diff --git a/frontend/controller/actions/identity.js b/frontend/controller/actions/identity.js index ee3e513579..fb4741002e 100644 --- a/frontend/controller/actions/identity.js +++ b/frontend/controller/actions/identity.js @@ -673,5 +673,6 @@ export default (sbp('sbp/selectors/register', { return sbp('okTurtles.eventQueue/queueEvent', 'ACTIONS-LOGIN', ['gi.actions/identity/_private/logout', ...params]) }, ...encryptedAction('gi.actions/identity/saveFileDeleteToken', L('Failed to save delete tokens for the attachments.')), - ...encryptedAction('gi.actions/identity/removeFileDeleteToken', L('Failed to remove delete tokens for the attachments.')) + ...encryptedAction('gi.actions/identity/removeFileDeleteToken', L('Failed to remove delete tokens for the attachments.')), + ...encryptedAction('gi.actions/identity/setGroupAttributes', L('Failed to set group attributes.')) }): string[]) diff --git a/frontend/controller/router.js b/frontend/controller/router.js index fd87d23877..3985507213 100644 --- a/frontend/controller/router.js +++ b/frontend/controller/router.js @@ -33,7 +33,14 @@ Vue.use(Router) */ const homeGuard = { guard: (to, from) => !!store.state.currentGroupId, - redirect: (to, from) => ({ path: store.getters.ourProfileActive ? '/dashboard' : '/pending-approval' }) + redirect: (to, from) => ({ + path: + // If we haven't accepted the invite OR we haven't clicked 'Awesome' on + // the welcome screen, redirect to the '/pending-approval' page + store.getters.seenWelcomeScreen + ? '/dashboard' + : '/pending-approval' + }) } const loginGuard = { diff --git a/frontend/model/contracts/identity.js b/frontend/model/contracts/identity.js index 95358ebf93..414d8c226f 100644 --- a/frontend/model/contracts/identity.js +++ b/frontend/model/contracts/identity.js @@ -2,7 +2,7 @@ import { L } from '@common/common.js' import sbp from '@sbp/sbp' -import { arrayOf, boolean, object, objectMaybeOf, objectOf, optional, string, stringMax, unionOf } from '~/frontend/model/contracts/misc/flowTyper.js' +import { arrayOf, boolean, object, objectMaybeOf, objectOf, optional, string, stringMax, unionOf, validatorFrom } from '~/frontend/model/contracts/misc/flowTyper.js' import { LEFT_GROUP } from '~/frontend/utils/events.js' import { Secret } from '~/shared/domains/chelonia/Secret.js' import { findForeignKeysByContractID, findKeyIdByName } from '~/shared/domains/chelonia/utils.js' @@ -283,8 +283,13 @@ sbp('chelonia/defineContract', { throw new Error(`Cannot leave group ${groupContractID} because the reference hash does not match the latest`) } - state.groups[groupContractID].hasLeft = true - delete state.groups[groupContractID].inviteSecret + // We only keep `hash` and `hasLeft` in the list of groups, as this + // is the only information we need for groups we're not part of. + // This has the advantage that we don't need to explicitly delete + // every new attribute that we may add in the future, but has the + // downside that, if we were to add a new attribute that's needed after + // having left, then it'd need to be added here. + state.groups[groupContractID] = { hash: reference, hasLeft: true } }, sideEffect ({ data, contractID }) { sbp('gi.contracts/identity/referenceTally', contractID, data.groupContractID, 'release') @@ -359,6 +364,26 @@ sbp('chelonia/defineContract', { delete state.fileDeleteTokens[manifestCid] } } + }, + 'gi.contracts/identity/setGroupAttributes': { + validate: objectOf({ + groupContractID: string, + attributes: objectMaybeOf({ + seenWelcomeScreen: validatorFrom((v) => v === true) + }) + }), + process ({ data }, { state }) { + const { groupContractID, attributes } = data + if (!has(state.groups, groupContractID) || state.groups[groupContractID].hasLeft) { + throw new Error('Can\'t set attributes of groups you\'re not a member of') + } + if (attributes.seenWelcomeScreen) { + if (state.groups[groupContractID].seenWelcomeScreen) { + throw new Error('seenWelcomeScreen already set') + } + state.groups[groupContractID].seenWelcomeScreen = attributes.seenWelcomeScreen + } + } } }, methods: { diff --git a/frontend/views/components/GroupWelcome.vue b/frontend/views/components/GroupWelcome.vue index ebae171d0a..21e6f52770 100644 --- a/frontend/views/components/GroupWelcome.vue +++ b/frontend/views/components/GroupWelcome.vue @@ -26,7 +26,8 @@