Skip to content

Commit 41db01e

Browse files
committed
Fix polls not sending while sending an attachment & polls not sending in replies
1 parent 88d8bd6 commit 41db01e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/chat-api/store/usePosts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export type Post = RawPost & {
3434
cachedComments(this: Post): Post[] | undefined;
3535
submitReply(
3636
this: Post,
37-
opts: { content: string; attachment?: File }
37+
opts: { content: string; attachment?: File, poll?: { choices: string[] }; }
3838
): Promise<any>;
3939
};
4040

@@ -193,6 +193,7 @@ export function usePosts() {
193193
content: formattedContent,
194194
attachment: opts.attachment,
195195
replyToPostId: this.id,
196+
poll: opts.poll,
196197
}).catch((err) => {
197198
alert(err.message);
198199
});

src/components/PostsArea.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,24 +158,28 @@ function NewPostArea(props: {
158158
const onCreateClick = () => {
159159
const tempContent = content();
160160
const formattedContent = formatMessage(content().trim());
161+
const pollOpts = [...pollOptions];
162+
161163
if (props.postId) {
162164
posts
163165
.cachedPost(props.postId)
164166
?.submitReply({
165167
content: formattedContent,
166168
attachment: attachedFile(),
169+
poll: showPollOptions() ? { choices: pollOpts } : undefined,
167170
})
168171
.then((res) => {
169172
if (!res) {
170173
setContent(tempContent);
171174
}
172175
});
173176
} else {
177+
console.log(pollOpts);
174178
posts
175179
.submitPost({
176180
content: formattedContent,
177181
file: attachedFile(),
178-
poll: showPollOptions() ? { choices: pollOptions } : undefined,
182+
poll: showPollOptions() ? { choices: pollOpts } : undefined,
179183
})
180184
.then((res) => {
181185
if (!res) {

0 commit comments

Comments
 (0)