Skip to content

Commit 9280f32

Browse files
committed
Implement featuer flags todos
1 parent 0e5c14e commit 9280f32

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/lib/flags.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { env } from '$env/dynamic/public';
2+
import { get } from 'svelte/store';
3+
import { user } from '$lib/stores/user';
4+
import { organization } from '$lib/stores/organization';
25

36
export const PUBLIC_CONSOLE_FEATURE_FLAGS = env.PUBLIC_CONSOLE_FEATURE_FLAGS ?? '';
47

@@ -9,9 +12,19 @@ function setupFlag(name: string, _description: string) {
912
return true;
1013
}
1114

12-
// TODO: Check team prefs
15+
const userInstance = get(user);
16+
const userPrefs = userInstance?.prefs ?? {};
17+
const userFlag = userPrefs[`flags-${name}`] ?? null;
18+
if (userFlag) {
19+
return true;
20+
}
1321

14-
// TODO: Check user prefs
22+
const organizationInstance = get(organization);
23+
const organizationPrefs = organizationInstance?.prefs ?? {};
24+
const organizationFlag = organizationPrefs[`flags-${name}`] ?? null;
25+
if (organizationFlag) {
26+
return true;
27+
}
1528

1629
return false;
1730
}

0 commit comments

Comments
 (0)