A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
feat(app): let people snooze the unclaimed account banner
Hampus52c14f2333a3
diff --git a/fluxer_app/src/features/ui/state/Nagbar.ts b/fluxer_app/src/features/ui/state/Nagbar.tsindex b0a39f9e6..d57bed743 100644--- a/fluxer_app/src/features/ui/state/Nagbar.ts+++ b/fluxer_app/src/features/ui/state/Nagbar.ts@@ -1,5 +1,6 @@// SPDX-License-Identifier: AGPL-3.0-or-later+import {ResettableStates} from '@app/features/app/state/ResettableStates';import {initializeStore} from '@app/features/platform/utils/StoreInitialization';import {makeSyncedField} from '@app/features/user/state/SyncedField';import {NagbarDismissalsSchema} from '@fluxer/schema/src/gen/fluxer/user/preferences/v1/preferences_pb';@@ -22,7 +23,6 @@ interface NagbarSettings {legacyPriceOptInDismissed: Record<string, boolean>;guildMembershipCtaDismissed: boolean;visionaryMfaDismissed: boolean;- claimAccountModalShownThisSession: boolean;forceConnectionNotice: boolean;forceEmailVerification: boolean;forceAccountLimited: boolean;@@ -67,7 +67,6 @@ export type NagbarToggleKey = Exclude<keyof NagbarSettings,| 'guildMfaRequirementDismissed'| 'invitesDisabledDismissed'- | 'claimAccountModalShownThisSession'| 'pendingBulkDeletionDismissed'| 'priceAnnouncementDismissed'| 'legacyPriceOptInDismissed'@@ -92,7 +91,7 @@ export class Nagbar implements NagbarSettings {visionaryMfaDismissed = false;buildEnvironmentDismissedThisSession = false;scheduledMaintenanceDismissalVersion = 0;- claimAccountModalShownThisSession = false;+ unclaimedAccountDismissedThisSession = false;forceEmailVerification = false;forceAccountLimited = false;forceUnclaimedAccount = false;@@ -222,8 +221,8 @@ export class Nagbar implements NagbarSettings {this.buildEnvironmentDismissedThisSession = true;}- markClaimAccountModalShown(): void {- this.claimAccountModalShownThisSession = true;+ dismissUnclaimedAccountForSession(): void {+ this.unclaimedAccountDismissedThisSession = true;}dismiss(nagbarType: NagbarToggleKey): void {@@ -266,6 +265,10 @@ export class Nagbar implements NagbarSettings {this[key] = value;}+ resetSessionDismissals(): void {+ this.unclaimedAccountDismissedThisSession = false;+ }+resetAll(): void {this.iosInstallDismissed = false;this.pwaInstallDismissed = false;@@ -284,7 +287,7 @@ export class Nagbar implements NagbarSettings {this.guildMembershipCtaDismissed = false;this.visionaryMfaDismissed = false;this.buildEnvironmentDismissedThisSession = false;- this.claimAccountModalShownThisSession = false;+ this.unclaimedAccountDismissedThisSession = false;this.forceEmailVerification = false;this.forceAccountLimited = false;this.forceUnclaimedAccount = false;@@ -350,4 +353,8 @@ export class Nagbar implements NagbarSettings {}}-export default new Nagbar();+const nagbar = new Nagbar();++ResettableStates.register(nagbar, () => nagbar.resetSessionDismissals());++export default nagbar;diff --git a/fluxer_app/src/features/ui/state/UnclaimedNagbarSnooze.ts b/fluxer_app/src/features/ui/state/UnclaimedNagbarSnooze.tsnew file mode 100644index 000000000..416db728a--- /dev/null+++ b/fluxer_app/src/features/ui/state/UnclaimedNagbarSnooze.ts@@ -0,0 +1,34 @@+// SPDX-License-Identifier: AGPL-3.0-or-later++import {getProtectedLocalStorage} from '@app/features/platform/state/ProtectedWebStorage';+import {Logger} from '@app/features/platform/utils/AppLogger';+import {MS_PER_DAY} from '@fluxer/date_utils/src/DateConstants';++const logger = new Logger('UnclaimedNagbarSnooze');++const SNOOZE_KEY_PREFIX = 'fluxer.unclaimed_nagbar_snoozed_until';+const UNCLAIMED_NAGBAR_SNOOZE_MS = 3 * MS_PER_DAY;++function snoozeKey(userId: string): string {+ return `${SNOOZE_KEY_PREFIX}:${userId}`;+}++export function snoozeUnclaimedNagbar(userId: string): void {+ const now = Date.now();+ try {+ getProtectedLocalStorage()?.setItem(snoozeKey(userId), String(now + UNCLAIMED_NAGBAR_SNOOZE_MS));+ } catch (error) {+ logger.warn('Failed to persist the unclaimed account banner snooze', error);+ }+}++export function isUnclaimedNagbarSnoozed(userId: string): boolean {+ const now = Date.now();+ try {+ const until = Number(getProtectedLocalStorage()?.getItem(snoozeKey(userId)) ?? '0');+ return Number.isFinite(until) && until > now;+ } catch (error) {+ logger.warn('Failed to read the unclaimed account banner snooze', error);+ return false;+ }+}