Skip to content

Commit 547a34b

Browse files
committed
feat: load gist info on-demand
1 parent 6773902 commit 547a34b

9 files changed

Lines changed: 25 additions & 10 deletions

File tree

src/locale/de.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ export const de: Strings = {
323323
gistId: 'Gist-ID',
324324
gistIdHint: '(optional, automatisch aus Ihren Gists erkannt)',
325325
gistIdPlaceholder: 'Leer lassen, um ein neues Gist zu erstellen',
326+
loadSettings: 'Einstellungen laden',
326327
hide: 'Ausblenden',
327328
show: 'Anzeigen',
328329
},

src/locale/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ export const en = {
322322
gistId: 'Gist ID',
323323
gistIdHint: '(optional, auto-detected from your gists)',
324324
gistIdPlaceholder: 'Leave empty to create a new gist',
325+
loadSettings: 'Load Settings',
325326
hide: 'Hide',
326327
show: 'Show',
327328
},

src/locale/es.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ export const es: Strings = {
323323
gistId: 'ID del Gist',
324324
gistIdHint: '(opcional, auto-detectado de tus gists)',
325325
gistIdPlaceholder: 'Dejar vacío para crear un nuevo gist',
326+
loadSettings: 'Cargar configuración',
326327
hide: 'Ocultar',
327328
show: 'Mostrar',
328329
},

src/locale/fr.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ export const fr: Strings = {
323323
gistId: 'ID du Gist',
324324
gistIdHint: '(optionnel, détecté automatiquement depuis vos gists)',
325325
gistIdPlaceholder: 'Laisser vide pour créer un nouveau gist',
326+
loadSettings: 'Charger les paramètres',
326327
hide: 'Masquer',
327328
show: 'Afficher',
328329
},

src/locale/it.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ export const it: Strings = {
323323
gistId: 'ID del Gist',
324324
gistIdHint: '(opzionale, rilevato automaticamente dai tuoi gist)',
325325
gistIdPlaceholder: 'Lascia vuoto per creare un nuovo gist',
326+
loadSettings: 'Carica impostazioni',
326327
hide: 'Nascondi',
327328
show: 'Mostra',
328329
},

src/locale/pt-BR.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ export const ptBR: Strings = {
323323
gistId: 'ID do Gist',
324324
gistIdHint: '(opcional, auto-detectado de seus gists)',
325325
gistIdPlaceholder: 'Deixe em branco para criar um novo gist',
326+
loadSettings: 'Carregar configurações',
326327
hide: 'Ocultar',
327328
show: 'Mostrar',
328329
},

src/locale/pt-PT.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ export const ptPT: Strings = {
323323
gistId: 'ID do Gist',
324324
gistIdHint: '(opcional, detetado automaticamente dos seus gists)',
325325
gistIdPlaceholder: 'Deixe em branco para criar um novo gist',
326+
loadSettings: 'Carregar definições',
326327
hide: 'Ocultar',
327328
show: 'Mostrar',
328329
},

src/locale/ru.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ export const ru: Strings = {
323323
gistId: 'ID Gist',
324324
gistIdHint: '(необязательно, определяется автоматически из ваших gist)',
325325
gistIdPlaceholder: 'Оставьте пустым для создания нового gist',
326+
loadSettings: 'Загрузить настройки',
326327
hide: 'Скрыть',
327328
show: 'Показать',
328329
},

web/preferences/components/sync/Sync.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ app.component('SyncTab', {
2828
</div>
2929
<span class="sync-card-description">{{ $i18n.preferences.sync.githubGistDesc }}</span>
3030
</div>
31-
<div class="sync-card-body">
31+
<div class="sync-card-body" v-if="settingsLoaded">
3232
<div class="sync-field">
3333
<label>{{ $i18n.preferences.sync.personalAccessToken }}</label>
3434
<div class="input-group input-group-sm">
@@ -45,11 +45,15 @@ app.component('SyncTab', {
4545
</div>
4646
</div>
4747
<div class="sync-card-actions">
48-
<button class="btn btn-sm btn-secondary" :disabled="!gist.token || loading" @click="gistPull">
48+
<button v-if="!settingsLoaded" class="btn btn-sm btn-secondary" :disabled="loading" @click="loadSettings">
49+
<span v-if="loading === 'load-settings'" class="spinner-border spinner-border-sm me-1"></span>
50+
{{ $i18n.preferences.sync.loadSettings }}
51+
</button>
52+
<button v-if="settingsLoaded" class="btn btn-sm btn-secondary" :disabled="!gist.token || loading" @click="gistPull">
4953
<span v-if="loading === 'gist-pull'" class="spinner-border spinner-border-sm me-1"></span>
5054
{{ $i18n.preferences.sync.import }}
5155
</button>
52-
<button class="btn btn-sm btn-secondary" :disabled="!gist.token || loading" @click="gistPush">
56+
<button v-if="settingsLoaded" class="btn btn-sm btn-secondary" :disabled="!gist.token || loading" @click="gistPush">
5357
<span v-if="loading === 'gist-push'" class="spinner-border spinner-border-sm me-1"></span>
5458
{{ $i18n.preferences.sync.export }}
5559
</button>
@@ -65,19 +69,22 @@ app.component('SyncTab', {
6569
return {
6670
showToken: false,
6771
loading: null,
72+
settingsLoaded: false,
6873
gist: { token: '', id: '' }
6974
}
7075
},
7176

72-
async created() {
73-
await this.loadSettings()
74-
},
75-
7677
methods: {
7778
async loadSettings() {
78-
const settings = await this.$remote.sync.getSettings()
79-
this.gist.token = settings.gistToken || ''
80-
this.gist.id = settings.gistId || ''
79+
this.loading = 'load-settings'
80+
try {
81+
const settings = await this.$remote.sync.getSettings()
82+
this.gist.token = settings.gistToken || ''
83+
this.gist.id = settings.gistId || ''
84+
this.settingsLoaded = true
85+
} finally {
86+
this.loading = null
87+
}
8188
},
8289

8390
saveGistSettings() {

0 commit comments

Comments
 (0)