stream-chat-react-native-core 9.10.2-beta.2 → 9.10.2-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewPollLabel.js +4 -1
- package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewPollLabel.js.map +1 -1
- package/lib/commonjs/middlewares/attachments.js +1 -0
- package/lib/commonjs/middlewares/attachments.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/ChannelPreview/hooks/useChannelPreviewPollLabel.js +4 -1
- package/lib/module/components/ChannelPreview/hooks/useChannelPreviewPollLabel.js.map +1 -1
- package/lib/module/middlewares/attachments.js +1 -0
- package/lib/module/middlewares/attachments.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/middlewares/attachments.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewPollLabel.test.tsx +86 -0
- package/src/components/ChannelPreview/hooks/useChannelPreviewPollLabel.ts +1 -1
- package/src/middlewares/__tests__/attachments.test.ts +19 -0
- package/src/middlewares/attachments.ts +5 -0
- package/src/version.json +1 -1
|
@@ -22,7 +22,10 @@ var useChannelPreviewPollLabel = ({
|
|
|
22
22
|
var pollState = (_useStateStore = (0, _useStateStore2.useStateStore)(poll == null ? void 0 : poll.state, selector)) != null ? _useStateStore : {};
|
|
23
23
|
var latestVotesByOption = pollState.latest_votes_by_option,
|
|
24
24
|
pollOptions = pollState.options;
|
|
25
|
-
var latestVotes = (0, _react.useMemo)(() => latestVotesByOption ? Object.values(latestVotesByOption).
|
|
25
|
+
var latestVotes = (0, _react.useMemo)(() => latestVotesByOption ? Object.values(latestVotesByOption).flatMap(votes => {
|
|
26
|
+
var _votes$;
|
|
27
|
+
return (_votes$ = votes == null ? void 0 : votes[0]) != null ? _votes$ : [];
|
|
28
|
+
}).sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()) : [], [latestVotesByOption]);
|
|
26
29
|
return (0, _react.useMemo)(() => {
|
|
27
30
|
if (!(latestVotes && latestVotes.length && latestVotes[0].user)) return;
|
|
28
31
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_ChatContext","_TranslationContext","_useStateStore2","selector","nextValue","latest_votes_by_option","options","useChannelPreviewPollLabel","pollId","_useStateStore","_client$user2","_useChatContext","useChatContext","client","_useTranslationContex","useTranslationContext","t","poll","polls","fromState","pollState","useStateStore","state","latestVotesByOption","pollOptions","latestVotes","useMemo","Object","values","
|
|
1
|
+
{"version":3,"names":["_react","require","_ChatContext","_TranslationContext","_useStateStore2","selector","nextValue","latest_votes_by_option","options","useChannelPreviewPollLabel","pollId","_useStateStore","_client$user2","_useChatContext","useChatContext","client","_useTranslationContex","useTranslationContext","t","poll","polls","fromState","pollState","useStateStore","state","latestVotesByOption","pollOptions","latestVotes","useMemo","Object","values","flatMap","votes","_votes$","sort","a","b","Date","created_at","getTime","length","user","_client$user","option","find","id","option_id","voteUser","text","name","exports"],"sourceRoot":"../../../../../src","sources":["components/ChannelPreview/hooks/useChannelPreviewPollLabel.ts"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAMA,IAAMI,QAAQ,GAAIC,SAAoB,KAAM;EAC1CC,sBAAsB,EAAED,SAAS,CAACC,sBAAsB;EACxDC,OAAO,EAAEF,SAAS,CAACE;AACrB,CAAC,CAAC;AAOK,IAAMC,0BAA0B,GAAGA,CAAC;EAAEC;AAAwC,CAAC,KAAK;EAAA,IAAAC,cAAA,EAAAC,aAAA;EACzF,IAAAC,eAAA,GAAmB,IAAAC,2BAAc,EAAC,CAAC;IAA3BC,MAAM,GAAAF,eAAA,CAANE,MAAM;EACd,IAAAC,qBAAA,GAAc,IAAAC,y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AC,CAAC,CAAC,CAACc,IAAI;MACpC,IAAIM,QAAQ,CAACF,EAAE,OAAAH,YAAA,GAAK3B,MAAM,CAAC0B,IAAI,qBAAXC,YAAA,CAAaG,EAAE,GAAE;QACnC,OAAO3B,CAAC,CAAC,yBAAyB,EAAE;UAAEyB,MAAM,EAAEA,MAAM,oBAANA,MAAM,CAAEK;QAAK,CAAC,CAAC;MAC/D,CAAC,MAAM;QACL,OAAO9B,CAAC,CAAC,gCAAgC,EAAE;UACzCuB,IAAI,EAAEM,QAAQ,CAACE,IAAI,IAAIF,QAAQ,CAACF,EAAE;UAClCF,MAAM,EAAEA,MAAM,oBAANA,MAAM,CAAEK;QAClB,CAAC,CAAC;MACJ;IACF;EACF,CAAC,EAAE,CAACrB,WAAW,EAAED,WAAW,GAAAd,aAAA,GAAEG,MAAM,CAAC0B,IAAI,qBAAX7B,aAAA,CAAaiC,EAAE,EAAE3B,CAAC,CAAC,CAAC;AACpD,CAAC;AAACgC,OAAA,CAAAzC,0BAAA,GAAAA,0BAAA","ignoreList":[]}
|
|
@@ -10,6 +10,7 @@ var _excluded = ["localMetadata"];
|
|
|
10
10
|
var localAttachmentToAttachment = localAttachment => {
|
|
11
11
|
var localMetadata = localAttachment.localMetadata,
|
|
12
12
|
attachment = (0, _objectWithoutProperties2.default)(localAttachment, _excluded);
|
|
13
|
+
if (!(0, _streamChat.isLocalUploadAttachment)(localAttachment)) return attachment;
|
|
13
14
|
if ((0, _streamChat.isLocalImageAttachment)(localAttachment)) {
|
|
14
15
|
var isRemoteUri = !!attachment.image_url && !(0, _utils.isLocalUrl)(attachment.image_url);
|
|
15
16
|
if (isRemoteUri) return attachment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_streamChat","require","_utils","_excluded","localAttachmentToAttachment","localAttachment","localMetadata","attachment","_objectWithoutProperties2","default","isLocalImageAttachment","isRemoteUri","image_url","isLocalUrl","previewUri","localId","id","originalFile","file","asset_url","uri","exports","createAttachmentsCompositionMiddleware","composer","handlers","compose","state","next","forward","_state$message$attach","attachmentManager","attachments","message","concat","filter","uploadState","map","length","localMessage","createDraftAttachmentsCompositionMiddleware","_state$draft$attachme","draft","createVideoAttachmentPreviewMiddleware","prepare","isLocalVideoAttachment","thumb_url","setupVideoAttachmentPreviewMiddleware","messageComposer","preUploadMiddlewareExecutor","insert","middleware","position","after","unique"],"sourceRoot":"../../../src","sources":["middlewares/attachments.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_streamChat","require","_utils","_excluded","localAttachmentToAttachment","localAttachment","localMetadata","attachment","_objectWithoutProperties2","default","isLocalUploadAttachment","isLocalImageAttachment","isRemoteUri","image_url","isLocalUrl","previewUri","localId","id","originalFile","file","asset_url","uri","exports","createAttachmentsCompositionMiddleware","composer","handlers","compose","state","next","forward","_state$message$attach","attachmentManager","attachments","message","concat","filter","uploadState","map","length","localMessage","createDraftAttachmentsCompositionMiddleware","_state$draft$attachme","draft","createVideoAttachmentPreviewMiddleware","prepare","isLocalVideoAttachment","thumb_url","setupVideoAttachmentPreviewMiddleware","messageComposer","preUploadMiddlewareExecutor","insert","middleware","position","after","unique"],"sourceRoot":"../../../src","sources":["middlewares/attachments.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAgBA,IAAAC,MAAA,GAAAD,OAAA;AAA4C,IAAAE,SAAA;AAErC,IAAMC,2BAA2B,GAAIC,eAAgC,IAAK;EAC/E,IAAQC,aAAa,GAAoBD,eAAe,CAAhDC,aAAa;IAAKC,UAAU,OAAAC,yBAAA,CAAAC,OAAA,EAAKJ,eAAe,EAAAF,SAAA;EAIxD,IAAI,CAAC,IAAAO,mCAAuB,EAACL,eAAe,CAAC,EAAE,OAAOE,UAAU;EAEhE,IAAI,IAAAI,kCAAsB,EAACN,eAAe,CAAC,EAAE;IAC3C,IAAMO,WAAW,GAAG,CAAC,CAACL,UAAU,CAACM,SAAS,IAAI,CAA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ACvEQ,QAAQ,EAAE;IACRmB,OAAO,EAAEA,CAAC;MAAEhB,IAAI;MAAEC,OAAO;MAAEF;IAAM,CAAC,KAAK;MACrC,IAAQpB,UAAU,GAAKoB,KAAK,CAApBpB,UAAU;MAElB,IAAI,CAACA,UAAU,IAAI,CAAC,IAAAsC,kCAAsB,EAACtC,UAAU,CAAC,EAAE;QACtD,OAAOsB,OAAO,CAAC,CAAC;MAClB;MAEA,OAAOD,IAAI,CAAC;QACV,GAAGD,KAAK;QACRpB,UAAU,EAAE;UACV,GAAGA,UAAU;UACbD,aAAa,EAAE;YACb,GAAGC,UAAU,CAACD,aAAa;YAC3BS,UAAU,EAAER,UAAU,CAACuC;UACzB;QACF;MACF,CAAC,CAAC;IACJ;EACF;AACF,CAAC,CAAC;AAEK,IAAMC,qCAAqC,GAAIC,eAAgC,IAAK;EACzFA,eAAe,CAACjB,iBAAiB,CAACkB,2BAA2B,CAACC,MAAM,CAAC;IACnEC,UAAU,EAAE,CAACR,sCAAsC,CAAC,CAAC,CAAC;IACtDS,QAAQ,EAAE;MAAEC,KAAK,EAAE;IAAmE,CAAC;IACvFC,MAAM,EAAE;EACV,CAAC,CAAC;AACJ,CAAC;AAAChC,OAAA,CAAAyB,qCAAA,GAAAA,qCAAA","ignoreList":[]}
|
|
@@ -22,7 +22,10 @@ var useChannelPreviewPollLabel = ({
|
|
|
22
22
|
var pollState = (_useStateStore = (0, _useStateStore2.useStateStore)(poll == null ? void 0 : poll.state, selector)) != null ? _useStateStore : {};
|
|
23
23
|
var latestVotesByOption = pollState.latest_votes_by_option,
|
|
24
24
|
pollOptions = pollState.options;
|
|
25
|
-
var latestVotes = (0, _react.useMemo)(() => latestVotesByOption ? Object.values(latestVotesByOption).
|
|
25
|
+
var latestVotes = (0, _react.useMemo)(() => latestVotesByOption ? Object.values(latestVotesByOption).flatMap(votes => {
|
|
26
|
+
var _votes$;
|
|
27
|
+
return (_votes$ = votes == null ? void 0 : votes[0]) != null ? _votes$ : [];
|
|
28
|
+
}).sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()) : [], [latestVotesByOption]);
|
|
26
29
|
return (0, _react.useMemo)(() => {
|
|
27
30
|
if (!(latestVotes && latestVotes.length && latestVotes[0].user)) return;
|
|
28
31
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_ChatContext","_TranslationContext","_useStateStore2","selector","nextValue","latest_votes_by_option","options","useChannelPreviewPollLabel","pollId","_useStateStore","_client$user2","_useChatContext","useChatContext","client","_useTranslationContex","useTranslationContext","t","poll","polls","fromState","pollState","useStateStore","state","latestVotesByOption","pollOptions","latestVotes","useMemo","Object","values","
|
|
1
|
+
{"version":3,"names":["_react","require","_ChatContext","_TranslationContext","_useStateStore2","selector","nextValue","latest_votes_by_option","options","useChannelPreviewPollLabel","pollId","_useStateStore","_client$user2","_useChatContext","useChatContext","client","_useTranslationContex","useTranslationContext","t","poll","polls","fromState","pollState","useStateStore","state","latestVotesByOption","pollOptions","latestVotes","useMemo","Object","values","flatMap","votes","_votes$","sort","a","b","Date","created_at","getTime","length","user","_client$user","option","find","id","option_id","voteUser","text","name","exports"],"sourceRoot":"../../../../../src","sources":["components/ChannelPreview/hooks/useChannelPreviewPollLabel.ts"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAMA,IAAMI,QAAQ,GAAIC,SAAoB,KAAM;EAC1CC,sBAAsB,EAAED,SAAS,CAACC,sBAAsB;EACxDC,OAAO,EAAEF,SAAS,CAACE;AACrB,CAAC,CAAC;AAOK,IAAMC,0BAA0B,GAAGA,CAAC;EAAEC;AAAwC,CAAC,KAAK;EAAA,IAAAC,cAAA,EAAAC,aAAA;EACzF,IAAAC,eAAA,GAAmB,IAAAC,2BAAc,EAAC,CAAC;IAA3BC,MAAM,GAAAF,eAAA,CA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CAAC;MACpF,IAAMC,QAAQ,GAAGpB,WAAW,CAAC,CAAC,CAAC,CAACc,IAAI;MACpC,IAAIM,QAAQ,CAACF,EAAE,OAAAH,YAAA,GAAK3B,MAAM,CAAC0B,IAAI,qBAAXC,YAAA,CAAaG,EAAE,GAAE;QACnC,OAAO3B,CAAC,CAAC,yBAAyB,EAAE;UAAEyB,MAAM,EAAEA,MAAM,oBAANA,MAAM,CAAEK;QAAK,CAAC,CAAC;MAC/D,CAAC,MAAM;QACL,OAAO9B,CAAC,CAAC,gCAAgC,EAAE;UACzCuB,IAAI,EAAEM,QAAQ,CAACE,IAAI,IAAIF,QAAQ,CAACF,EAAE;UAClCF,MAAM,EAAEA,MAAM,oBAANA,MAAM,CAAEK;QAClB,CAAC,CAAC;MACJ;IACF;EACF,CAAC,EAAE,CAACrB,WAAW,EAAED,WAAW,GAAAd,aAAA,GAAEG,MAAM,CAAC0B,IAAI,qBAAX7B,aAAA,CAAaiC,EAAE,EAAE3B,CAAC,CAAC,CAAC;AACpD,CAAC;AAACgC,OAAA,CAAAzC,0BAAA,GAAAA,0BAAA","ignoreList":[]}
|
|
@@ -10,6 +10,7 @@ var _excluded = ["localMetadata"];
|
|
|
10
10
|
var localAttachmentToAttachment = localAttachment => {
|
|
11
11
|
var localMetadata = localAttachment.localMetadata,
|
|
12
12
|
attachment = (0, _objectWithoutProperties2.default)(localAttachment, _excluded);
|
|
13
|
+
if (!(0, _streamChat.isLocalUploadAttachment)(localAttachment)) return attachment;
|
|
13
14
|
if ((0, _streamChat.isLocalImageAttachment)(localAttachment)) {
|
|
14
15
|
var isRemoteUri = !!attachment.image_url && !(0, _utils.isLocalUrl)(attachment.image_url);
|
|
15
16
|
if (isRemoteUri) return attachment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_streamChat","require","_utils","_excluded","localAttachmentToAttachment","localAttachment","localMetadata","attachment","_objectWithoutProperties2","default","isLocalImageAttachment","isRemoteUri","image_url","isLocalUrl","previewUri","localId","id","originalFile","file","asset_url","uri","exports","createAttachmentsCompositionMiddleware","composer","handlers","compose","state","next","forward","_state$message$attach","attachmentManager","attachments","message","concat","filter","uploadState","map","length","localMessage","createDraftAttachmentsCompositionMiddleware","_state$draft$attachme","draft","createVideoAttachmentPreviewMiddleware","prepare","isLocalVideoAttachment","thumb_url","setupVideoAttachmentPreviewMiddleware","messageComposer","preUploadMiddlewareExecutor","insert","middleware","position","after","unique"],"sourceRoot":"../../../src","sources":["middlewares/attachments.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_streamChat","require","_utils","_excluded","localAttachmentToAttachment","localAttachment","localMetadata","attachment","_objectWithoutProperties2","default","isLocalUploadAttachment","isLocalImageAttachment","isRemoteUri","image_url","isLocalUrl","previewUri","localId","id","originalFile","file","asset_url","uri","exports","createAttachmentsCompositionMiddleware","composer","handlers","compose","state","next","forward","_state$message$attach","attachmentManager","attachments","message","concat","filter","uploadState","map","length","localMessage","createDraftAttachmentsCompositionMiddleware","_state$draft$attachme","draft","createVideoAttachmentPreviewMiddleware","prepare","isLocalVideoAttachment","thumb_url","setupVideoAttachmentPreviewMiddleware","messageComposer","preUploadMiddlewareExecutor","insert","middleware","position","after","unique"],"sourceRoot":"../../../src","sources":["middlewares/attachments.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAgBA,IAAAC,MAAA,GAAAD,OAAA;AAA4C,IAAAE,SAAA;AAErC,IAAMC,2BAA2B,GAAIC,eAAgC,IAAK;EAC/E,IAAQC,aAAa,GAAoBD,eAAe,CAAhDC,aAAa;IAAKC,UAAU,OAAAC,yBAAA,CAAAC,OAAA,EAAKJ,eAAe,EAAAF,SAAA;EAIxD,IAAI,CAAC,IAAAO,mCAAuB,EAACL,eAAe,CAAC,EAAE,OAAOE,UAAU;EAEhE,IAAI,IAAAI,kCAAsB,EAACN,eAAe,CAAC,EAAE;IAC3C,IAAMO,WAAW,GA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CAAA,MAAsC;EACnF1B,EAAE,EAAE,mEAAmE;EACvEQ,QAAQ,EAAE;IACRmB,OAAO,EAAEA,CAAC;MAAEhB,IAAI;MAAEC,OAAO;MAAEF;IAAM,CAAC,KAAK;MACrC,IAAQpB,UAAU,GAAKoB,KAAK,CAApBpB,UAAU;MAElB,IAAI,CAACA,UAAU,IAAI,CAAC,IAAAsC,kCAAsB,EAACtC,UAAU,CAAC,EAAE;QACtD,OAAOsB,OAAO,CAAC,CAAC;MAClB;MAEA,OAAOD,IAAI,CAAC;QACV,GAAGD,KAAK;QACRpB,UAAU,EAAE;UACV,GAAGA,UAAU;UACbD,aAAa,EAAE;YACb,GAAGC,UAAU,CAACD,aAAa;YAC3BS,UAAU,EAAER,UAAU,CAACuC;UACzB;QACF;MACF,CAAC,CAAC;IACJ;EACF;AACF,CAAC,CAAC;AAEK,IAAMC,qCAAqC,GAAIC,eAAgC,IAAK;EACzFA,eAAe,CAACjB,iBAAiB,CAACkB,2BAA2B,CAACC,MAAM,CAAC;IACnEC,UAAU,EAAE,CAACR,sCAAsC,CAAC,CAAC,CAAC;IACtDS,QAAQ,EAAE;MAAEC,KAAK,EAAE;IAAmE,CAAC;IACvFC,MAAM,EAAE;EACV,CAAC,CAAC;AACJ,CAAC;AAAChC,OAAA,CAAAyB,qCAAA,GAAAA,qCAAA","ignoreList":[]}
|
package/lib/module/version.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../../../src/middlewares/attachments.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,
|
|
1
|
+
{"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../../../src/middlewares/attachments.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAMV,eAAe,EACf,eAAe,EAEf,4BAA4B,EAE5B,iCAAiC,EAElC,MAAM,aAAa,CAAC;AAIrB,eAAO,MAAM,2BAA2B,GAAI,iBAAiB,eAAe,eA6B3E,CAAC;AAEF,eAAO,MAAM,sCAAsC,GACjD,UAAU,eAAe,KACxB,4BAoCD,CAAC;AAEH,eAAO,MAAM,2CAA2C,GACtD,UAAU,eAAe,KACxB,iCA4BD,CAAC;AA0BH,eAAO,MAAM,qCAAqC,GAAI,iBAAiB,eAAe,SAMrF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stream-chat-react-native-core",
|
|
3
3
|
"description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
|
|
4
|
-
"version": "9.10.2-beta.
|
|
4
|
+
"version": "9.10.2-beta.4",
|
|
5
5
|
"author": {
|
|
6
6
|
"company": "Stream.io Inc",
|
|
7
7
|
"name": "Stream.io Inc"
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
import { act, renderHook } from '@testing-library/react-native';
|
|
4
|
+
import { Poll, PollResponse, PollVote, StreamChat } from 'stream-chat';
|
|
5
|
+
|
|
6
|
+
import { ChatProvider } from '../../../../contexts/chatContext/ChatContext';
|
|
7
|
+
import { useChannelPreviewPollLabel } from '../useChannelPreviewPollLabel';
|
|
8
|
+
|
|
9
|
+
const OWN_USER = { id: 'own-user' };
|
|
10
|
+
const MESSAGE_ID = 'message-id';
|
|
11
|
+
const POLL_ID = 'poll-id';
|
|
12
|
+
|
|
13
|
+
const generateVote = (id: string, optionId: string, createdAt: string): PollVote => ({
|
|
14
|
+
created_at: createdAt,
|
|
15
|
+
id,
|
|
16
|
+
option_id: optionId,
|
|
17
|
+
poll_id: POLL_ID,
|
|
18
|
+
updated_at: createdAt,
|
|
19
|
+
user: OWN_USER,
|
|
20
|
+
user_id: OWN_USER.id,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const setup = (ownVotes: PollVote[]) => {
|
|
24
|
+
const client = {
|
|
25
|
+
removePollVote: jest.fn(() => new Promise(() => {})),
|
|
26
|
+
user: OWN_USER,
|
|
27
|
+
userID: OWN_USER.id,
|
|
28
|
+
} as unknown as StreamChat;
|
|
29
|
+
const latestVotesByOption: Record<string, PollVote[]> = {};
|
|
30
|
+
const voteCountsByOption: Record<string, number> = {};
|
|
31
|
+
ownVotes.forEach((vote) => {
|
|
32
|
+
latestVotesByOption[vote.option_id as string] = [vote];
|
|
33
|
+
voteCountsByOption[vote.option_id as string] = 1;
|
|
34
|
+
});
|
|
35
|
+
const poll = new Poll({
|
|
36
|
+
client,
|
|
37
|
+
poll: {
|
|
38
|
+
enforce_unique_vote: false,
|
|
39
|
+
id: POLL_ID,
|
|
40
|
+
latest_answers: [],
|
|
41
|
+
latest_votes_by_option: latestVotesByOption,
|
|
42
|
+
name: 'Poll',
|
|
43
|
+
options: [
|
|
44
|
+
{ id: 'option-a', text: 'A' },
|
|
45
|
+
{ id: 'option-b', text: 'B' },
|
|
46
|
+
],
|
|
47
|
+
own_votes: ownVotes,
|
|
48
|
+
vote_count: ownVotes.length,
|
|
49
|
+
vote_counts_by_option: voteCountsByOption,
|
|
50
|
+
} as unknown as PollResponse,
|
|
51
|
+
});
|
|
52
|
+
(client as unknown as { polls: unknown }).polls = { fromState: () => poll };
|
|
53
|
+
|
|
54
|
+
const wrapper = ({ children }: PropsWithChildren) => (
|
|
55
|
+
<ChatProvider value={{ client } as never}>{children}</ChatProvider>
|
|
56
|
+
);
|
|
57
|
+
const hook = renderHook(() => useChannelPreviewPollLabel({ pollId: POLL_ID }), { wrapper });
|
|
58
|
+
return { ...hook, poll };
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
describe('useChannelPreviewPollLabel', () => {
|
|
62
|
+
it('returns no label once the only vote is removed', () => {
|
|
63
|
+
const vote = generateVote('vote-a', 'option-a', '2026-10-27T10:00:00.000Z');
|
|
64
|
+
const { poll, result } = setup([vote]);
|
|
65
|
+
expect(result.current).toBe('You voted: {{ option }}');
|
|
66
|
+
|
|
67
|
+
act(() => {
|
|
68
|
+
poll.removeVote(vote.id, MESSAGE_ID);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
expect(result.current).toBeUndefined();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('labels the remaining latest vote once another option loses its only vote', () => {
|
|
75
|
+
const voteA = generateVote('vote-a', 'option-a', '2026-10-27T10:00:00.000Z');
|
|
76
|
+
const voteB = generateVote('vote-b', 'option-b', '2026-10-27T09:00:00.000Z');
|
|
77
|
+
const { poll, result } = setup([voteA, voteB]);
|
|
78
|
+
|
|
79
|
+
act(() => {
|
|
80
|
+
poll.removeVote(voteA.id, MESSAGE_ID);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(poll.data.latest_votes_by_option['option-a']).toEqual([]);
|
|
84
|
+
expect(result.current).toBe('You voted: {{ option }}');
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -31,7 +31,7 @@ export const useChannelPreviewPollLabel = ({ pollId }: UseChannelPreviewPollLabe
|
|
|
31
31
|
() =>
|
|
32
32
|
latestVotesByOption
|
|
33
33
|
? Object.values(latestVotesByOption)
|
|
34
|
-
.
|
|
34
|
+
.flatMap((votes) => votes?.[0] ?? [])
|
|
35
35
|
.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())
|
|
36
36
|
: [],
|
|
37
37
|
[latestVotesByOption],
|
|
@@ -63,6 +63,25 @@ describe('createAttachmentsCompositionMiddleware', () => {
|
|
|
63
63
|
expect(titles).toEqual(['finished-attachment', 'pending-attachment']);
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
+
it('keeps attachments that are not uploads as they are', () => {
|
|
67
|
+
// e.g. the attachments of an edited message that never went through an upload
|
|
68
|
+
const product = { title: 'Camp stove', type: 'product' };
|
|
69
|
+
const giphy = { thumb_url: 'https://media.giphy.com/cat.gif', title: 'cat', type: 'giphy' };
|
|
70
|
+
const { next } = runComposeHandler([
|
|
71
|
+
{ ...product, localMetadata: { id: 'product' } },
|
|
72
|
+
createLocalImageAttachment('finished-attachment', 'finished'),
|
|
73
|
+
{ ...giphy, localMetadata: { id: 'giphy' } },
|
|
74
|
+
] as LocalAttachment[]);
|
|
75
|
+
|
|
76
|
+
const composedState = next.mock.calls[0][0] as {
|
|
77
|
+
message: { attachments: { title?: string }[] };
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
expect(composedState.message.attachments[0]).toEqual(product);
|
|
81
|
+
expect(composedState.message.attachments[1].title).toBe('finished-attachment');
|
|
82
|
+
expect(composedState.message.attachments[2]).toEqual(giphy);
|
|
83
|
+
});
|
|
84
|
+
|
|
66
85
|
it('forwards without attachments when every attachment is blocked', () => {
|
|
67
86
|
const { forward, next } = runComposeHandler([
|
|
68
87
|
createLocalImageAttachment('blocked-1', 'blocked'),
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
AttachmentPreUploadMiddleware,
|
|
4
4
|
FileReference,
|
|
5
5
|
isLocalImageAttachment,
|
|
6
|
+
isLocalUploadAttachment,
|
|
6
7
|
isLocalVideoAttachment,
|
|
7
8
|
LocalAttachment,
|
|
8
9
|
MessageComposer,
|
|
@@ -18,6 +19,10 @@ import { isLocalUrl } from '../utils/utils';
|
|
|
18
19
|
export const localAttachmentToAttachment = (localAttachment: LocalAttachment) => {
|
|
19
20
|
const { localMetadata, ...attachment } = localAttachment;
|
|
20
21
|
|
|
22
|
+
// Not an upload (e.g. a custom or giphy attachment of an edited message), so there is no
|
|
23
|
+
// local file to point at.
|
|
24
|
+
if (!isLocalUploadAttachment(localAttachment)) return attachment as Attachment;
|
|
25
|
+
|
|
21
26
|
if (isLocalImageAttachment(localAttachment)) {
|
|
22
27
|
const isRemoteUri = !!attachment.image_url && !isLocalUrl(attachment.image_url);
|
|
23
28
|
|
package/src/version.json
CHANGED