Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2441 - proposal notifications should have 'you' when I am the creator #2444

Merged
merged 9 commits into from
Dec 16, 2024
54 changes: 37 additions & 17 deletions frontend/model/notifications/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,31 @@ 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 = {
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: 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: 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: 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: 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: 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: isCreator
? L('You created a proposal.')
: L('{strong_}{name}{_strong} created a proposal. Vote now!', args)
}

const iconMap = {
Expand Down Expand Up @@ -212,6 +226,7 @@ export default ({
},
PROPOSAL_CLOSED (data: { proposal: Object, proposalHash: string }) {
const { creatorID, status, type, options } = getProposalDetails(data.proposal)
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') },
Expand All @@ -223,7 +238,7 @@ export default ({
...options,
...LTags('strong'),
closedWith: statusMap[status].closedWith,
name: `${CHATROOM_MEMBER_MENTION_SPECIAL_CHAR}${creatorID}`
name: !isCreator ? `${CHATROOM_MEMBER_MENTION_SPECIAL_CHAR}${creatorID}` : ''
}

if (options.memberID) {
Expand All @@ -233,16 +248,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]: 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]: 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]: 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]: 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]: isCreator
? L('Your proposal "{title}" was {strong_}{closedWith}{_strong}.', args)
: L("{strong_}{name}'s{_strong} proposal \"{title}\" was {strong_}{closedWith}{_strong}.", args)
}

return {
Expand Down