Store edit key in localStorage on create response

This commit is contained in:
Justin Edmund 2023-01-31 01:24:42 -08:00
parent 6b83f81eb6
commit c0df78758b
3 changed files with 20 additions and 1 deletions

View file

@ -147,7 +147,7 @@ const Party = (props: Props) => {
} }
// Methods: Storing party data // Methods: Storing party data
const storeParty = function (team: Party) { const storeParty = function (team: any) {
// Store the important party and state-keeping values in global state // Store the important party and state-keeping values in global state
appState.party.name = team.name appState.party.name = team.name
appState.party.description = team.description appState.party.description = team.description
@ -170,6 +170,9 @@ const Party = (props: Props) => {
appState.party.detailsVisible = false appState.party.detailsVisible = false
// Store the edit key in local storage
if (team.edit_key) storeEditKey(team.id, team.edit_key)
// Populate state // Populate state
storeCharacters(team.characters) storeCharacters(team.characters)
storeWeapons(team.weapons) storeWeapons(team.weapons)
@ -191,6 +194,10 @@ const Party = (props: Props) => {
return team return team
} }
const storeEditKey = (id: string, key: string) => {
ls(id, key)
}
const storeCharacters = (list: Array<GridCharacter>) => { const storeCharacters = (list: Array<GridCharacter>) => {
list.forEach((object: GridCharacter) => { list.forEach((object: GridCharacter) => {
if (object.position != null) if (object.position != null)

11
package-lock.json generated
View file

@ -26,6 +26,7 @@
"i18next": "^21.6.13", "i18next": "^21.6.13",
"i18next-browser-languagedetector": "^6.1.3", "i18next-browser-languagedetector": "^6.1.3",
"i18next-http-backend": "^1.3.2", "i18next-http-backend": "^1.3.2",
"local-storage": "^2.0.0",
"lodash.clonedeep": "^4.5.0", "lodash.clonedeep": "^4.5.0",
"lodash.debounce": "^4.0.8", "lodash.debounce": "^4.0.8",
"meyer-reset-scss": "^2.0.4", "meyer-reset-scss": "^2.0.4",
@ -5655,6 +5656,11 @@
"json5": "lib/cli.js" "json5": "lib/cli.js"
} }
}, },
"node_modules/local-storage": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/local-storage/-/local-storage-2.0.0.tgz",
"integrity": "sha512-/0sRoeijw7yr/igbVVygDuq6dlYCmtsuTmmpnweVlVtl/s10pf5BCq8LWBxW/AMyFJ3MhMUuggMZiYlx6qr9tw=="
},
"node_modules/lodash.clonedeep": { "node_modules/lodash.clonedeep": {
"version": "4.5.0", "version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
@ -11398,6 +11404,11 @@
} }
} }
}, },
"local-storage": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/local-storage/-/local-storage-2.0.0.tgz",
"integrity": "sha512-/0sRoeijw7yr/igbVVygDuq6dlYCmtsuTmmpnweVlVtl/s10pf5BCq8LWBxW/AMyFJ3MhMUuggMZiYlx6qr9tw=="
},
"lodash.clonedeep": { "lodash.clonedeep": {
"version": "4.5.0", "version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",

View file

@ -31,6 +31,7 @@
"i18next": "^21.6.13", "i18next": "^21.6.13",
"i18next-browser-languagedetector": "^6.1.3", "i18next-browser-languagedetector": "^6.1.3",
"i18next-http-backend": "^1.3.2", "i18next-http-backend": "^1.3.2",
"local-storage": "^2.0.0",
"lodash.clonedeep": "^4.5.0", "lodash.clonedeep": "^4.5.0",
"lodash.debounce": "^4.0.8", "lodash.debounce": "^4.0.8",
"meyer-reset-scss": "^2.0.4", "meyer-reset-scss": "^2.0.4",