-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Changes from 2 commits
b0ab51e
f0e178c
6c4c1b1
6fa92b9
b532560
4de9188
e9d1111
b95bb44
5d1b013
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -702,6 +702,7 @@ sbp('chelonia/defineContract', { | |
createdDate: meta.createdDate, | ||
groupID: contractID, | ||
creatorID: innerSigningContractID, | ||
isCreator: innerSigningContractID === loggedIn.identityContractID, | ||
subtype: typeToSubTypeMap[data.proposalType] | ||
}) | ||
} | ||
|
@@ -1548,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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
proposal | ||
}) | ||
} | ||
}, | ||
'gi.contracts/group/sendMincomeChangedNotification': async function (contractID, meta, data, height, innerSigningContractID) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Every sentence that starts with "you" needs to be replaced with "You" because sentences should start with an uppercase letter. |
||
: 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 = { | ||
|
@@ -204,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 = { | ||
|
@@ -217,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) { | ||
|
@@ -227,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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Every sentence that starts with "your" needs to be replaced with "Your" because sentences should start with an uppercase letter. |
||
: 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 { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of
isCreator
, I think it'd be better to leave this as is, and add thecreatorID
to thePROPOSAL_CLOSED
notification. Then, we can check for creator when the notification text is created. (The reason for doing it this way is to keep the contract code as less reliant on external state as possible).