Store and set edit keys
This stores and sets the edit keys on page load and after party create
This commit is contained in:
parent
cd28629389
commit
ce3d0d73a2
1 changed files with 17 additions and 9 deletions
|
|
@ -73,7 +73,11 @@ const Party = (props: Props) => {
|
|||
} else {
|
||||
// Not authenticated
|
||||
if (!props.team.user && accountData.userId === props.team.local_id) {
|
||||
// Set editable
|
||||
editable = true
|
||||
|
||||
// Also set edit key header
|
||||
setEditKey(props.team.id, props.team.user)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -103,14 +107,6 @@ const Party = (props: Props) => {
|
|||
else updateParty(details)
|
||||
}
|
||||
|
||||
function localId() {
|
||||
const cookie = accountCookie()
|
||||
const parsed = JSON.parse(cookie as string)
|
||||
if (parsed && !parsed.token) {
|
||||
return { local_id: parsed.userId }
|
||||
} else return {}
|
||||
}
|
||||
|
||||
function formatDetailsObject(details: DetailsObject) {
|
||||
const payload: { [key: string]: any } = {}
|
||||
|
||||
|
|
@ -205,7 +201,10 @@ const Party = (props: Props) => {
|
|||
appState.party.detailsVisible = false
|
||||
|
||||
// Store the edit key in local storage
|
||||
if (team.edit_key) storeEditKey(team.id, team.edit_key)
|
||||
if (team.edit_key) {
|
||||
storeEditKey(team.id, team.edit_key)
|
||||
setEditKey(team.id, team.user)
|
||||
}
|
||||
|
||||
// Populate state
|
||||
storeCharacters(team.characters)
|
||||
|
|
@ -289,6 +288,15 @@ const Party = (props: Props) => {
|
|||
}
|
||||
}
|
||||
|
||||
// Methods: Unauth validation
|
||||
function localId() {
|
||||
const cookie = accountCookie()
|
||||
const parsed = JSON.parse(cookie as string)
|
||||
if (parsed && !parsed.token) {
|
||||
return { local_id: parsed.userId }
|
||||
} else return {}
|
||||
}
|
||||
|
||||
// Render: JSX components
|
||||
const navigation = (
|
||||
<PartySegmentedControl
|
||||
|
|
|
|||
Loading…
Reference in a new issue