Skip to content

Commit

Permalink
responsive miner toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Dec 5, 2023
1 parent 9cf0768 commit 9d87fb8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
20 changes: 16 additions & 4 deletions src/components/miner/ToggleMiner.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
<script lang="ts">
import { minerLoopEnabled } from '../../modules/miner'
import { toggleMining } from '../../modules/miner_toggle'
let checking = false
const toggle = () => {
checking = true
setTimeout(() => (checking = false), 1000)
toggleMining()
}
</script>

<main>
<div class="uk-text-center uk-margin" style="position: relative">
<label class="uk-switch">
<input type="checkbox" on:click={() => toggleMining()} checked={$minerLoopEnabled} />
<div class="uk-switch-slider uk-switch-on-off round" />
</label>
{#if !checking}
<label class="uk-switch">
<input type="checkbox" on:click={toggle} checked={$minerLoopEnabled} />
<div class="uk-switch-slider uk-switch-on-off round" />
</label>
{:else}
<div uk-spinner></div>
{/if}
</div>
</main>
12 changes: 8 additions & 4 deletions src/modules/miner_invoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,20 @@ export const startBacklogListener = async () => {
.then((res) => {
responses.set(res as string)
backlogListenerReady.set(true)
minerLoopEnabled.set(true)
return res
})
.catch((e: CarpeError) => {
let be_quiet = false
let quiet_errors = false
if (e.uid == 104) {
// check for know error: key not found after upgrade
// check for known error: key not found after upgrade
isKeyError.set(true)
be_quiet = true
backlogListenerReady.set(false)
minerLoopEnabled.set(false)

quiet_errors = true
}
raise_error(e, be_quiet, 'startBacklogListener')
raise_error(e, quiet_errors, 'startBacklogListener')
})
}

Expand Down
5 changes: 1 addition & 4 deletions src/modules/miner_toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ export const enableMining = async (): Promise<void> => {
// if the user has stuck proofs, we will show an error screen with a button for
// manually triggering the backlog.

startBacklogListener()
.then(carpeTick)
.then(() => minerLoopEnabled.set(true))
.then(maybeTowerOnce)
startBacklogListener().then(carpeTick).then(maybeTowerOnce)

looper = setInterval(() => setProofPercent(), 5000)
}
Expand Down

0 comments on commit 9d87fb8

Please sign in to comment.