From 06b83f79ef2564cec8e597d9994dd02a95afc839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thea=20Sch=C3=B6bl?= Date: Fri, 5 Jan 2024 00:12:42 +0100 Subject: [PATCH] feat: add refresh button resolves #82 --- icons.config.js | 1 + src/i18n/de/index.ts | 1 + src/i18n/en/index.ts | 1 + src/lib/serial/connection.ts | 6 ++++++ src/routes/SyncOverlay.svelte | 35 +++++++++++++++++++++++------------ 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/icons.config.js b/icons.config.js index 0dc473f1..f5ffb0a6 100644 --- a/icons.config.js +++ b/icons.config.js @@ -92,6 +92,7 @@ const config = { "stat_2", "description", "add_circle", + "refresh", ], codePoints: { speed: "e9e4", diff --git a/src/i18n/de/index.ts b/src/i18n/de/index.ts index f81da39d..2e2a00ae 100644 --- a/src/i18n/de/index.ts +++ b/src/i18n/de/index.ts @@ -14,6 +14,7 @@ const de = { sync: { TITLE_READ: "Neueste Änderungen werden abgerufen", TITLE_WRITE: "Änderungen werden gespeichert", + RELOAD: "Neu laden", }, backup: { TITLE: "Verlauf speichern", diff --git a/src/i18n/en/index.ts b/src/i18n/en/index.ts index ea414776..756bcb03 100644 --- a/src/i18n/en/index.ts +++ b/src/i18n/en/index.ts @@ -21,6 +21,7 @@ const en = { sync: { TITLE_READ: "Reading latest changes", TITLE_WRITE: "Saving changes to device", + RELOAD: "Reload", }, modal: { CLOSE: "Close", diff --git a/src/lib/serial/connection.ts b/src/lib/serial/connection.ts index f9f6eb90..a09d1624 100644 --- a/src/lib/serial/connection.ts +++ b/src/lib/serial/connection.ts @@ -55,6 +55,12 @@ export async function initSerial(manual = false) { const device = get(serialPort) ?? new CharaDevice() await device.init(manual) serialPort.set(device) + sync() +} + +export async function sync() { + const device = get(serialPort) + if (!device) return const chordCount = await device.getChordCount() syncStatus.set("downloading") diff --git a/src/routes/SyncOverlay.svelte b/src/routes/SyncOverlay.svelte index e487295e..4c83cae9 100644 --- a/src/routes/SyncOverlay.svelte +++ b/src/routes/SyncOverlay.svelte @@ -1,21 +1,32 @@ -{#if $syncStatus !== "done"} -
- - {#if $syncStatus === "downloading"} -
{$LL.sync.TITLE_READ()}
- {:else} -
{$LL.sync.TITLE_WRITE()}
- {/if} -
-{/if} +
+ {#if $syncStatus !== "done"} +
+ + {#if $syncStatus === "downloading"} +
{$LL.sync.TITLE_READ()}
+ {:else} +
{$LL.sync.TITLE_WRITE()}
+ {/if} +
+ {:else if $serialPort} + + {/if} +