From b266d4cf72855d7526caef5c4bd75ad76111cfe4 Mon Sep 17 00:00:00 2001 From: Sebin Song Date: Wed, 12 Jun 2024 03:31:40 +1200 Subject: [PATCH 1/2] #2051 - Improve the UI for already joined group (#2055) * add already-a-member screen to Join.vue * display the groupname to the already-joined screen --- frontend/views/pages/Join.vue | 40 +++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/frontend/views/pages/Join.vue b/frontend/views/pages/Join.vue index ca8d484a57..43a9281e0f 100644 --- a/frontend/views/pages/Join.vue +++ b/frontend/views/pages/Join.vue @@ -31,6 +31,11 @@ div |   i18n.link(tag='button' @click='pageStatus = "SIGNING"') Create an account + .c-joined(v-else-if='isStatus("JOINED")') + svg-create-group.c-svg + i18n.is-title-1(tag='h1' data-test='pageTitle' :args='{ groupName: ephemeral.groupInfo.name }') You are already a member of '{groupName}' + i18n.has-text-1(tag='p' data-test='helperText') You cannot join already joined group. + i18n.c-goHome(tag='button' @click='goToDashboard(ephemeral.groupInfo.id)') Go to dashboard .c-broken(v-else-if='isStatus("INVALID")') svg-broken-link.c-svg i18n.is-title-1(tag='h1' data-test='pageTitle' :args='LTags()') Oh no! {br_}This invite is not valid @@ -51,6 +56,7 @@ import LoginForm from '@containers/access/LoginForm.vue' import SignupForm from '@containers/access/SignupForm.vue' import sbp from '@sbp/sbp' import SvgBrokenLink from '@svgs/broken-link.svg' +import SvgCreateGroup from '@svgs/create-group.svg' import { LOGIN } from '@utils/events.js' import { mapGetters, mapState } from 'vuex' import { INVITE_STATUS } from '~/shared/domains/chelonia/constants.js' @@ -68,13 +74,15 @@ export default ({ LoginForm, SignupForm, Avatar, - SvgBrokenLink + SvgBrokenLink, + SvgCreateGroup }, data () { return { ephemeral: { pageStatus: 'LOADING', invitation: {}, + groupInfo: {}, query: null } } @@ -85,7 +93,7 @@ export default ({ pageStatus: { get () { return this.ephemeral.pageStatus }, set (status) { - const possibleStatus = ['LOADING', 'SIGNING', 'LOGGING', 'INVALID', 'EXPIRED'] + const possibleStatus = ['LOADING', 'SIGNING', 'LOGGING', 'INVALID', 'EXPIRED', 'JOINED'] if (!possibleStatus.includes(status)) { throw new Error(`Bad status: ${status}. Use one of the following: ${possibleStatus.join(', ')}`) } @@ -134,8 +142,20 @@ export default ({ return } if (this.ourIdentityContractId) { - if (this.currentGroupId && [PROFILE_STATUS.ACTIVE, PROFILE_STATUS.PENDING].includes(this.$store.state.contracts[this.ephemeral.hash.groupId]?.profiles?.[this.ourIdentityContractId])) { - this.$router.push({ path: '/dashboard' }) + const myGroupIds = Object.keys(this.$store.state[this.ourIdentityContractId]?.groups || {}) + const targetGroupId = this.ephemeral.hash?.get('groupId') || '' + const targetGroupState = this.$store.state[targetGroupId] || {} + + if (this.currentGroupId && [PROFILE_STATUS.ACTIVE, PROFILE_STATUS.PENDING].includes(targetGroupState?.profiles?.[this.ourIdentityContractId])) { + this.goToDashboard() + } else if (myGroupIds.includes(targetGroupId)) { // if the user is already part of the target group. + this.ephemeral.groupInfo = { + name: targetGroupState.settings?.groupName || '', + id: targetGroupId + } + this.pageStatus = 'JOINED' + + return } else { await this.accept() } @@ -167,6 +187,13 @@ export default ({ goHome () { this.$router.push({ path: '/' }) }, + goToDashboard (toGroupId) { + if (toGroupId && this.currentGroupId !== toGroupId) { + sbp('gi.actions/group/switch', toGroupId) + } + + this.$router.push({ path: '/dashboard' }) + }, async accept () { this.ephemeral.errorMsg = null const groupId = this.ephemeral.hash.get('groupId') @@ -174,7 +201,7 @@ export default ({ const profileStatus = this.$store.state.contracts[groupId]?.profiles?.[this.ourIdentityContractId]?.status if ([PROFILE_STATUS.ACTIVE, PROFILE_STATUS.PENDING].includes(profileStatus)) { - return this.$router.push({ path: '/dashboard' }) + return this.goToDashboard() } try { await sbp('gi.actions/group/joinWithInviteSecret', groupId, secret) @@ -263,7 +290,8 @@ export default ({ text-align: center; } -.c-broken { +.c-broken, +.c-joined { margin-top: 20vh; text-align: center; From 586e0dd8b464765a9a9c0ccebbc7a73147818ddf Mon Sep 17 00:00:00 2001 From: Greg Slepak Date: Tue, 11 Jun 2024 09:26:50 -0700 Subject: [PATCH 2/2] v0.5.1 - also update page refresh logic on new version --- Gruntfile.js | 5 ++--- frontend/main.js | 9 +++++++-- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index c610f7902d..6fe794663e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -51,10 +51,9 @@ if (!['development', 'production'].includes(NODE_ENV)) { throw new TypeError(`Invalid NODE_ENV value: ${NODE_ENV}.`) } const CONTRACTS_VERSION = packageJSON.contractsVersion -// In production, append a timestamp so that browsers will detect a new version +// In development, append a timestamp so that browsers will detect a new version // and reload whenever the live server is restarted. -// TODO: get rid of this timestamp and just bump the package version when necessary. -const GI_VERSION = packageJSON.version + (NODE_ENV === 'production' ? `@${new Date().toISOString()}` : '') +const GI_VERSION = packageJSON.version + (NODE_ENV === 'development' ? `@${new Date().toISOString()}` : '') // Make version info available to subprocesses. Object.assign(process.env, { CONTRACTS_VERSION, GI_VERSION }) diff --git a/frontend/main.js b/frontend/main.js index 6544136829..f3ca9c9cfa 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -206,7 +206,6 @@ async function startApp () { sbp('okTurtles.data/set', PUBSUB_INSTANCE, sbp('chelonia/connect', { messageHandlers: { [NOTIFICATION_TYPE.VERSION_INFO] (msg) { - const isDevelopment = process.env.NODE_ENV === 'development' const ourVersion = process.env.GI_VERSION const theirVersion = msg.data.GI_VERSION @@ -218,7 +217,13 @@ async function startApp () { // We only compare GI_VERSION in development mode so that the page auto-refreshes if `grunt dev` is re-run // This check cannot be done in production mode as it would lead to an infinite page refresh bug // when using `grunt deploy` with `grunt serve` - if (isContractVersionDiff || (isDevelopment && isGIVersionDiff)) { + console.info('VERSION_INFO received:', { + ourVersion, + theirVersion, + ourContractsVersion, + theirContractsVersion + }) + if (isContractVersionDiff || isGIVersionDiff) { sbp('okTurtles.events/emit', NOTIFICATION_TYPE.VERSION_INFO, { ...msg.data }) } }, diff --git a/package-lock.json b/package-lock.json index 9ac5013adc..48598b6f28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "group-income", - "version": "0.5.0", + "version": "0.5.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "group-income", - "version": "0.5.0", + "version": "0.5.1", "license": "AGPL-3.0", "dependencies": { "@babel/core": "7.23.7", diff --git a/package.json b/package.json index 70ad76599a..9405dabb2d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "group-income", - "version": "0.5.0", + "version": "0.5.1", "contractsVersion": "0.5.0", "private": true, "description": "",