@amityco/ts-sdk 6.7.3-cbeeb97.0 → 6.7.3-cf5eee7.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMessages.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/observers/getMessages.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getMessages.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/observers/getMessages.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW,WACd,MAAM,sBAAsB,YAC1B,MAAM,sBAAsB,CAAC,MAAM,OAAO,CAAC,WAC5C,MAAM,oBAAoB,KAClC,MAAM,YAwHR,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import { getActiveClient } from '~/client/api';
|
|
|
4
4
|
import { dropFromCache, pullFromCache, pushToCache } from '~/cache/api';
|
|
5
5
|
import { createQuery, filterByPropEquality, queryOptions, runQuery } from '~/core/query';
|
|
6
6
|
import { onMessageMarked, onMessageMarkerFetched } from '~/marker/events';
|
|
7
|
+
import { uuid } from '~/core/uuid';
|
|
7
8
|
|
|
8
9
|
import {
|
|
9
10
|
COLLECTION_DEFAULT_CACHING_POLICY,
|
|
@@ -68,13 +69,20 @@ export const getMessages = (
|
|
|
68
69
|
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config ?? {};
|
|
69
70
|
|
|
70
71
|
const disposers: Amity.Unsubscriber[] = [];
|
|
71
|
-
const cacheKey = ['message', 'collection', params];
|
|
72
|
+
const cacheKey = ['message', 'collection', params, uuid()];
|
|
72
73
|
|
|
73
74
|
const responder = (data: Amity.MessageLiveCollectionCache) => {
|
|
74
75
|
let messages: Amity.Message[] =
|
|
75
76
|
data.data
|
|
76
77
|
.map(messageId => pullFromCache<Amity.Message>(['message', 'get', messageId])!)
|
|
77
78
|
.filter(Boolean)
|
|
79
|
+
.filter(item => {
|
|
80
|
+
if (!params.tags) return true;
|
|
81
|
+
return params.tags.find(value => {
|
|
82
|
+
if (!item.data?.tags) return false;
|
|
83
|
+
return item.data.tags.includes(value);
|
|
84
|
+
});
|
|
85
|
+
})
|
|
78
86
|
.map(({ data }) => data) ?? [];
|
|
79
87
|
|
|
80
88
|
/*
|
|
@@ -94,13 +102,15 @@ export const getMessages = (
|
|
|
94
102
|
});
|
|
95
103
|
};
|
|
96
104
|
|
|
97
|
-
const realtimeRouter = (
|
|
105
|
+
const realtimeRouter = (action: Amity.MessageActionType) => (message: Amity.Message) => {
|
|
98
106
|
const collection = pullFromCache<Amity.MessageLiveCollectionCache>(cacheKey)?.data;
|
|
99
107
|
|
|
100
108
|
if (params.subChannelId !== message?.subChannelId || !collection) return;
|
|
101
109
|
|
|
102
|
-
if (!
|
|
103
|
-
collection.data
|
|
110
|
+
if (!['onFetched', 'onUpdate'].includes(action)) {
|
|
111
|
+
if (!collection.data.includes(message.messageId)) {
|
|
112
|
+
collection.data = [...new Set([message.messageId, ...collection.data])];
|
|
113
|
+
}
|
|
104
114
|
}
|
|
105
115
|
|
|
106
116
|
pushToCache(cacheKey, collection);
|