diff --git a/src/components/DataSync.svelte b/src/components/DataSync.svelte index 1cbbbeb3..77b089a3 100644 --- a/src/components/DataSync.svelte +++ b/src/components/DataSync.svelte @@ -8,6 +8,7 @@ import SyncConflictModal from '../components/SyncConflictModal.svelte'; import { pushToast } from '../stores/toast'; + import { t } from 'svelte-i18n'; const { open: openModal, close: closeModal } = getContext('simple-modal'); @@ -66,11 +67,20 @@ } function updateSigninStatus(status) { - console.log('update drive signed in status:', status); - driveSignedIn.set(status); + const hasScope = gapi.auth2.getAuthInstance().currentUser.get().hasGrantedScopes(SCOPES); + + if (status && !hasScope) { + pushToast($t('settings.driveSignInErrorScope'), 'error'); + gapi.auth2.getAuthInstance().signOut(); + } + + const finalStatus = status && hasScope; + + console.log('update drive signed in status:', finalStatus); + driveSignedIn.set(finalStatus); driveLoading.set(false); - if (status) { + if (finalStatus) { getFiles(); } else { synced.set(true); @@ -343,7 +353,6 @@ document.body.appendChild(fileLink); fileLink.click(); } - diff --git a/src/locales/en.json b/src/locales/en.json index 92a552f6..8e198471 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -552,6 +552,7 @@ "driveError": "Google Drive API cannot be loaded", "driveSignIn": "Sign in to Google Drive", "driveSignOut": "Sign out Google Drive", + "driveSignInErrorScope": "Drive Sign In failed! Please sign in again and check the required permission!", "synced": "Synced", "waiting": "Waiting...", "syncing": "Syncing...", diff --git a/src/locales/id.json b/src/locales/id.json index ba573238..5351f002 100644 --- a/src/locales/id.json +++ b/src/locales/id.json @@ -552,6 +552,7 @@ "driveError": "Google Drive API tidak bisa dimuat", "driveSignIn": "Sign in ke Google Drive", "driveSignOut": "Sign out dari Google Drive", + "driveSignInErrorScope": "Drive Sign In gagal! Silahkan login kembali dan cek permission yang diperlukan!", "synced": "Synced", "waiting": "Menunggu...", "syncing": "Syncing...", diff --git a/src/routes/settings/index.svelte b/src/routes/settings/index.svelte index b4b43b43..b0374798 100644 --- a/src/routes/settings/index.svelte +++ b/src/routes/settings/index.svelte @@ -252,7 +252,7 @@
-

{$t('settings.version')} 1.5

+

{$t('settings.version')} 2.0

{$t('settings.multiple')}