Skip to content

Commit

Permalink
try window.onNuxtReady with the persisted store
Browse files Browse the repository at this point in the history
  • Loading branch information
Recidvst committed Jun 22, 2024
1 parent 54706f3 commit ef52edc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
20 changes: 0 additions & 20 deletions assets/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,6 @@ export function isObject(o) {
return !!o && o.constructor === Object && Object.keys(o).length !== 0 && typeof o !== 'undefined';
}

// is email?
export function validateEmail(email) {
const re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
return re.test(email);
}

// AUTH
// Set JWT token in localStorage
export function setJWTstorage(key, value) {
localStorage.setItem(key, value);
}
// Get JWT token from localStorage
export function getJWTstorage(key) {
return localStorage.getItem(key);
}
// Delete JTW token from localStorage
export function deleteJWTstorage(key) {
localStorage.removeItem(key);
}

// copy to clipboard
export function copyToClipboard(str) {
const el = document.createElement('textarea');
Expand Down
10 changes: 6 additions & 4 deletions plugins/persistedState.client.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import createPersistedState from 'vuex-persistedstate';

export default ({ store }) => {
createPersistedState({
key: 'vuex',
paths: ['loadState', 'snippetsArray', 'snippetsAmount', 'contentType', 'bookType', 'token'],
})(store);
window.onNuxtReady(() => {
createPersistedState({
key: 'vuex',
paths: ['loadState', 'snippetsAmount', 'contentType', 'bookType'],
})(store);
})
};

0 comments on commit ef52edc

Please sign in to comment.