Skip to content

Commit

Permalink
Merge branch 'master' into modify-design
Browse files Browse the repository at this point in the history
  • Loading branch information
duyoji committed Dec 26, 2017
2 parents 720f4a9 + 89ab6af commit 3d33717
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utils/localStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ const buildKey = (key) => {
};

const setUserName = (userName) => {
const key = buildKey(KEY_TYPES.USER_NAME);
window.localStorage.setItem(key, userName);
// https://stackoverflow.com/questions/21159301/quotaexceedederror-dom-exception-22-an-attempt-was-made-to-add-something-to-st
// When user is in private mode, Just ignore.
// It only setItem, so we do not need to wrap `getItem` with `try/catch`.
try {
const key = buildKey(KEY_TYPES.USER_NAME);
window.localStorage.setItem(key, userName);
} catch (error) {
// Error handling
}
};

const getUserName = () => {
Expand Down

0 comments on commit 3d33717

Please sign in to comment.