Skip to content

Commit

Permalink
Merge branch 'master' into releases
Browse files Browse the repository at this point in the history
  • Loading branch information
taoeffect committed Jun 11, 2024
2 parents 000b711 + e7ea0c3 commit 910c581
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 14 deletions.
5 changes: 2 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
9 changes: 7 additions & 2 deletions frontend/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 })
}
},
Expand Down
40 changes: 34 additions & 6 deletions frontend/views/pages/Join.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand All @@ -68,13 +74,15 @@ export default ({
LoginForm,
SignupForm,
Avatar,
SvgBrokenLink
SvgBrokenLink,
SvgCreateGroup
},
data () {
return {
ephemeral: {
pageStatus: 'LOADING',
invitation: {},
groupInfo: {},
query: null
}
}
Expand All @@ -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(', ')}`)
}
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -167,14 +187,21 @@ 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')
const secret = this.ephemeral.hash.get('secret')
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)
Expand Down Expand Up @@ -263,7 +290,8 @@ export default ({
text-align: center;
}
.c-broken {
.c-broken,
.c-joined {
margin-top: 20vh;
text-align: center;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "group-income",
"version": "0.5.0",
"version": "0.5.1",
"contractsVersion": "0.5.0",
"private": true,
"description": "",
Expand Down

0 comments on commit 910c581

Please sign in to comment.