diff --git a/src/util/galaxy.ts b/src/util/galaxy.ts index e5fadc3..420ecb8 100644 --- a/src/util/galaxy.ts +++ b/src/util/galaxy.ts @@ -54,8 +54,8 @@ function onLoggedInChanged(g: GalaxyApi) { .then(list => { const saves = syncSaves(list); - // If our current save has under a minute of playtime, load the cloud save with the most recent time. - if (player.timePlayed < 60 && saves.length > 0) { + // If our current save has under 2 minutes of playtime, load the cloud save with the most recent time. + if (player.timePlayed < 120 && saves.length > 0) { const longestSave = saves.reduce((acc, curr) => acc.content.time < curr.content.time ? curr : acc ); @@ -63,6 +63,8 @@ function onLoggedInChanged(g: GalaxyApi) { } }) .catch(console.error); + + setInterval(sync, 60000); } function syncSaves( @@ -123,9 +125,9 @@ function syncSaves( localSave.timePlayed - cloudSave.content.timePlayed ); const timeDiff = Math.abs(localSave.time - cloudSave.content.time); - // If their last played time and total time played are both within a minute, just use the newer save (very unlikely to be coincidence) + // If their last played time and total time played are both within 2 minutes, just use the newer save (very unlikely to be coincidence) // Otherwise, ask the player - if (timePlayedDiff < 60 && timeDiff < 60) { + if (timePlayedDiff < 120 && timeDiff < 120) { if (localSave.time < cloudSave.content.time) { save(setupInitialStore(cloudSave.content)); if (settings.active === localSaveId) { diff --git a/src/util/save.ts b/src/util/save.ts index 90eca12..a7830cd 100644 --- a/src/util/save.ts +++ b/src/util/save.ts @@ -6,7 +6,6 @@ import player, { stringifySave } from "game/player"; import settings, { loadSettings } from "game/settings"; import LZString from "lz-string"; import { ref, shallowReactive } from "vue"; -import { sync } from "./galaxy"; export function setupInitialStore(player: Partial = {}): Player { return Object.assign( @@ -31,7 +30,6 @@ export function setupInitialStore(player: Partial = {}): Player { export function save(playerData?: Player): string { const stringifiedSave = LZString.compressToUTF16(stringifySave(playerData ?? player)); localStorage.setItem((playerData ?? player).id, stringifiedSave); - sync(); return stringifiedSave; }