summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2025-03-09 12:39:43 +0900
committersyuilo <4439005+syuilo@users.noreply.github.com>2025-03-09 12:39:43 +0900
commitabc1e9168d41c168a0c67bb2910fe5bf326b4f99 (patch)
tree5e8f1a077fcf527287ebc190f06aaa63b84cb188
parentRefine preferences (#15597) (diff)
downloadmisskey-abc1e9168d41c168a0c67bb2910fe5bf326b4f99.tar.gz
misskey-abc1e9168d41c168a0c67bb2910fe5bf326b4f99.tar.bz2
misskey-abc1e9168d41c168a0c67bb2910fe5bf326b4f99.zip
refactor
-rw-r--r--packages/frontend/src/preferences/utility.ts12
1 files changed, 8 insertions, 4 deletions
diff --git a/packages/frontend/src/preferences/utility.ts b/packages/frontend/src/preferences/utility.ts
index 7979695231..e9dd088462 100644
--- a/packages/frontend/src/preferences/utility.ts
+++ b/packages/frontend/src/preferences/utility.ts
@@ -16,12 +16,16 @@ import { $i } from '@/account.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { unisonReload } from '@/scripts/unison-reload.js';
+function canAutoBackup() {
+ return profileManager.profile.name != null && profileManager.profile.name.trim() !== '';
+}
+
export function getPreferencesProfileMenu(): MenuItem[] {
const autoBackupEnabled = ref(store.state.enablePreferencesAutoCloudBackup);
watch(autoBackupEnabled, () => {
if (autoBackupEnabled.value) {
- if (profileManager.profile.name == null || profileManager.profile.name.trim() === '') {
+ if (!canAutoBackup()) {
autoBackupEnabled.value = false;
os.alert({
type: 'warning',
@@ -130,7 +134,7 @@ function importProfile() {
export async function cloudBackup() {
if ($i == null) return;
- if (profileManager.profile.name == null || profileManager.profile.name.trim() === '') {
+ if (!canAutoBackup()) {
throw new Error('Profile name is not set');
}
@@ -185,11 +189,11 @@ export async function restoreFromCloudBackup() {
}
export async function enableAutoBackup() {
- if (profileManager.profile.name == null || profileManager.profile.name.trim() === '') {
+ if (!canAutoBackup()) {
await renameProfile();
}
- if (profileManager.profile.name == null || profileManager.profile.name.trim() === '') {
+ if (!canAutoBackup()) {
return;
}