mirror of
https://github.com/paricafe/misskey.git
synced 2025-03-23 11:39:25 -05:00
refactor
This commit is contained in:
parent
9876ff9a7a
commit
8593aa1418
2 changed files with 8 additions and 8 deletions
packages/frontend/src
|
@ -7,25 +7,25 @@ import { v4 as uuid } from 'uuid';
|
|||
import type { PreferencesProfile, StorageProvider } from '@/preferences/manager.js';
|
||||
import { cloudBackup } from '@/preferences/utility.js';
|
||||
import { miLocalStorage } from '@/local-storage.js';
|
||||
import { isSameCond, ProfileManager } from '@/preferences/manager.js';
|
||||
import { isSameCond, PreferencesManager } from '@/preferences/manager.js';
|
||||
import { store } from '@/store.js';
|
||||
import { $i } from '@/account.js';
|
||||
import { misskeyApi } from '@/utility/misskey-api.js';
|
||||
|
||||
const TAB_ID = uuid();
|
||||
|
||||
function createProfileManager(storageProvider: StorageProvider) {
|
||||
function createPrefManager(storageProvider: StorageProvider) {
|
||||
let profile: PreferencesProfile;
|
||||
|
||||
const savedProfileRaw = miLocalStorage.getItem('preferences');
|
||||
if (savedProfileRaw == null) {
|
||||
profile = ProfileManager.newProfile();
|
||||
profile = PreferencesManager.newProfile();
|
||||
miLocalStorage.setItem('preferences', JSON.stringify(profile));
|
||||
} else {
|
||||
profile = ProfileManager.normalizeProfile(JSON.parse(savedProfileRaw));
|
||||
profile = PreferencesManager.normalizeProfile(JSON.parse(savedProfileRaw));
|
||||
}
|
||||
|
||||
return new ProfileManager(profile, storageProvider);
|
||||
return new PreferencesManager(profile, storageProvider);
|
||||
}
|
||||
|
||||
const syncGroup = 'default';
|
||||
|
@ -104,7 +104,7 @@ const storageProvider: StorageProvider = {
|
|||
},
|
||||
};
|
||||
|
||||
export const prefer = createProfileManager(storageProvider);
|
||||
export const prefer = createPrefManager(storageProvider);
|
||||
|
||||
let latestSyncedAt = Date.now();
|
||||
|
||||
|
@ -118,7 +118,7 @@ function syncBetweenTabs() {
|
|||
if (latestTab === TAB_ID) return;
|
||||
if (latestAt <= latestSyncedAt) return;
|
||||
|
||||
prefer.rewriteProfile(ProfileManager.normalizeProfile(JSON.parse(miLocalStorage.getItem('preferences')!)));
|
||||
prefer.rewriteProfile(PreferencesManager.normalizeProfile(JSON.parse(miLocalStorage.getItem('preferences')!)));
|
||||
|
||||
latestSyncedAt = Date.now();
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ export type PreferencesDefinition = Record<string, {
|
|||
serverDependent?: boolean;
|
||||
}>;
|
||||
|
||||
export class ProfileManager {
|
||||
export class PreferencesManager {
|
||||
private storageProvider: StorageProvider;
|
||||
public profile: PreferencesProfile;
|
||||
public cloudReady: Promise<void>;
|
||||
|
|
Loading…
Add table
Reference in a new issue