@@ -16,18 +16,13 @@ type t =
1616 | WelcomeShown
1717 | Completed
1818
19- @val @scope ("localStorage" ) external getItem : string => Nullable .t <string > = "getItem"
20- @val @scope ("localStorage" ) external setItem : (string , string ) => unit = "setItem"
21- @val @scope ("localStorage" ) external localStorageKey : (int ) => Nullable .t <string > = "key"
22- @val @scope ("localStorage" ) external localStorageLength : int = "length"
23-
2419// Check whether any other frontman:* localStorage key exists, indicating a returning user
2520let hasExistingFrontmanData = (): bool => {
2621 try {
27- let len = localStorageLength
22+ let len = FrontmanBindings . LocalStorage . length
2823 let found = ref (false )
2924 for i in 0 to len - 1 {
30- switch localStorageKey (i )-> Nullable .toOption {
25+ switch FrontmanBindings . LocalStorage . key (i )-> Nullable .toOption {
3126 | Some (k ) =>
3227 switch k -> String .startsWith ("frontman:" ) && k !== storageKey {
3328 | true => found := true
@@ -44,15 +39,15 @@ let hasExistingFrontmanData = (): bool => {
4439
4540let get = (): t => {
4641 try {
47- switch getItem (storageKey )-> Nullable .toOption {
42+ switch FrontmanBindings . LocalStorage . getItem (storageKey )-> Nullable .toOption {
4843 | Some ("welcome_shown" ) => WelcomeShown
4944 | Some ("completed" ) => Completed
5045 | Some (_ ) | None =>
5146 // No FTUE key — check if user is truly new or an existing user who predates FTUE
5247 switch hasExistingFrontmanData () {
5348 | true =>
5449 // Auto-migrate existing user: write Completed so this check only runs once
55- setItem (storageKey , "completed" )
50+ FrontmanBindings . LocalStorage . setItem (storageKey , "completed" )
5651 Completed
5752 | false => New
5853 }
@@ -63,9 +58,9 @@ let get = (): t => {
6358}
6459
6560let setWelcomeShown = () => {
66- setItem (storageKey , "welcome_shown" )
61+ FrontmanBindings . LocalStorage . setItem (storageKey , "welcome_shown" )
6762}
6863
6964let setCompleted = () => {
70- setItem (storageKey , "completed" )
65+ FrontmanBindings . LocalStorage . setItem (storageKey , "completed" )
7166}
0 commit comments