-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial progress towards #380
- Loading branch information
Showing
9 changed files
with
124 additions
and
239 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,62 @@ | ||
/* eslint-disable no-console */ | ||
|
||
/** | ||
Manage user state | ||
*/ | ||
import { | ||
FIRST_TIME_USER_VISIT, | ||
RETURNING_USER_VISIT | ||
} from './mutation-types.js' | ||
import { | ||
USER_VISIT | ||
} from './action-types.js' | ||
const STORAGE_KEY = 'ambianic-user-settings' | ||
|
||
const state = { | ||
/** | ||
Is this a first time user of the system? | ||
*/ | ||
isReturningUser: window.localStorage.getItem(`${STORAGE_KEY}.isReturningUser`) | ||
} | ||
|
||
const mutations = { | ||
[FIRST_TIME_USER_VISIT] (state) { | ||
state.isReturningUser = true | ||
window.localStorage.setItem(`${STORAGE_KEY}.isReturningUser`, true) | ||
}, | ||
[RETURNING_USER_VISIT] (state) { | ||
} | ||
} | ||
|
||
const actions = { | ||
/** | ||
* Update user state according to user visit of the app | ||
*/ | ||
async [USER_VISIT] ({ state, commit }) { | ||
console.debug('user visiting app') | ||
if (state.isReturningUser) { | ||
commit(RETURNING_USER_VISIT) | ||
} else { | ||
commit(FIRST_TIME_USER_VISIT) | ||
} | ||
} | ||
} | ||
|
||
const getters = { | ||
isFirstTimeUser: state => { | ||
const isReturningUser = state.isReturningUser | ||
console.debug({ isReturningUser }) | ||
const isFirstTimeUser = !isReturningUser | ||
console.debug({ isFirstTimeUser }) | ||
return isFirstTimeUser | ||
} | ||
} | ||
|
||
const userStoreModule = { | ||
state, | ||
getters, | ||
mutations, | ||
actions | ||
} | ||
|
||
export default userStoreModule |
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
Oops, something went wrong.