Skip to content

Commit d62c397

Browse files
Add ability for poll author to terminate a poll
Co-authored-by: yash-signal <[email protected]>
1 parent da43ea6 commit d62c397

39 files changed

+893
-85
lines changed

_locales/en/messages.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,10 @@
14621462
"messageformat": "Info",
14631463
"description": "Shown on the drop-down menu for an individual message, takes you to message detail screen"
14641464
},
1465+
"icu:Poll__end-poll": {
1466+
"messageformat": "End poll",
1467+
"description": "Label for button/menu item to end a poll. Shown in the poll votes modal and in the message context menu"
1468+
},
14651469
"icu:PollMessage--SelectOne": {
14661470
"messageformat": "Poll · Select one",
14671471
"description": "Status text for single-choice poll where user can select one option"
@@ -1482,6 +1486,18 @@
14821486
"messageformat": "You voted",
14831487
"description": "Accessibility label for checkmark indicating user voted for this poll option"
14841488
},
1489+
"icu:PollTerminate--you": {
1490+
"messageformat": "You ended the poll: \"{poll}\"",
1491+
"description": "Chat event shown when you end a poll"
1492+
},
1493+
"icu:PollTerminate--other": {
1494+
"messageformat": "{name} ended the poll: \"{poll}\"",
1495+
"description": "Chat event shown when someone else ends a poll"
1496+
},
1497+
"icu:PollTerminate__view-poll": {
1498+
"messageformat": "View poll",
1499+
"description": "Button in poll terminate chat event to scroll to and select the original poll message"
1500+
},
14851501
"icu:PollVotesModal__title": {
14861502
"messageformat": "Poll details",
14871503
"description": "Modal title for viewing poll votes and who voted on which option"
@@ -1498,6 +1514,10 @@
14981514
"messageformat": "No votes",
14991515
"description": "Message shown when poll has no votes"
15001516
},
1517+
"icu:Toast--PollNotFound": {
1518+
"messageformat": "Poll not found",
1519+
"description": "Toast shown when user tries to view a poll that no longer exists"
1520+
},
15011521
"icu:PollCreateModal__title": {
15021522
"messageformat": "New poll",
15031523
"description": "Title for the modal to create a new poll"
Lines changed: 1 addition & 0 deletions
Loading

stylesheets/_modules.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6785,6 +6785,13 @@ button.module-calling-participants-list__contact {
67856785
}
67866786
}
67876787

6788+
&__end-poll::before {
6789+
@include mixins.color-svg(
6790+
'../images/icons/v3/stop/stop-circle.svg',
6791+
light-dark(variables.$color-black, variables.$color-gray-15)
6792+
);
6793+
}
6794+
67886795
&__more-info::before {
67896796
@include mixins.light-theme {
67906797
@include mixins.color-svg(

stylesheets/components/SystemMessage.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
}
5454
}
5555

56-
&::before {
56+
&--has-icon::before {
5757
content: '';
5858
display: inline-block;
5959
height: 16px;

ts/components/EditHistoryMessagesModal.dom.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const MESSAGE_DEFAULT_PROPS = {
5252
previews: [],
5353
retryMessageSend: shouldNeverBeCalled,
5454
sendPollVote: shouldNeverBeCalled,
55+
endPoll: shouldNeverBeCalled,
5556
pushPanelForConversation: shouldNeverBeCalled,
5657
renderAudioAttachment: () => <div />,
5758
renderingContext: 'EditHistoryMessagesModal',

ts/components/StoryViewsNRepliesModal.dom.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const MESSAGE_DEFAULT_PROPS = {
6666
previews: [],
6767
retryMessageSend: shouldNeverBeCalled,
6868
sendPollVote: shouldNeverBeCalled,
69+
endPoll: shouldNeverBeCalled,
6970
pushPanelForConversation: shouldNeverBeCalled,
7071
renderAudioAttachment: () => <div />,
7172
saveAttachment: shouldNeverBeCalled,

ts/components/ToastManager.dom.stories.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ function getToast(toastType: ToastType): AnyToast {
189189
return { toastType: ToastType.OriginalMessageNotFound };
190190
case ToastType.PinnedConversationsFull:
191191
return { toastType: ToastType.PinnedConversationsFull };
192+
case ToastType.PollNotFound:
193+
return { toastType: ToastType.PollNotFound };
192194
case ToastType.ReactionFailed:
193195
return { toastType: ToastType.ReactionFailed };
194196
case ToastType.ReceiptSaved:

ts/components/ToastManager.dom.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,10 @@ export function renderToast({
652652
);
653653
}
654654

655+
if (toastType === ToastType.PollNotFound) {
656+
return <Toast onClose={hideToast}>{i18n('icu:Toast--PollNotFound')}</Toast>;
657+
}
658+
655659
if (toastType === ToastType._InternalMainProcessLoggingError) {
656660
return (
657661
<Toast

ts/components/conversation/CallingNotification.dom.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export const CallingNotification: React.FC<PropsType> = React.memo(
138138
onEdit={undefined}
139139
onReplyToMessage={undefined}
140140
onReact={undefined}
141+
onEndPoll={undefined}
141142
onRetryMessageSend={undefined}
142143
onRetryDeleteForEveryone={undefined}
143144
onCopy={undefined}

ts/components/conversation/Message.dom.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ export type PropsData = {
249249
isSelectMode: boolean;
250250
isSMS: boolean;
251251
isSpoilerExpanded?: Record<number, boolean>;
252+
canEndPoll?: boolean;
252253
direction: DirectionType;
253254
timestamp: number;
254255
receivedAtMS?: number;
@@ -363,6 +364,7 @@ export type PropsActions = {
363364
messageId: string;
364365
optionIndexes: ReadonlyArray<number>;
365366
}) => void;
367+
endPoll: (messageId: string) => void;
366368
showContactModal: (contactId: string, conversationId?: string) => void;
367369
showSpoiler: (messageId: string, data: Record<number, boolean>) => void;
368370

@@ -2023,7 +2025,7 @@ export class Message extends React.PureComponent<Props, State> {
20232025
}
20242026

20252027
public renderPoll(): JSX.Element | null {
2026-
const { poll, direction, i18n, id } = this.props;
2028+
const { poll, direction, i18n, id, endPoll, canEndPoll } = this.props;
20272029
if (!poll || !isPollReceiveEnabled()) {
20282030
return null;
20292031
}
@@ -2034,6 +2036,8 @@ export class Message extends React.PureComponent<Props, State> {
20342036
i18n={i18n}
20352037
messageId={id}
20362038
sendPollVote={this.props.sendPollVote}
2039+
endPoll={endPoll}
2040+
canEndPoll={canEndPoll}
20372041
/>
20382042
);
20392043
}

0 commit comments

Comments
 (0)