-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support "don't show again" announcement
- Loading branch information
Showing
10 changed files
with
59 additions
and
7 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
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,25 @@ | ||
import { namespace } from '../../package.json'; | ||
import { ANNOUNCEMENT_DONT_SHOW_AGAIN_QUESTION } from './../constants/texts'; | ||
import * as cookies from './cookies'; | ||
|
||
const prefix = `${namespace}-announcement-read-receipt`; | ||
|
||
const getCookieName = (id: string) => { | ||
const name = `${prefix}-${id}`; | ||
return name; | ||
}; | ||
|
||
export const hasRead = (id: string) => { | ||
const name = getCookieName(id); | ||
const value = cookies.get<boolean>(name); | ||
return value || false; | ||
}; | ||
|
||
export const dontShowAgain = (id: string, expires: number) => { | ||
const name = getCookieName(id); | ||
cookies.set(name, true, { expires }); | ||
}; | ||
|
||
export const promptDontShowAgain = () => { | ||
return window.confirm(ANNOUNCEMENT_DONT_SHOW_AGAIN_QUESTION); | ||
}; |
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,15 @@ | ||
import Cookies, { CookieAttributes } from 'js-cookie'; | ||
|
||
export const get = <T> (name: string): T | undefined => { | ||
const json = Cookies.get(name); | ||
return json && JSON.parse(json); | ||
}; | ||
|
||
export const set = <T> (name: string, value: T, options?: CookieAttributes) => { | ||
const _options = { | ||
expires: 7, | ||
...options | ||
}; | ||
const json = JSON.stringify(value); | ||
return Cookies.set(name, json, _options); | ||
}; |
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 |
---|---|---|
|
@@ -3420,6 +3420,11 @@ js-cookie@^2.2.1: | |
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8" | ||
integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ== | ||
|
||
js-cookie@^3.0.1: | ||
version "3.0.1" | ||
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-3.0.1.tgz#9e39b4c6c2f56563708d7d31f6f5f21873a92414" | ||
integrity sha512-+0rgsUXZu4ncpPxRL+lNEptWMOWl9etvPHc/koSRp6MPwpRYAhmk0dUG00J4bxVV3r9uUzfo24wW0knS07SKSw== | ||
|
||
[email protected]: | ||
version "0.8.0" | ||
resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" | ||
|