fix: user preferences
This commit is contained in:
@@ -14,7 +14,7 @@ export class PreferencesManager extends ApplicationService {
|
|||||||
private userPreferences!: SNUserPrefs;
|
private userPreferences!: SNUserPrefs;
|
||||||
private loadingPrefs = false;
|
private loadingPrefs = false;
|
||||||
private unubscribeStreamItems?: () => void;
|
private unubscribeStreamItems?: () => void;
|
||||||
private shouldReloadSingleton = true;
|
private needsSingletonReload = true;
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
async onAppLaunch() {
|
async onAppLaunch() {
|
||||||
@@ -24,6 +24,7 @@ export class PreferencesManager extends ApplicationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onAppEvent(event: ApplicationEvent) {
|
async onAppEvent(event: ApplicationEvent) {
|
||||||
|
super.onAppEvent(event);
|
||||||
if (event === ApplicationEvent.CompletedFullSync) {
|
if (event === ApplicationEvent.CompletedFullSync) {
|
||||||
this.reloadSingleton();
|
this.reloadSingleton();
|
||||||
}
|
}
|
||||||
@@ -41,13 +42,13 @@ export class PreferencesManager extends ApplicationService {
|
|||||||
this.unubscribeStreamItems = this.application!.streamItems(
|
this.unubscribeStreamItems = this.application!.streamItems(
|
||||||
ContentType.UserPrefs,
|
ContentType.UserPrefs,
|
||||||
() => {
|
() => {
|
||||||
this.shouldReloadSingleton = true;
|
this.needsSingletonReload = true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async reloadSingleton() {
|
private async reloadSingleton() {
|
||||||
if (this.loadingPrefs || !this.shouldReloadSingleton) {
|
if (this.loadingPrefs || !this.needsSingletonReload) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loadingPrefs = true;
|
this.loadingPrefs = true;
|
||||||
@@ -60,6 +61,7 @@ export class PreferencesManager extends ApplicationService {
|
|||||||
FillItemContent({}),
|
FillItemContent({}),
|
||||||
)) as SNUserPrefs;
|
)) as SNUserPrefs;
|
||||||
this.loadingPrefs = false;
|
this.loadingPrefs = false;
|
||||||
|
this.needsSingletonReload = false;
|
||||||
const didChange =
|
const didChange =
|
||||||
!previousRef ||
|
!previousRef ||
|
||||||
this.userPreferences.lastSyncBegan?.getTime() !==
|
this.userPreferences.lastSyncBegan?.getTime() !==
|
||||||
|
|||||||
Reference in New Issue
Block a user