Skip to content

Commit 4063386

Browse files
syuiloDA-TENSHI
authored andcommitted
refactor
1 parent 3253c48 commit 4063386

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/frontend/src/preferences/utility.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ import { $i } from '@/account.js';
1616
import { misskeyApi } from '@/scripts/misskey-api.js';
1717
import { unisonReload } from '@/scripts/unison-reload.js';
1818

19+
function canAutoBackup() {
20+
return profileManager.profile.name != null && profileManager.profile.name.trim() !== '';
21+
}
22+
1923
export function getPreferencesProfileMenu(): MenuItem[] {
2024
const autoBackupEnabled = ref(store.state.enablePreferencesAutoCloudBackup);
2125

2226
watch(autoBackupEnabled, () => {
2327
if (autoBackupEnabled.value) {
24-
if (profileManager.profile.name == null || profileManager.profile.name.trim() === '') {
28+
if (!canAutoBackup()) {
2529
autoBackupEnabled.value = false;
2630
os.alert({
2731
type: 'warning',
@@ -130,7 +134,7 @@ function importProfile() {
130134

131135
export async function cloudBackup() {
132136
if ($i == null) return;
133-
if (profileManager.profile.name == null || profileManager.profile.name.trim() === '') {
137+
if (!canAutoBackup()) {
134138
throw new Error('Profile name is not set');
135139
}
136140

@@ -185,11 +189,11 @@ export async function restoreFromCloudBackup() {
185189
}
186190

187191
export async function enableAutoBackup() {
188-
if (profileManager.profile.name == null || profileManager.profile.name.trim() === '') {
192+
if (!canAutoBackup()) {
189193
await renameProfile();
190194
}
191195

192-
if (profileManager.profile.name == null || profileManager.profile.name.trim() === '') {
196+
if (!canAutoBackup()) {
193197
return;
194198
}
195199

0 commit comments

Comments
 (0)