@@ -16,12 +16,16 @@ import { $i } from '@/account.js';
16
16
import { misskeyApi } from '@/scripts/misskey-api.js' ;
17
17
import { unisonReload } from '@/scripts/unison-reload.js' ;
18
18
19
+ function canAutoBackup ( ) {
20
+ return profileManager . profile . name != null && profileManager . profile . name . trim ( ) !== '' ;
21
+ }
22
+
19
23
export function getPreferencesProfileMenu ( ) : MenuItem [ ] {
20
24
const autoBackupEnabled = ref ( store . state . enablePreferencesAutoCloudBackup ) ;
21
25
22
26
watch ( autoBackupEnabled , ( ) => {
23
27
if ( autoBackupEnabled . value ) {
24
- if ( profileManager . profile . name == null || profileManager . profile . name . trim ( ) === '' ) {
28
+ if ( ! canAutoBackup ( ) ) {
25
29
autoBackupEnabled . value = false ;
26
30
os . alert ( {
27
31
type : 'warning' ,
@@ -130,7 +134,7 @@ function importProfile() {
130
134
131
135
export async function cloudBackup ( ) {
132
136
if ( $i == null ) return ;
133
- if ( profileManager . profile . name == null || profileManager . profile . name . trim ( ) === '' ) {
137
+ if ( ! canAutoBackup ( ) ) {
134
138
throw new Error ( 'Profile name is not set' ) ;
135
139
}
136
140
@@ -185,11 +189,11 @@ export async function restoreFromCloudBackup() {
185
189
}
186
190
187
191
export async function enableAutoBackup ( ) {
188
- if ( profileManager . profile . name == null || profileManager . profile . name . trim ( ) === '' ) {
192
+ if ( ! canAutoBackup ( ) ) {
189
193
await renameProfile ( ) ;
190
194
}
191
195
192
- if ( profileManager . profile . name == null || profileManager . profile . name . trim ( ) === '' ) {
196
+ if ( ! canAutoBackup ( ) ) {
193
197
return ;
194
198
}
195
199
0 commit comments