Skip to content

Commit

Permalink
Bugfixes from feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
corrideat committed Jan 14, 2025
1 parent fd9c99f commit 4803eb8
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 47 deletions.
35 changes: 1 addition & 34 deletions frontend/controller/actions/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ import {
JOINED_GROUP,
JOINED_CHATROOM,
LEFT_GROUP,
LOGOUT,
OPEN_MODAL,
REPLACE_MODAL
LOGOUT
} from '@utils/events.js'
import { imageUpload } from '@utils/image.js'
import { GIMessage } from '~/shared/domains/chelonia/GIMessage.js'
Expand Down Expand Up @@ -945,37 +943,6 @@ export default (sbp('sbp/selectors/register', {
})
}
}),
'gi.actions/group/displayMincomeChangedPrompt': async function ({ data }: GIActionParams) {
const { withGroupCurrency } = sbp('state/vuex/getters')
const promptOptions = data.increased
? {
heading: L('Mincome changed'),
question: L('Do you make at least {amount} per month?', { amount: withGroupCurrency(data.amount) }),
primaryButton: data.memberType === 'pledging' ? L('No') : L('Yes'),
secondaryButton: data.memberType === 'pledging' ? L('Yes') : L('No')
}
: {
heading: L('Automatically switched to pledging {zero}', { zero: withGroupCurrency(0) }),
question: L('You now make more than the mincome. Would you like to increase your pledge?'),
primaryButton: L('Yes'),
secondaryButton: L('No')
}

const primaryButtonSelected = await sbp('gi.ui/prompt', promptOptions)
if (primaryButtonSelected) {
// NOTE: emtting 'REPLACE_MODAL' instead of 'OPEN_MODAL' here because 'Prompt' modal is open at this point (by 'gi.ui/prompt' action above).
sbp('okTurtles.events/emit', REPLACE_MODAL, 'IncomeDetails')
}
},
'gi.actions/group/checkAndSeeProposal': function ({ data }: GIActionParams) {
const openProposalIds = Object.keys(sbp('state/vuex/getters').currentGroupState.proposals || {})

if (openProposalIds.includes(data.proposalHash)) {
sbp('controller/router').push({ path: '/dashboard#proposals' })
} else {
sbp('okTurtles.events/emit', OPEN_MODAL, 'PropositionsAllModal', { targetProposal: data.proposalHash })
}
},
'gi.actions/group/fixAnyoneCanJoinLink': function ({ contractID }) {
// Queue ensures that the update happens as atomically as possible
return sbp('chelonia/queueInvocation', `${contractID}-FIX-ANYONE-CAN-JOIN`, async () => {
Expand Down
43 changes: 43 additions & 0 deletions frontend/controller/app/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,48 @@ export default (sbp('sbp/selectors/register', {
} else {
sbp('okTurtles.events/emit', OPEN_MODAL, 'AddMembers')
}
},
'gi.app/group/checkAndSeeProposal': function ({ contractID, data }: GIActionParams) {
const rootGetters = sbp('state/vuex/getters')
const rootState = sbp('state/vuex/state')
if (rootState.currentGroupId !== contractID) {
sbp('state/vuex/commit', 'setCurrentGroupId', { contractID })
}

const openProposalIds = Object.keys(rootGetters.currentGroupState.proposals || {})

if (openProposalIds.includes(data.proposalHash)) {
sbp('controller/router').push({ path: '/dashboard#proposals' })
} else {
sbp('okTurtles.events/emit', OPEN_MODAL, 'PropositionsAllModal', { targetProposal: data.proposalHash })
}
},
'gi.app/group/displayMincomeChangedPrompt': async function ({ contractID, data }: GIActionParams) {
const rootGetters = sbp('state/vuex/getters')
const rootState = sbp('state/vuex/state')
if (rootState.currentGroupId !== contractID) {
sbp('state/vuex/commit', 'setCurrentGroupId', { contractID })
}

const { withGroupCurrency } = rootGetters
const promptOptions = data.increased
? {
heading: L('Mincome changed'),
question: L('Do you make at least {amount} per month?', { amount: withGroupCurrency(data.amount) }),
primaryButton: data.memberType === 'pledging' ? L('No') : L('Yes'),
secondaryButton: data.memberType === 'pledging' ? L('Yes') : L('No')
}
: {
heading: L('Automatically switched to pledging {zero}', { zero: withGroupCurrency(0) }),
question: L('You now make more than the mincome. Would you like to increase your pledge?'),
primaryButton: L('Yes'),
secondaryButton: L('No')
}

const primaryButtonSelected = await sbp('gi.ui/prompt', promptOptions)
if (primaryButtonSelected) {
// NOTE: emtting 'REPLACE_MODAL' instead of 'OPEN_MODAL' here because 'Prompt' modal is open at this point (by 'gi.ui/prompt' action above).
sbp('okTurtles.events/emit', REPLACE_MODAL, 'IncomeDetails')
}
}
}): string[])
9 changes: 0 additions & 9 deletions frontend/model/contracts/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -1582,15 +1582,6 @@ sbp('chelonia/defineContract', {
pledgeAmount: 0
}
})

await sbp('gi.actions/group/displayMincomeChangedPrompt', {
contractID,
data: {
amount: toAmount,
memberType,
increased: mincomeIncreased
}
})
}

sbp('gi.notifications/emit', 'MINCOME_CHANGED', {
Expand Down
2 changes: 2 additions & 0 deletions frontend/model/notifications/messageReceivePostEffect.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ async function messageReceivePostEffect ({
? rootGetters.userDisplayNameFromID(identityContractID)
: partners.map(cID => rootGetters.userDisplayNameFromID(cID)).join(', ')
icon = rootGetters.ourContactProfilesById[lastJoinedPartner]?.picture
} else {
icon = rootGetters.ourContactProfilesById[memberID]?.picture
}
const path = `/group-chat/${contractID}`

Expand Down
8 changes: 4 additions & 4 deletions frontend/model/notifications/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export default ({
level: 'info',
subtype: data.subtype,
scope: 'group',
sbpInvocation: ['gi.actions/group/checkAndSeeProposal', {
sbpInvocation: ['gi.app/group/checkAndSeeProposal', {
contractID: data.groupID,
data: { proposalHash: data.proposalHash }
}]
Expand Down Expand Up @@ -297,7 +297,7 @@ export default ({
icon: 'exclamation-triangle',
scope: 'group',
data: { proposalId: data.proposalId },
sbpInvocation: ['gi.actions/group/checkAndSeeProposal', {
sbpInvocation: ['gi.app/group/checkAndSeeProposal', {
contractID: data.groupID,
data: { proposalHash: data.proposalId }
}]
Expand Down Expand Up @@ -378,7 +378,7 @@ export default ({
icon: statusMap[status].icon,
level: statusMap[status].level,
scope: 'group',
sbpInvocation: ['gi.actions/group/checkAndSeeProposal', {
sbpInvocation: ['gi.app/group/checkAndSeeProposal', {
contractID: data.groupID,
data: { proposalHash: data.proposalHash }
}]
Expand Down Expand Up @@ -438,7 +438,7 @@ export default ({
icon: 'dollar-sign',
level: 'info',
scope: 'group',
sbpInvocation: ['gi.actions/group/displayMincomeChangedPrompt', {
sbpInvocation: ['gi.app/group/displayMincomeChangedPrompt', {
contractID: data.groupID,
data: {
amount: data.to,
Expand Down

0 comments on commit 4803eb8

Please sign in to comment.