From aa21b6810674f1efc296fb30a879824b3ff1b47a Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sat, 17 Feb 2024 16:31:13 -0600 Subject: [PATCH] Add synced icon to saves in saves manager --- src/components/saves/Save.vue | 18 ++++++++++++++++++ src/util/galaxy.ts | 9 ++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/components/saves/Save.vue b/src/components/saves/Save.vue index d8af7d0..93cfee2 100644 --- a/src/components/saves/Save.vue +++ b/src/components/saves/Save.vue @@ -53,6 +53,9 @@
+ cloud @@ -80,6 +83,7 @@ import DangerButton from "../fields/DangerButton.vue"; import FeedbackButton from "../fields/FeedbackButton.vue"; import Text from "../fields/Text.vue"; import type { LoadablePlayerData } from "./SavesManager.vue"; +import { galaxy, syncedSaves } from "util/galaxy"; const _props = defineProps<{ save: LoadablePlayerData; @@ -115,6 +119,9 @@ const isActive = computed( const currentTime = computed(() => isActive.value ? player.time : (save.value != null && save.value.time) ?? 0 ); +const synced = computed( + () => !unref(readonly) && galaxy.value?.loggedIn && syncedSaves.value.includes(save.value.id) +); function changeName() { emit("editName", newName.value); @@ -196,6 +203,13 @@ function changeName() { .time { font-size: small; } + +.synced { + font-size: 100%; + margin-right: 0.5em; + vertical-align: middle; + cursor: default; +} diff --git a/src/util/galaxy.ts b/src/util/galaxy.ts index d74d17b..ab79d82 100644 --- a/src/util/galaxy.ts +++ b/src/util/galaxy.ts @@ -10,6 +10,7 @@ export const galaxy = ref(); export const conflictingSaves = ref< { id: string; local: LoadablePlayerData; cloud: LoadablePlayerData; slot: number }[] >([]); +export const syncedSaves = ref([]); export function sync() { if (galaxy.value == null || !galaxy.value.loggedIn) { @@ -19,7 +20,13 @@ export function sync() { // Pause syncing while resolving conflicted saves return; } - galaxy.value.getSaveList().then(syncSaves).catch(console.error); + galaxy.value + .getSaveList() + .then(syncSaves) + .then(list => { + syncedSaves.value = list.map(s => s.content.id); + }) + .catch(console.error); } // Setup Galaxy API