Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions src/components/MessageInput/hooks/useSubmitHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,13 @@ export const useSubmitHandler = <
return addNotification(t('Wait until all attachments have uploaded'), 'error');
}

const attachmentsFromUploads = attachments
.filter(
(att) =>
att.localMetadata?.uploadState !== 'failed' ||
(findAndEnqueueURLsToEnrich && !att.og_scrape_url), // filter out all the attachments scraped before the message was edited
)
const attachmentsWithoutLinkPreviews = attachments
.filter((att) => {
const isSuccessfulUpload = att.localMetadata?.uploadState === 'finished';
const isNotUpload = !att.localMetadata?.uploadState;
const isNotLinkPreview = !att.og_scrape_url;
return isNotLinkPreview && (isSuccessfulUpload || isNotUpload);
})
.map((localAttachment) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { localMetadata: _, ...attachment } = localAttachment;
Expand All @@ -116,14 +117,7 @@ export const useSubmitHandler = <
attachmentsFromLinkPreviews = someLinkPreviewsLoading
? []
: Array.from(linkPreviews.values())
.filter(
(linkPreview) =>
linkPreview.state === LinkPreviewState.LOADED &&
!attachmentsFromUploads.find(
(attFromUpload) =>
attFromUpload.og_scrape_url === linkPreview.og_scrape_url,
),
)
.filter((linkPreview) => linkPreview.state === LinkPreviewState.LOADED)

.map(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand All @@ -137,7 +131,10 @@ export const useSubmitHandler = <
someLinkPreviewsDismissed;
}

const newAttachments = [...attachmentsFromUploads, ...attachmentsFromLinkPreviews];
const newAttachments = [
...attachmentsWithoutLinkPreviews,
...attachmentsFromLinkPreviews,
];

// Instead of checking if a user is still mentioned every time the text changes,
// just filter out non-mentioned users before submit, which is cheaper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const pollStateSelector = <
nextValue: PollState<StreamChatGenerics>,
): PollStateSelectorReturnValue<StreamChatGenerics> => ({
name: nextValue.name,
options: nextValue.options,
options: [...nextValue.options],
vote_counts_by_option: nextValue.vote_counts_by_option,
});

Expand Down
13 changes: 9 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,11 @@
dependencies:
regenerator-runtime "^0.14.0"

"@babel/runtime@^7.27.0":
version "7.27.1"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.27.1.tgz#9fce313d12c9a77507f264de74626e87fd0dc541"
integrity sha512-1x3D2xEk2fRo3PAhwQwu5UubzgiVWSXTBfWpVd2Mx2AzRqJuDJCsgaDVZ7HB5iGzDW1Hl1sWN2mFyKjmR9uAog==

"@babel/template@^7.16.7", "@babel/template@^7.24.7", "@babel/template@^7.3.3":
version "7.24.7"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.24.7.tgz#02efcee317d0609d2c07117cb70ef8fb17ab7315"
Expand Down Expand Up @@ -12119,11 +12124,11 @@ [email protected]:
integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==

stream-chat@^8.55.0:
version "8.55.0"
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.55.0.tgz#a4a651c4216185821a9d6b1ea55b6689a1a979a8"
integrity sha512-mdgB6LrDwCojf2xuHME2pnZIoIzAgd++CSsGlk9a+AUhmZMLnFFuMfg18uav3h9dKdRcRfFIgXe+raJgV6uIgA==
version "8.60.0"
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.60.0.tgz#b67d4fbb185da53fb8ac5fc5759986d6ad7e19a3"
integrity sha512-7FpO7Wno++r+n+x9aFuXtGYtNO06CIMd2Bxe3doYZLhMfS0nuaXloeFlGcMT0r4U/6bnguz1qQdDJUPNQAS8bQ==
dependencies:
"@babel/runtime" "^7.16.3"
"@babel/runtime" "^7.27.0"
"@types/jsonwebtoken" "~9.0.0"
"@types/ws" "^7.4.0"
axios "^1.6.0"
Expand Down