diff options
| author | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
|---|---|---|
| committer | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
| commit | bce557cc2dc767628bed6aac87301a1be7c5431b (patch) | |
| tree | b51a051228d01fe3306cd7626d4a96768aadb944 /shared/components/src/utils/should-show-navigation-item.ts | |
init commit
Diffstat (limited to 'shared/components/src/utils/should-show-navigation-item.ts')
| -rw-r--r-- | shared/components/src/utils/should-show-navigation-item.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/shared/components/src/utils/should-show-navigation-item.ts b/shared/components/src/utils/should-show-navigation-item.ts new file mode 100644 index 0000000..194628a --- /dev/null +++ b/shared/components/src/utils/should-show-navigation-item.ts @@ -0,0 +1,25 @@ +export function shouldShowNavigationItem( + visibilityPreferencesKey: string | null, + isEditing: boolean, + data: Record<string, boolean> | null, + itemVisibilityPreferenceKey: string, +): boolean { + // If there are no visibility preferences, + // the item should always be shown. + if (!visibilityPreferencesKey) { + return true; + } + + // If the visibility preference of an item + // is in an editing state, it should be shown. + if (isEditing) { + return true; + } + + // Show the item if the visibility preference is to show it. + if (data && data[itemVisibilityPreferenceKey]) { + return true; + } + + return false; +} |
