-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7422 from opengovsg/refactor/generalize-seen-flag
refactor: generalize user seen flag
- Loading branch information
Showing
18 changed files
with
206 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
frontend/src/services/FeatureFlagService.ts → ...tures/feature-flags/FeatureFlagService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { SeenFlags } from '~shared/types' | ||
|
||
import { FEATURE_UPDATE_LIST } from '~features/whats-new/FeatureUpdateList' | ||
|
||
const LegacySeenFlags = { | ||
[SeenFlags.LastSeenFeatureUpdateVersion]: FEATURE_UPDATE_LIST.version, | ||
} | ||
|
||
export const SeenFlagsMapVersion: { [key in SeenFlags]: number } = { | ||
...LegacySeenFlags, | ||
[SeenFlags.SettingsEmailNotification]: 0, // stub | ||
[SeenFlags.CreateBuilderMrfWorkflow]: 0, // stub | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { SeenFlags, UserDto } from '~shared/types' | ||
|
||
import { SeenFlagsMapVersion } from './constants' | ||
|
||
/** | ||
* Returns whether the user should see the feature flag. | ||
* @param user The user to check. | ||
* @param flag The flag to check. | ||
* @returns Boolean indicating whether the user should see the flag. | ||
*/ | ||
|
||
export const getShowFeatureFlagLastSeen = ( | ||
user: UserDto | undefined, | ||
flag: SeenFlags, | ||
): boolean => { | ||
const since = SeenFlagsMapVersion[flag] | ||
const flagValue = user?.flags?.[flag] | ||
if (flagValue == null) { | ||
// If the flag is not set, failover as user has seen the flag. | ||
return true | ||
} | ||
|
||
return flagValue < since | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.