From b0ab51e6b7b4e0f26427ef09e21f162801f64ade Mon Sep 17 00:00:00 2001 From: SebinSong Date: Thu, 5 Dec 2024 09:59:52 +1300 Subject: [PATCH 1/7] update template for NEW_PROPOSAL --- frontend/model/contracts/group.js | 1 + frontend/model/notifications/templates.js | 37 ++++++++++++++++------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/frontend/model/contracts/group.js b/frontend/model/contracts/group.js index 8c6d7a21f3..e1134e036d 100644 --- a/frontend/model/contracts/group.js +++ b/frontend/model/contracts/group.js @@ -702,6 +702,7 @@ sbp('chelonia/defineContract', { createdDate: meta.createdDate, groupID: contractID, creatorID: innerSigningContractID, + isCreator: innerSigningContractID === loggedIn.identityContractID, subtype: typeToSubTypeMap[data.proposalType] }) } diff --git a/frontend/model/notifications/templates.js b/frontend/model/notifications/templates.js index e878f21b6b..2f31e1adc5 100644 --- a/frontend/model/notifications/templates.js +++ b/frontend/model/notifications/templates.js @@ -144,18 +144,33 @@ export default ({ scope: 'group' } }, - NEW_PROPOSAL (data: { groupID: string, creatorID: string, subtype: NewProposalType }) { - const args = { - name: `${CHATROOM_MEMBER_MENTION_SPECIAL_CHAR}${data.creatorID}`, - ...LTags('strong') - } + NEW_PROPOSAL (data: { groupID: string, creatorID: string, isCreator: boolean, subtype: NewProposalType }) { + const args = data.isCreator + ? null + : { + name: `${CHATROOM_MEMBER_MENTION_SPECIAL_CHAR}${data.creatorID}`, + ...LTags('strong') + } + const bodyTemplateMap = { - ADD_MEMBER: L('{strong_}{name}{_strong} proposed to add a member to the group. Vote now!', args), - CHANGE_MINCOME: L('{strong_}{name}{_strong} proposed to change the group mincome. Vote now!', args), - CHANGE_DISTRIBUTION_DATE: L('{strong_}{name}{_strong} proposed to change the group distribution date. Vote now!', args), - CHANGE_VOTING_RULE: L('{strong_}{name}{_strong} proposed to change the group voting system. Vote now!', args), - REMOVE_MEMBER: L('{strong_}{name}{_strong} proposed to remove a member from the group. Vote now!', args), - GENERIC: L('{strong_}{name}{_strong} created a proposal. Vote now!', args) + ADD_MEMBER: data.isCreator + ? L('you proposed to add a member to the group.') + : L('{strong_}{name}{_strong} proposed to add a member to the group. Vote now!', args), + CHANGE_MINCOME: data.isCreator + ? L('you proposed to change the group mincome.') + : L('{strong_}{name}{_strong} proposed to change the group mincome. Vote now!', args), + CHANGE_DISTRIBUTION_DATE: data.isCreator + ? L('you proposed to change the group distribution date.') + : L('{strong_}{name}{_strong} proposed to change the group distribution date. Vote now!', args), + CHANGE_VOTING_RULE: data.isCreator + ? L('you proposed to change the group voting system.') + : L('{strong_}{name}{_strong} proposed to change the group voting system. Vote now!', args), + REMOVE_MEMBER: data.isCreator + ? L('you proposed to remove a member from the group.') + : L('{strong_}{name}{_strong} proposed to remove a member from the group. Vote now!', args), + GENERIC: data.isCreator + ? L('you created a proposal.') + : L('{strong_}{name}{_strong} created a proposal. Vote now!', args) } const iconMap = { From f0e178cd6800ca4a606e3065c9783bc54cfcbfa1 Mon Sep 17 00:00:00 2001 From: SebinSong Date: Thu, 5 Dec 2024 10:14:50 +1300 Subject: [PATCH 2/7] update notification msg template for PROPOSAL_CLOSED --- frontend/model/contracts/group.js | 7 +++++- frontend/model/notifications/templates.js | 29 +++++++++++++---------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/frontend/model/contracts/group.js b/frontend/model/contracts/group.js index e1134e036d..80239cd02e 100644 --- a/frontend/model/contracts/group.js +++ b/frontend/model/contracts/group.js @@ -1549,7 +1549,12 @@ sbp('chelonia/defineContract', { 'gi.contracts/group/makeNotificationWhenProposalClosed': function (state, contractID, meta, height, proposal) { const { loggedIn } = sbp('state/vuex/state') if (isActionNewerThanUserJoinedDate(height, state.profiles[loggedIn.identityContractID])) { - sbp('gi.notifications/emit', 'PROPOSAL_CLOSED', { createdDate: meta.createdDate, groupID: contractID, proposal }) + sbp('gi.notifications/emit', 'PROPOSAL_CLOSED', { + createdDate: meta.createdDate, + groupID: contractID, + isCreator: loggedIn.identityContractID === proposal.creatorID, + proposal + }) } }, 'gi.contracts/group/sendMincomeChangedNotification': async function (contractID, meta, data, height, innerSigningContractID) { diff --git a/frontend/model/notifications/templates.js b/frontend/model/notifications/templates.js index 2f31e1adc5..b15d1a6704 100644 --- a/frontend/model/notifications/templates.js +++ b/frontend/model/notifications/templates.js @@ -219,7 +219,7 @@ export default ({ data: { proposalId: data.proposalId } } }, - PROPOSAL_CLOSED (data: { proposal: Object }) { + PROPOSAL_CLOSED (data: { proposal: Object, isCreator: boolean }) { const { creatorID, status, type, options } = getProposalDetails(data.proposal) const statusMap = { @@ -232,7 +232,7 @@ export default ({ ...options, ...LTags('strong'), closedWith: statusMap[status].closedWith, - name: `${CHATROOM_MEMBER_MENTION_SPECIAL_CHAR}${creatorID}` + name: !data.isCreator ? `${CHATROOM_MEMBER_MENTION_SPECIAL_CHAR}${creatorID}` : '' } if (options.memberID) { @@ -242,16 +242,21 @@ export default ({ } const bodyTemplateMap = { - [PROPOSAL_INVITE_MEMBER]: - L("{strong_}{name}'s{_strong} proposal to add {member} to the group was {strong_}{closedWith}{_strong}.", args), - [PROPOSAL_REMOVE_MEMBER]: - L("{strong_}{name}'s{_strong} proposal to remove {member} from the group was {strong_}{closedWith}{_strong}.", args), - [PROPOSAL_GROUP_SETTING_CHANGE]: - L("{strong_}{name}'s{_strong} proposal to change group's {setting} to {value} was {strong_}{closedWith}{_strong}.", args), - [PROPOSAL_PROPOSAL_SETTING_CHANGE]: - L("{strong_}{name}'s{_strong} proposal to change group's {setting} was {strong_}{closedWith}{_strong}.", args), - [PROPOSAL_GENERIC]: - L('{strong_}{name}\'s{_strong} proposal "{title}" was {strong_}{closedWith}{_strong}.', args) + [PROPOSAL_INVITE_MEMBER]: data.isCreator + ? L('your proposal to add {member} to the group was {strong_}{closedWith}{_strong}.', args) + : L("{strong_}{name}'s{_strong} proposal to add {member} to the group was {strong_}{closedWith}{_strong}.", args), + [PROPOSAL_REMOVE_MEMBER]: data.isCreator + ? L('your proposal to remove {member} from the group was {strong_}{closedWith}{_strong}.', args) + : L("{strong_}{name}'s{_strong} proposal to remove {member} from the group was {strong_}{closedWith}{_strong}.", args), + [PROPOSAL_GROUP_SETTING_CHANGE]: data.isCreator + ? L('your proposal to change group\'s {setting} to {value} was {strong_}{closedWith}{_strong}.', args) + : L("{strong_}{name}'s{_strong} proposal to change group's {setting} to {value} was {strong_}{closedWith}{_strong}.", args), + [PROPOSAL_PROPOSAL_SETTING_CHANGE]: data.isCreator + ? L('your proposal to change group\'s {setting} was {strong_}{closedWith}{_strong}.', args) + : L("{strong_}{name}'s{_strong} proposal to change group's {setting} was {strong_}{closedWith}{_strong}.", args), + [PROPOSAL_GENERIC]: data.isCreator + ? L('your proposal "{title}" was {strong_}{closedWith}{_strong}.', args) + : L("{strong_}{name}'s{_strong} proposal \"{title}\" was {strong_}{closedWith}{_strong}.", args) } return { From 6c4c1b1bce0614fc863db8d3f58ddf458da7c1f6 Mon Sep 17 00:00:00 2001 From: SebinSong Date: Sun, 8 Dec 2024 10:14:11 +0900 Subject: [PATCH 3/7] update for feedback --- frontend/model/contracts/group.js | 2 -- frontend/model/notifications/templates.js | 30 ++++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/frontend/model/contracts/group.js b/frontend/model/contracts/group.js index 80239cd02e..4ed3c02376 100644 --- a/frontend/model/contracts/group.js +++ b/frontend/model/contracts/group.js @@ -702,7 +702,6 @@ sbp('chelonia/defineContract', { createdDate: meta.createdDate, groupID: contractID, creatorID: innerSigningContractID, - isCreator: innerSigningContractID === loggedIn.identityContractID, subtype: typeToSubTypeMap[data.proposalType] }) } @@ -1552,7 +1551,6 @@ sbp('chelonia/defineContract', { sbp('gi.notifications/emit', 'PROPOSAL_CLOSED', { createdDate: meta.createdDate, groupID: contractID, - isCreator: loggedIn.identityContractID === proposal.creatorID, proposal }) } diff --git a/frontend/model/notifications/templates.js b/frontend/model/notifications/templates.js index b15d1a6704..7a8192eccf 100644 --- a/frontend/model/notifications/templates.js +++ b/frontend/model/notifications/templates.js @@ -144,8 +144,9 @@ export default ({ scope: 'group' } }, - NEW_PROPOSAL (data: { groupID: string, creatorID: string, isCreator: boolean, subtype: NewProposalType }) { - const args = data.isCreator + NEW_PROPOSAL (data: { groupID: string, creatorID: string, subtype: NewProposalType }) { + const isCreator = data.creatorID === sbp('state/vuex/getters').ourIdentityContractId + const args = isCreator ? null : { name: `${CHATROOM_MEMBER_MENTION_SPECIAL_CHAR}${data.creatorID}`, @@ -153,22 +154,22 @@ export default ({ } const bodyTemplateMap = { - ADD_MEMBER: data.isCreator + ADD_MEMBER: isCreator ? L('you proposed to add a member to the group.') : L('{strong_}{name}{_strong} proposed to add a member to the group. Vote now!', args), - CHANGE_MINCOME: data.isCreator + CHANGE_MINCOME: isCreator ? L('you proposed to change the group mincome.') : L('{strong_}{name}{_strong} proposed to change the group mincome. Vote now!', args), - CHANGE_DISTRIBUTION_DATE: data.isCreator + CHANGE_DISTRIBUTION_DATE: isCreator ? L('you proposed to change the group distribution date.') : L('{strong_}{name}{_strong} proposed to change the group distribution date. Vote now!', args), - CHANGE_VOTING_RULE: data.isCreator + CHANGE_VOTING_RULE: isCreator ? L('you proposed to change the group voting system.') : L('{strong_}{name}{_strong} proposed to change the group voting system. Vote now!', args), - REMOVE_MEMBER: data.isCreator + REMOVE_MEMBER: isCreator ? L('you proposed to remove a member from the group.') : L('{strong_}{name}{_strong} proposed to remove a member from the group. Vote now!', args), - GENERIC: data.isCreator + GENERIC: isCreator ? L('you created a proposal.') : L('{strong_}{name}{_strong} created a proposal. Vote now!', args) } @@ -221,6 +222,7 @@ export default ({ }, PROPOSAL_CLOSED (data: { proposal: Object, isCreator: boolean }) { const { creatorID, status, type, options } = getProposalDetails(data.proposal) + const isCreator = creatorID === sbp('state/vuex/getters').ourIdentityContractId const statusMap = { [STATUS_PASSED]: { icon: 'check', level: 'success', closedWith: L('accepted') }, @@ -232,7 +234,7 @@ export default ({ ...options, ...LTags('strong'), closedWith: statusMap[status].closedWith, - name: !data.isCreator ? `${CHATROOM_MEMBER_MENTION_SPECIAL_CHAR}${creatorID}` : '' + name: !isCreator ? `${CHATROOM_MEMBER_MENTION_SPECIAL_CHAR}${creatorID}` : '' } if (options.memberID) { @@ -242,19 +244,19 @@ export default ({ } const bodyTemplateMap = { - [PROPOSAL_INVITE_MEMBER]: data.isCreator + [PROPOSAL_INVITE_MEMBER]: isCreator ? L('your proposal to add {member} to the group was {strong_}{closedWith}{_strong}.', args) : L("{strong_}{name}'s{_strong} proposal to add {member} to the group was {strong_}{closedWith}{_strong}.", args), - [PROPOSAL_REMOVE_MEMBER]: data.isCreator + [PROPOSAL_REMOVE_MEMBER]: isCreator ? L('your proposal to remove {member} from the group was {strong_}{closedWith}{_strong}.', args) : L("{strong_}{name}'s{_strong} proposal to remove {member} from the group was {strong_}{closedWith}{_strong}.", args), - [PROPOSAL_GROUP_SETTING_CHANGE]: data.isCreator + [PROPOSAL_GROUP_SETTING_CHANGE]: isCreator ? L('your proposal to change group\'s {setting} to {value} was {strong_}{closedWith}{_strong}.', args) : L("{strong_}{name}'s{_strong} proposal to change group's {setting} to {value} was {strong_}{closedWith}{_strong}.", args), - [PROPOSAL_PROPOSAL_SETTING_CHANGE]: data.isCreator + [PROPOSAL_PROPOSAL_SETTING_CHANGE]: isCreator ? L('your proposal to change group\'s {setting} was {strong_}{closedWith}{_strong}.', args) : L("{strong_}{name}'s{_strong} proposal to change group's {setting} was {strong_}{closedWith}{_strong}.", args), - [PROPOSAL_GENERIC]: data.isCreator + [PROPOSAL_GENERIC]: isCreator ? L('your proposal "{title}" was {strong_}{closedWith}{_strong}.', args) : L("{strong_}{name}'s{_strong} proposal \"{title}\" was {strong_}{closedWith}{_strong}.", args) } From 6fa92b9f5a5eca236980a7080c20f215e3b79fef Mon Sep 17 00:00:00 2001 From: SebinSong Date: Sun, 8 Dec 2024 10:41:45 +0900 Subject: [PATCH 4/7] add comment --- frontend/model/notifications/templates.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/model/notifications/templates.js b/frontend/model/notifications/templates.js index 7a8192eccf..d8f73ffb3b 100644 --- a/frontend/model/notifications/templates.js +++ b/frontend/model/notifications/templates.js @@ -145,7 +145,7 @@ export default ({ } }, NEW_PROPOSAL (data: { groupID: string, creatorID: string, subtype: NewProposalType }) { - const isCreator = data.creatorID === sbp('state/vuex/getters').ourIdentityContractId + const isCreator = data.creatorID === sbp('state/vuex/getters').ourIdentityContractId // notification message is different for creator and non-creator const args = isCreator ? null : { @@ -222,7 +222,7 @@ export default ({ }, PROPOSAL_CLOSED (data: { proposal: Object, isCreator: boolean }) { const { creatorID, status, type, options } = getProposalDetails(data.proposal) - const isCreator = creatorID === sbp('state/vuex/getters').ourIdentityContractId + const isCreator = creatorID === sbp('state/vuex/getters').ourIdentityContractId // notification message is different for creator and non-creator const statusMap = { [STATUS_PASSED]: { icon: 'check', level: 'success', closedWith: L('accepted') }, From 4de9188157696fab05254335ac97515f2a48a7c7 Mon Sep 17 00:00:00 2001 From: SebinSong Date: Mon, 16 Dec 2024 20:01:06 +0900 Subject: [PATCH 5/7] install new pkg --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 666ba223a7..8b2b25b402 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "group-income", - "version": "1.0.7", + "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "group-income", - "version": "1.0.7", + "version": "1.1.0", "license": "AGPL-3.0", "dependencies": { "@babel/core": "7.23.7", From b95bb4441aa1d6e7841a8fe8ba2ba55d88a27ffa Mon Sep 17 00:00:00 2001 From: SebinSong Date: Mon, 16 Dec 2024 20:05:20 +0900 Subject: [PATCH 6/7] update for Greg CR --- frontend/model/notifications/templates.js | 32 +++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/frontend/model/notifications/templates.js b/frontend/model/notifications/templates.js index 0b9583feb0..5ebc9c3ba0 100644 --- a/frontend/model/notifications/templates.js +++ b/frontend/model/notifications/templates.js @@ -146,31 +146,29 @@ export default ({ }, NEW_PROPOSAL (data: { groupID: string, creatorID: string, proposalHash: string, subtype: NewProposalType }) { const isCreator = data.creatorID === sbp('state/vuex/getters').ourIdentityContractId // notification message is different for creator and non-creator - const args = isCreator - ? null - : { - name: `${CHATROOM_MEMBER_MENTION_SPECIAL_CHAR}${data.creatorID}`, - ...LTags('strong') - } + const args = { + name: `${CHATROOM_MEMBER_MENTION_SPECIAL_CHAR}${data.creatorID}`, + ...LTags('strong') + } const bodyTemplateMap = { ADD_MEMBER: isCreator - ? L('you proposed to add a member to the group.') + ? L('You proposed to add a member to the group.') : L('{strong_}{name}{_strong} proposed to add a member to the group. Vote now!', args), CHANGE_MINCOME: isCreator - ? L('you proposed to change the group mincome.') + ? L('You proposed to change the group mincome.') : L('{strong_}{name}{_strong} proposed to change the group mincome. Vote now!', args), CHANGE_DISTRIBUTION_DATE: isCreator - ? L('you proposed to change the group distribution date.') + ? L('You proposed to change the group distribution date.') : L('{strong_}{name}{_strong} proposed to change the group distribution date. Vote now!', args), CHANGE_VOTING_RULE: isCreator - ? L('you proposed to change the group voting system.') + ? L('You proposed to change the group voting system.') : L('{strong_}{name}{_strong} proposed to change the group voting system. Vote now!', args), REMOVE_MEMBER: isCreator - ? L('you proposed to remove a member from the group.') + ? L('You proposed to remove a member from the group.') : L('{strong_}{name}{_strong} proposed to remove a member from the group. Vote now!', args), GENERIC: isCreator - ? L('you created a proposal.') + ? L('You created a proposal.') : L('{strong_}{name}{_strong} created a proposal. Vote now!', args) } @@ -251,19 +249,19 @@ export default ({ const bodyTemplateMap = { [PROPOSAL_INVITE_MEMBER]: isCreator - ? L('your proposal to add {member} to the group was {strong_}{closedWith}{_strong}.', args) + ? L('Your proposal to add {member} to the group was {strong_}{closedWith}{_strong}.', args) : L("{strong_}{name}'s{_strong} proposal to add {member} to the group was {strong_}{closedWith}{_strong}.", args), [PROPOSAL_REMOVE_MEMBER]: isCreator - ? L('your proposal to remove {member} from the group was {strong_}{closedWith}{_strong}.', args) + ? L('Your proposal to remove {member} from the group was {strong_}{closedWith}{_strong}.', args) : L("{strong_}{name}'s{_strong} proposal to remove {member} from the group was {strong_}{closedWith}{_strong}.", args), [PROPOSAL_GROUP_SETTING_CHANGE]: isCreator - ? L('your proposal to change group\'s {setting} to {value} was {strong_}{closedWith}{_strong}.', args) + ? L('Your proposal to change group\'s {setting} to {value} was {strong_}{closedWith}{_strong}.', args) : L("{strong_}{name}'s{_strong} proposal to change group's {setting} to {value} was {strong_}{closedWith}{_strong}.", args), [PROPOSAL_PROPOSAL_SETTING_CHANGE]: isCreator - ? L('your proposal to change group\'s {setting} was {strong_}{closedWith}{_strong}.', args) + ? L('Your proposal to change group\'s {setting} was {strong_}{closedWith}{_strong}.', args) : L("{strong_}{name}'s{_strong} proposal to change group's {setting} was {strong_}{closedWith}{_strong}.", args), [PROPOSAL_GENERIC]: isCreator - ? L('your proposal "{title}" was {strong_}{closedWith}{_strong}.', args) + ? L('Your proposal "{title}" was {strong_}{closedWith}{_strong}.', args) : L("{strong_}{name}'s{_strong} proposal \"{title}\" was {strong_}{closedWith}{_strong}.", args) } From 5d1b0136293db048b921ba0f48ee7c27535061e5 Mon Sep 17 00:00:00 2001 From: SebinSong Date: Mon, 16 Dec 2024 20:27:03 +0900 Subject: [PATCH 7/7] comment update for the flaky cypress --- frontend/model/notifications/templates.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/model/notifications/templates.js b/frontend/model/notifications/templates.js index 5ebc9c3ba0..dda04d7f3b 100644 --- a/frontend/model/notifications/templates.js +++ b/frontend/model/notifications/templates.js @@ -145,7 +145,7 @@ export default ({ } }, NEW_PROPOSAL (data: { groupID: string, creatorID: string, proposalHash: string, subtype: NewProposalType }) { - const isCreator = data.creatorID === sbp('state/vuex/getters').ourIdentityContractId // notification message is different for creator and non-creator + const isCreator = data.creatorID === sbp('state/vuex/getters').ourIdentityContractId // notification message is different for creator and non-creator. const args = { name: `${CHATROOM_MEMBER_MENTION_SPECIAL_CHAR}${data.creatorID}`, ...LTags('strong')