Skip to content

Commit

Permalink
fix: Move profilesCleanDeadline to account.settings
Browse files Browse the repository at this point in the history
account.settings is :
- per user
- kept after a logout

So it will avoid two users to share the same profilesCleanDeadline.
  • Loading branch information
zatteo committed May 2, 2024
1 parent d7fab69 commit e59337b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 4 additions & 0 deletions libs/common/src/models/domain/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ export class AccountSettings {
avatarColor?: string;
activateAutoFillOnPageLoadFromPolicy?: boolean;
smOnboardingTasks?: Record<string, Record<string, boolean>>;
// Cozy customization, clean profiles after X days
//*
profilesCleanDeadline?: string;
//*/

static fromJSON(obj: Jsonify<AccountSettings>): AccountSettings {
if (obj == null) {
Expand Down
4 changes: 0 additions & 4 deletions libs/common/src/models/domain/global-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,4 @@ export class GlobalState {
enableBrowserIntegration?: boolean;
enableBrowserIntegrationFingerprint?: boolean;
enableDuckDuckGoBrowserIntegration?: boolean;
// Cozy customization, clean profiles after X days
//*
profilesCleanDeadline: string;
//*/
}
12 changes: 6 additions & 6 deletions libs/common/src/services/state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2911,8 +2911,8 @@ export class StateService<
//*
async getProfilesCleanDeadline(options?: StorageOptions): Promise<Date | null> {
const valueString = (
await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
)?.profilesCleanDeadline;
await this.getAccount(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
)?.settings?.profilesCleanDeadline;

if (valueString) {
return parseISO(valueString);
Expand All @@ -2922,12 +2922,12 @@ export class StateService<
}

async setProfilesCleanDeadline(value: Date, options?: StorageOptions): Promise<void> {
const globals = await this.getGlobals(
const account = await this.getAccount(
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
);
globals.profilesCleanDeadline = formatISO(value);
await this.saveGlobals(
globals,
account.settings.profilesCleanDeadline = formatISO(value);
await this.saveAccount(
account,
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
);
}
Expand Down

0 comments on commit e59337b

Please sign in to comment.