-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store inbox tab settings in local storage (#136)
- Loading branch information
1 parent
152f74d
commit f602398
Showing
2 changed files
with
52 additions
and
3 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
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,32 @@ | ||
import { storeKv } from './kv-storage'; | ||
|
||
const inboxNumber = async (key: string, value?: number) => { | ||
const loaded = await storeKv( | ||
key, | ||
value === undefined ? undefined : String(value)); | ||
|
||
if (loaded === undefined || loaded === null) { | ||
return 0; | ||
} | ||
|
||
const loadedInt = parseInt(loaded); | ||
|
||
if (isNaN(loadedInt)) { | ||
return 0; | ||
} | ||
|
||
return loadedInt; | ||
}; | ||
|
||
const inboxOrder = async (value?: number) => { | ||
return await inboxNumber('inbox_order', value); | ||
}; | ||
|
||
const inboxSection = async (value?: number) => { | ||
return await inboxNumber('inbox_section', value); | ||
}; | ||
|
||
export { | ||
inboxOrder, | ||
inboxSection, | ||
} |