Update StyleCustomizerBackgroundTab.vue
This commit is contained in:
@@ -60,6 +60,9 @@ const localRemoteHtmlPresetsRepositoryUrl = ref('');
|
|||||||
const localHtmlSearchTerm = ref('');
|
const localHtmlSearchTerm = ref('');
|
||||||
const remoteHtmlSearchTerm = ref('');
|
const remoteHtmlSearchTerm = ref('');
|
||||||
|
|
||||||
|
const localSpecificLoading = ref(false);
|
||||||
|
const remoteSpecificLoading = ref(false);
|
||||||
|
|
||||||
|
|
||||||
const initializeEditableState = () => {
|
const initializeEditableState = () => {
|
||||||
localTerminalBackgroundEnabled.value = isTerminalBackgroundEnabled.value;
|
localTerminalBackgroundEnabled.value = isTerminalBackgroundEnabled.value;
|
||||||
@@ -72,7 +75,13 @@ const initializeEditableState = () => {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
initializeEditableState();
|
initializeEditableState();
|
||||||
|
localSpecificLoading.value = true;
|
||||||
|
try {
|
||||||
await fetchLocalHtmlPresets();
|
await fetchLocalHtmlPresets();
|
||||||
|
} finally {
|
||||||
|
localSpecificLoading.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch remote URL if not already set, or always? Per plan, store initializes it.
|
// Fetch remote URL if not already set, or always? Per plan, store initializes it.
|
||||||
// If store's remoteHtmlPresetsRepositoryUrl is null, then fetch it.
|
// If store's remoteHtmlPresetsRepositoryUrl is null, then fetch it.
|
||||||
if (!remoteHtmlPresetsRepositoryUrl.value) {
|
if (!remoteHtmlPresetsRepositoryUrl.value) {
|
||||||
@@ -80,7 +89,12 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
// If a URL exists, fetch remote presets
|
// If a URL exists, fetch remote presets
|
||||||
if (remoteHtmlPresetsRepositoryUrl.value) {
|
if (remoteHtmlPresetsRepositoryUrl.value) {
|
||||||
|
remoteSpecificLoading.value = true;
|
||||||
|
try {
|
||||||
await fetchRemoteHtmlPresets();
|
await fetchRemoteHtmlPresets();
|
||||||
|
} finally {
|
||||||
|
remoteSpecificLoading.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -299,9 +313,22 @@ const handleSaveRemoteRepositoryUrl = async () => {
|
|||||||
await updateRemoteHtmlPresetsRepositoryUrl(localRemoteHtmlPresetsRepositoryUrl.value);
|
await updateRemoteHtmlPresetsRepositoryUrl(localRemoteHtmlPresetsRepositoryUrl.value);
|
||||||
notificationsStore.addNotification({ type: 'success', message: t('styleCustomizer.remoteUrlSaved') });
|
notificationsStore.addNotification({ type: 'success', message: t('styleCustomizer.remoteUrlSaved') });
|
||||||
// Optionally fetch presets immediately after saving new URL
|
// Optionally fetch presets immediately after saving new URL
|
||||||
|
if (localRemoteHtmlPresetsRepositoryUrl.value) {
|
||||||
|
remoteSpecificLoading.value = true;
|
||||||
|
try {
|
||||||
await fetchRemoteHtmlPresets(localRemoteHtmlPresetsRepositoryUrl.value);
|
await fetchRemoteHtmlPresets(localRemoteHtmlPresetsRepositoryUrl.value);
|
||||||
|
} finally {
|
||||||
|
remoteSpecificLoading.value = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// If URL is cleared, ensure remote presets are cleared and loading indicator is off.
|
||||||
|
// The store's fetchRemoteHtmlPresets might handle clearing presets if URL is empty.
|
||||||
|
if (remoteHtmlPresets.value?.length) remoteHtmlPresets.value = [];
|
||||||
|
remoteSpecificLoading.value = false;
|
||||||
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
notificationsStore.addNotification({ type: 'error', message: t('styleCustomizer.remoteUrlSaveFailed', { message: error.message }) });
|
notificationsStore.addNotification({ type: 'error', message: t('styleCustomizer.remoteUrlSaveFailed', { message: error.message }) });
|
||||||
|
remoteSpecificLoading.value = false; // Ensure loading indicator is off on error
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -310,6 +337,7 @@ const handleLoadRemotePresets = async () => {
|
|||||||
notificationsStore.addNotification({ type: 'error', message: t('styleCustomizer.errorSetRemoteUrlFirst') });
|
notificationsStore.addNotification({ type: 'error', message: t('styleCustomizer.errorSetRemoteUrlFirst') });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
remoteSpecificLoading.value = true;
|
||||||
try {
|
try {
|
||||||
await fetchRemoteHtmlPresets();
|
await fetchRemoteHtmlPresets();
|
||||||
if (!htmlPresetError.value) {
|
if (!htmlPresetError.value) {
|
||||||
@@ -317,6 +345,8 @@ const handleLoadRemotePresets = async () => {
|
|||||||
}
|
}
|
||||||
} catch (error: any) { // This catch might not be needed if store handles errors
|
} catch (error: any) { // This catch might not be needed if store handles errors
|
||||||
notificationsStore.addNotification({ type: 'error', message: t('styleCustomizer.remotePresetsLoadFailed', { message: error.message }) });
|
notificationsStore.addNotification({ type: 'error', message: t('styleCustomizer.remotePresetsLoadFailed', { message: error.message }) });
|
||||||
|
} finally {
|
||||||
|
remoteSpecificLoading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -481,7 +511,7 @@ const filteredRemoteHtmlPresets = computed(() => {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="isLoadingHtmlPresets" class="text-center p-4 text-text-secondary">
|
<div v-if="localSpecificLoading" class="text-center p-4 text-text-secondary">
|
||||||
{{ t('common.loading') }}
|
{{ t('common.loading') }}
|
||||||
</div>
|
</div>
|
||||||
<ul v-else-if="filteredLocalHtmlPresets.length > 0" class="list-none p-0 mt-4 max-h-[200px] md:max-h-[280px] overflow-y-auto border border-border rounded bg-background">
|
<ul v-else-if="filteredLocalHtmlPresets.length > 0" class="list-none p-0 mt-4 max-h-[200px] md:max-h-[280px] overflow-y-auto border border-border rounded bg-background">
|
||||||
@@ -561,8 +591,8 @@ const filteredRemoteHtmlPresets = computed(() => {
|
|||||||
<button @click="handleSaveRemoteRepositoryUrl" class="px-3 py-1.5 text-sm border border-border rounded bg-header hover:bg-border transition duration-200 ease-in-out whitespace-nowrap flex-shrink-0">
|
<button @click="handleSaveRemoteRepositoryUrl" class="px-3 py-1.5 text-sm border border-border rounded bg-header hover:bg-border transition duration-200 ease-in-out whitespace-nowrap flex-shrink-0">
|
||||||
{{ t('common.save') }}
|
{{ t('common.save') }}
|
||||||
</button>
|
</button>
|
||||||
<button @click="handleLoadRemotePresets" :disabled="!remoteHtmlPresetsRepositoryUrl || isLoadingHtmlPresets" class="px-3 py-1.5 text-sm border border-border rounded bg-header hover:bg-border transition duration-200 ease-in-out whitespace-nowrap disabled:opacity-50 flex-shrink-0">
|
<button @click="handleLoadRemotePresets" :disabled="!remoteHtmlPresetsRepositoryUrl || remoteSpecificLoading" class="px-3 py-1.5 text-sm border border-border rounded bg-header hover:bg-border transition duration-200 ease-in-out whitespace-nowrap disabled:opacity-50 flex-shrink-0">
|
||||||
{{ isLoadingHtmlPresets && currentActiveTab === 'remote' ? t('common.loading') : t('styleCustomizer.loadRemoteThemes') }}
|
{{ remoteSpecificLoading ? t('common.loading') : t('styleCustomizer.loadRemoteThemes') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -577,7 +607,7 @@ const filteredRemoteHtmlPresets = computed(() => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="isLoadingHtmlPresets && currentActiveTab === 'remote'" class="text-center p-4 text-text-secondary">
|
<div v-if="remoteSpecificLoading && currentActiveTab === 'remote'" class="text-center p-4 text-text-secondary">
|
||||||
{{ t('common.loading') }}
|
{{ t('common.loading') }}
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="htmlPresetError && currentActiveTab === 'remote'" class="p-4 mb-4 text-sm text-red-700 bg-red-100 rounded-lg dark:bg-red-200 dark:text-red-800" role="alert">
|
<div v-else-if="htmlPresetError && currentActiveTab === 'remote'" class="p-4 mb-4 text-sm text-red-700 bg-red-100 rounded-lg dark:bg-red-200 dark:text-red-800" role="alert">
|
||||||
|
|||||||
Reference in New Issue
Block a user