@amityco/ts-sdk-react-native 6.32.2 → 6.32.3-89ca939.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.
- package/.env +26 -26
- package/dist/@types/core/events.d.ts +1 -1
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +1 -1
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +1 -1
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +1 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/channelRepository/api/createChannel.d.ts.map +1 -1
- package/dist/channelRepository/api/getChannel.d.ts.map +1 -1
- package/dist/channelRepository/api/getChannelByIds.d.ts.map +1 -1
- package/dist/channelRepository/api/updateChannel.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberQueryStreamController.d.ts +2 -2
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberQueryStreamController.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelCreated.d.ts +1 -1
- package/dist/channelRepository/events/onChannelCreated.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelDeleted.d.ts +1 -1
- package/dist/channelRepository/events/onChannelDeleted.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelFetched.d.ts +1 -1
- package/dist/channelRepository/events/onChannelFetched.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelJoined.d.ts +1 -1
- package/dist/channelRepository/events/onChannelJoined.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelLeft.d.ts +1 -1
- package/dist/channelRepository/events/onChannelLeft.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMemberAdded.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMemberAdded.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMemberBanned.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMemberBanned.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMemberRemoved.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMemberRemoved.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMemberRoleAdded.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMemberRoleAdded.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMemberRoleRemoved.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMemberRoleRemoved.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMemberUnbanned.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMemberUnbanned.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMuted.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMuted.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelResolved.d.ts +1 -1
- package/dist/channelRepository/events/onChannelResolved.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelUpdated.d.ts +1 -1
- package/dist/channelRepository/events/onChannelUpdated.d.ts.map +1 -1
- package/dist/channelRepository/events/onUserDeleted.d.ts +1 -1
- package/dist/channelRepository/events/onUserDeleted.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannels/ChannelQueryStreamController.d.ts +2 -2
- package/dist/channelRepository/observers/getChannels/ChannelQueryStreamController.d.ts.map +1 -1
- package/dist/channelRepository/observers/observeChannel.d.ts.map +1 -1
- package/dist/channelRepository/observers/observeChannels.d.ts.map +1 -1
- package/dist/channelRepository/utils/constructChannelDynamicValue.d.ts +2 -0
- package/dist/channelRepository/utils/constructChannelDynamicValue.d.ts.map +1 -0
- package/dist/channelRepository/utils/prepareChannelPayload.d.ts +1 -1
- package/dist/channelRepository/utils/prepareChannelPayload.d.ts.map +1 -1
- package/dist/channelRepository/utils/resolveUnreadInfoOnChannelEvent.d.ts +1 -1
- package/dist/channelRepository/utils/resolveUnreadInfoOnChannelEvent.d.ts.map +1 -1
- package/dist/client/utils/removeChannelMarkerCache.d.ts +1 -1
- package/dist/client/utils/removeChannelMarkerCache.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/utils.d.ts.map +1 -1
- package/dist/communityRepository/utils/communityWithMembership.d.ts.map +1 -1
- package/dist/index.cjs.js +157 -134
- package/dist/index.esm.js +157 -134
- package/dist/index.umd.js +3 -3
- package/dist/marker/events/onMessageMarked.d.ts.map +1 -1
- package/dist/marker/utils/reCalculateChannelUnreadInfo.d.ts.map +1 -1
- package/dist/marker/utils/updateSubChannelUnreadFromMessage.d.ts.map +1 -1
- package/dist/messageRepository/events/onMessageCreated.d.ts.map +1 -1
- package/dist/utils/linkedObject/channelLinkedObject.d.ts.map +1 -1
- package/dist/utils/shallowClone.d.ts +1 -1
- package/dist/utils/shallowClone.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/@types/core/events.ts +1 -1
- package/src/@types/core/model.ts +1 -1
- package/src/@types/core/payload.ts +1 -1
- package/src/@types/domains/channel.ts +5 -0
- package/src/channelRepository/api/createChannel.ts +2 -1
- package/src/channelRepository/api/getChannel.ts +4 -3
- package/src/channelRepository/api/getChannelByIds.ts +2 -1
- package/src/channelRepository/api/updateChannel.ts +2 -1
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberQueryStreamController.ts +2 -2
- package/src/channelRepository/events/onChannelCreated.ts +2 -2
- package/src/channelRepository/events/onChannelDeleted.ts +2 -2
- package/src/channelRepository/events/onChannelFetched.ts +3 -3
- package/src/channelRepository/events/onChannelJoined.ts +5 -2
- package/src/channelRepository/events/onChannelLeft.ts +5 -2
- package/src/channelRepository/events/onChannelMemberAdded.ts +5 -2
- package/src/channelRepository/events/onChannelMemberBanned.ts +5 -2
- package/src/channelRepository/events/onChannelMemberRemoved.ts +5 -2
- package/src/channelRepository/events/onChannelMemberRoleAdded.ts +5 -2
- package/src/channelRepository/events/onChannelMemberRoleRemoved.ts +5 -2
- package/src/channelRepository/events/onChannelMemberUnbanned.ts +5 -2
- package/src/channelRepository/events/onChannelMuted.ts +3 -2
- package/src/channelRepository/events/onChannelResolved.ts +2 -2
- package/src/channelRepository/events/onChannelUpdated.ts +2 -2
- package/src/channelRepository/events/onUserDeleted.ts +8 -2
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +11 -7
- package/src/channelRepository/observers/getChannels/ChannelQueryStreamController.ts +2 -2
- package/src/channelRepository/observers/observeChannel.ts +5 -4
- package/src/channelRepository/observers/observeChannels.ts +6 -4
- package/src/channelRepository/utils/constructChannelDynamicValue.ts +22 -0
- package/src/channelRepository/utils/prepareChannelPayload.ts +1 -13
- package/src/channelRepository/utils/resolveUnreadInfoOnChannelEvent.ts +2 -2
- package/src/channelRepository/utils/updateChannelCache.ts +1 -1
- package/src/client/utils/removeChannelMarkerCache.ts +1 -1
- package/src/communityRepository/communityMembership/events/utils.ts +4 -2
- package/src/communityRepository/utils/communityWithMembership.ts +15 -8
- package/src/marker/events/onMessageMarked.ts +0 -2
- package/src/marker/utils/reCalculateChannelUnreadInfo.ts +6 -0
- package/src/marker/utils/updateSubChannelUnreadFromMessage.ts +10 -0
- package/src/messageRepository/events/onMessageCreated.ts +2 -0
- package/src/subChannelRepository/utils/updateSubChannelCache.ts +1 -1
- package/src/utils/linkedObject/channelLinkedObject.ts +3 -3
- package/src/utils/shallowClone.ts +8 -5
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
onChannelMemberRemoved,
|
|
17
17
|
} from '../events';
|
|
18
18
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
19
|
+
import { constructChannelDynamicValue } from '../utils/constructChannelDynamicValue';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* ```js
|
|
@@ -43,25 +44,25 @@ export const observeChannel = <Events extends [Exclude<Amity.ChannelActionType,
|
|
|
43
44
|
log(`observeChannel(tmpid: ${timestamp}) > listen`);
|
|
44
45
|
|
|
45
46
|
// wrapper function to make sure
|
|
46
|
-
const router = (result: Amity.Snapshot<Amity.
|
|
47
|
+
const router = (result: Amity.Snapshot<Amity.StaticInternalChannel>, action: Events[number]) => {
|
|
47
48
|
// filter function
|
|
48
49
|
if (result.data?.channelId !== channelId) return;
|
|
49
50
|
|
|
50
51
|
if (callback instanceof Function)
|
|
51
52
|
return callback({
|
|
52
53
|
...result,
|
|
53
|
-
data: LinkedObject.channel(result.data),
|
|
54
|
+
data: LinkedObject.channel(constructChannelDynamicValue(result.data)),
|
|
54
55
|
});
|
|
55
56
|
|
|
56
57
|
if (action !== 'onFetch')
|
|
57
58
|
callback.onEvent?.(action, {
|
|
58
59
|
...result,
|
|
59
|
-
data: LinkedObject.channel(result.data),
|
|
60
|
+
data: LinkedObject.channel(constructChannelDynamicValue(result.data)),
|
|
60
61
|
});
|
|
61
62
|
|
|
62
63
|
callback[action]?.({
|
|
63
64
|
...result,
|
|
64
|
-
data: LinkedObject.channel(result.data),
|
|
65
|
+
data: LinkedObject.channel(constructChannelDynamicValue(result.data)),
|
|
65
66
|
});
|
|
66
67
|
};
|
|
67
68
|
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
onChannelMemberRemoved,
|
|
14
14
|
} from '../events';
|
|
15
15
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
16
|
+
import { constructChannelDynamicValue } from '../utils/constructChannelDynamicValue';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* ```js
|
|
@@ -40,13 +41,14 @@ export const observeChannels = (
|
|
|
40
41
|
const disposers: Amity.Unsubscriber[] = [];
|
|
41
42
|
|
|
42
43
|
const router = (
|
|
43
|
-
channel: Amity.
|
|
44
|
+
channel: Amity.StaticInternalChannel,
|
|
44
45
|
action: Exclude<Amity.ChannelActionType, 'onFetch'>,
|
|
45
46
|
) => {
|
|
46
|
-
if (callback instanceof Function)
|
|
47
|
+
if (callback instanceof Function)
|
|
48
|
+
return callback(LinkedObject.channel(constructChannelDynamicValue(channel)));
|
|
47
49
|
|
|
48
|
-
callback.onEvent?.(action, LinkedObject.channel(channel));
|
|
49
|
-
callback[action]?.(LinkedObject.channel(channel));
|
|
50
|
+
callback.onEvent?.(action, LinkedObject.channel(constructChannelDynamicValue(channel)));
|
|
51
|
+
callback[action]?.(LinkedObject.channel(constructChannelDynamicValue(channel)));
|
|
50
52
|
};
|
|
51
53
|
|
|
52
54
|
disposers.push(
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { shallowClone } from '~/utils/shallowClone';
|
|
2
|
+
import { getChannelIsMentioned } from './getChannelIsMentioned';
|
|
3
|
+
import { getSubChannelsUnreadCount } from './getSubChannelsUnreadCount';
|
|
4
|
+
|
|
5
|
+
export const constructChannelDynamicValue = (
|
|
6
|
+
channel: Amity.StaticInternalChannel,
|
|
7
|
+
): Amity.InternalChannel => {
|
|
8
|
+
return shallowClone(channel, {
|
|
9
|
+
get unreadCount() {
|
|
10
|
+
return getSubChannelsUnreadCount(channel);
|
|
11
|
+
},
|
|
12
|
+
get hasMentioned() {
|
|
13
|
+
return getChannelIsMentioned(channel);
|
|
14
|
+
},
|
|
15
|
+
get isMentioned() {
|
|
16
|
+
return getChannelIsMentioned(channel);
|
|
17
|
+
},
|
|
18
|
+
get subChannelsUnreadCount() {
|
|
19
|
+
return getSubChannelsUnreadCount(channel);
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
};
|
|
@@ -16,7 +16,7 @@ export const isUnreadCountSupport = ({ type }: Pick<Amity.RawChannel, 'type'>) =
|
|
|
16
16
|
export function convertFromRaw(
|
|
17
17
|
channel: Amity.RawChannel,
|
|
18
18
|
options: { isMessagePreviewUpdated?: boolean } = { isMessagePreviewUpdated: true },
|
|
19
|
-
): Amity.
|
|
19
|
+
): Amity.StaticInternalChannel {
|
|
20
20
|
let { messagePreviewId } = channel;
|
|
21
21
|
|
|
22
22
|
const messagePreviewChannelCache = pullFromCache<Amity.InternalMessagePreview>([
|
|
@@ -30,18 +30,6 @@ export function convertFromRaw(
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
return {
|
|
33
|
-
get unreadCount() {
|
|
34
|
-
return getSubChannelsUnreadCount(channel);
|
|
35
|
-
},
|
|
36
|
-
get hasMentioned() {
|
|
37
|
-
return getChannelIsMentioned(channel);
|
|
38
|
-
},
|
|
39
|
-
get isMentioned() {
|
|
40
|
-
return getChannelIsMentioned(channel);
|
|
41
|
-
},
|
|
42
|
-
get subChannelsUnreadCount() {
|
|
43
|
-
return getSubChannelsUnreadCount(channel);
|
|
44
|
-
},
|
|
45
33
|
...channel,
|
|
46
34
|
defaultSubChannelId: channel.channelInternalId,
|
|
47
35
|
isUnreadCountSupport: isUnreadCountSupport(channel),
|
|
@@ -2,8 +2,8 @@ import { getActiveClient } from '~/client/api/activeClient';
|
|
|
2
2
|
import ObjectResolverEngine from '~/client/utils/ObjectResolver/objectResolverEngine';
|
|
3
3
|
|
|
4
4
|
export const resolveUnreadInfoOnChannelEvent = (
|
|
5
|
-
channel: Amity.
|
|
6
|
-
callback: Amity.Listener<Amity.
|
|
5
|
+
channel: Amity.StaticInternalChannel,
|
|
6
|
+
callback: Amity.Listener<Amity.StaticInternalChannel>,
|
|
7
7
|
) => {
|
|
8
8
|
const client = getActiveClient();
|
|
9
9
|
|
|
@@ -5,6 +5,6 @@ export function updateChannelCache(channel: Amity.Channel, params: Partial<Amity
|
|
|
5
5
|
pushToCache(
|
|
6
6
|
['channel', 'get', channel.channelId],
|
|
7
7
|
// eslint-disable-next-line prefer-object-spread
|
|
8
|
-
|
|
8
|
+
shallowClone(channel, params),
|
|
9
9
|
);
|
|
10
10
|
}
|
|
@@ -3,7 +3,7 @@ import { getResolver } from '~/core/model';
|
|
|
3
3
|
|
|
4
4
|
import { getActiveUser } from '../api/activeUser';
|
|
5
5
|
|
|
6
|
-
export const removeChannelMarkerCache = (channel: Amity.
|
|
6
|
+
export const removeChannelMarkerCache = (channel: Amity.StaticInternalChannel) => {
|
|
7
7
|
const id = getResolver('channelMarker')({
|
|
8
8
|
userId: getActiveUser()._id,
|
|
9
9
|
entityId: channel.channelId,
|
|
@@ -73,7 +73,8 @@ export const createCommunityMemberEventSubscriber = (
|
|
|
73
73
|
// TODO: here we are missing specific properties here!
|
|
74
74
|
callback(preparedPayload.communities[0], getEventRelatedMember(event, preparedPayload));
|
|
75
75
|
} else {
|
|
76
|
-
|
|
76
|
+
// NOTE: The event payload should be merge with existing cache data
|
|
77
|
+
ingestInCache(preparedPayload, undefined, false);
|
|
77
78
|
|
|
78
79
|
const community = pullFromCache<Amity.Community>([
|
|
79
80
|
'community',
|
|
@@ -121,7 +122,8 @@ export const createLocalCommunityMemberEventSubscriber = (
|
|
|
121
122
|
// TODO: here we are missing specific properties here!
|
|
122
123
|
callback(preparedPayload.communities[0], getEventRelatedMember(event, preparedPayload));
|
|
123
124
|
} else {
|
|
124
|
-
|
|
125
|
+
// NOTE: The event payload should be merge with existing cache data
|
|
126
|
+
ingestInCache(preparedPayload, undefined, false);
|
|
125
127
|
|
|
126
128
|
const community = pullFromCache<Amity.Community>([
|
|
127
129
|
'community',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pullFromCache } from '~/cache/api';
|
|
1
2
|
import { getActiveUser } from '~/client';
|
|
2
3
|
|
|
3
4
|
/*
|
|
@@ -21,21 +22,27 @@ function isCurrentUserPartOfCommunity(
|
|
|
21
22
|
|
|
22
23
|
/*
|
|
23
24
|
* For mqtt events server will not send user specific data as it's broadcasted
|
|
24
|
-
* to multiple users
|
|
25
|
-
*
|
|
25
|
+
* to multiple users and it also does not include communityUser
|
|
26
|
+
*
|
|
27
|
+
* Client SDK needs to check for the existing isJoined field in cache data before calculating.
|
|
28
|
+
* Althought this can be calculated, it's not scalable.
|
|
26
29
|
*/
|
|
27
30
|
export function updateMembershipStatus(
|
|
28
31
|
communities: Amity.Community[],
|
|
29
32
|
communityUsers: Amity.Membership<'community'>[],
|
|
30
33
|
): Amity.Community[] {
|
|
31
34
|
return communities.map(c => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const cachedCommunity = pullFromCache<Amity.Community>(['community', 'get', c.communityId]);
|
|
36
|
+
if (cachedCommunity?.data && cachedCommunity?.data.hasOwnProperty('isJoined')) {
|
|
37
|
+
return {
|
|
38
|
+
...cachedCommunity.data,
|
|
39
|
+
...c,
|
|
40
|
+
};
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
|
|
43
|
+
const isJoined = communityUsers.some(
|
|
44
|
+
m => isCurrentUserPartOfCommunity(c, m) && isMember(m.communityMembership),
|
|
45
|
+
);
|
|
46
|
+
return { ...c, isJoined };
|
|
40
47
|
});
|
|
41
48
|
}
|
|
@@ -4,8 +4,6 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
4
4
|
import { getActiveClient } from '~/client/api/activeClient';
|
|
5
5
|
import { createEventSubscriber } from '~/core/events';
|
|
6
6
|
import { getResolver } from '~/core/model';
|
|
7
|
-
import { isObject } from '~/utils/object';
|
|
8
|
-
import { shallowClone } from '~/utils/shallowClone';
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
9
|
* ```js
|
|
@@ -6,6 +6,8 @@ export const reCalculateChannelUnreadInfo = (channelId: string): Amity.ChannelUn
|
|
|
6
6
|
const cacheChannelUnreadInfo =
|
|
7
7
|
pullFromCache<Amity.ChannelUnreadInfo>(cacheKeyChannelUnread)?.data;
|
|
8
8
|
|
|
9
|
+
console.log('[reCalculateChannelUnreadInfo] cacheChannelUnreadInfo => ', cacheChannelUnreadInfo);
|
|
10
|
+
|
|
9
11
|
const cacheKeySubChannelUnread = ['subChannelUnreadInfo', 'get'];
|
|
10
12
|
const cachedSubChannelUnreadInfo =
|
|
11
13
|
queryCache<Amity.SubChannelUnreadInfo>(cacheKeySubChannelUnread);
|
|
@@ -18,10 +20,14 @@ export const reCalculateChannelUnreadInfo = (channelId: string): Amity.ChannelUn
|
|
|
18
20
|
return data.channelId === channelId && !data.isDeleted;
|
|
19
21
|
});
|
|
20
22
|
|
|
23
|
+
console.log('[reCalculateChannelUnreadInfo] subChannelUnreadsInfo => ', subChannelUnreadsInfo);
|
|
24
|
+
|
|
21
25
|
channelUnreads = subChannelUnreadsInfo
|
|
22
26
|
.map(({ data }) => data.unreadCount)
|
|
23
27
|
.reduce((acc, cur) => acc + cur, 0);
|
|
24
28
|
|
|
29
|
+
console.log('[reCalculateChannelUnreadInfo] channelUnreads => ', channelUnreads);
|
|
30
|
+
|
|
25
31
|
isMentioned = subChannelUnreadsInfo.some(({ data }) => data.isMentioned);
|
|
26
32
|
}
|
|
27
33
|
|
|
@@ -6,6 +6,7 @@ export const updateSubChannelUnreadFromMessage = (message: Amity.RawMessage) =>
|
|
|
6
6
|
const cacheKeyUnreadCount = ['subChannelUnreadInfo', 'get', message.messageFeedId];
|
|
7
7
|
const cachedUnreadCount = pullFromCache<Amity.SubChannelUnreadInfo>(cacheKeyUnreadCount)?.data;
|
|
8
8
|
|
|
9
|
+
console.log('[updateSubChannelUnreadFromMessage] cachedUnreadCount => ', cachedUnreadCount);
|
|
9
10
|
if (!cachedUnreadCount) return;
|
|
10
11
|
|
|
11
12
|
const lastSegment =
|
|
@@ -15,6 +16,8 @@ export const updateSubChannelUnreadFromMessage = (message: Amity.RawMessage) =>
|
|
|
15
16
|
|
|
16
17
|
const unreadCount = lastSegment - cachedUnreadCount.readToSegment;
|
|
17
18
|
|
|
19
|
+
console.log('[updateSubChannelUnreadFromMessage] unreadCount => ', unreadCount);
|
|
20
|
+
|
|
18
21
|
let { lastMentionSegment } = cachedUnreadCount;
|
|
19
22
|
|
|
20
23
|
if (message.mentionedUsers && message.mentionedUsers.length > 0) {
|
|
@@ -36,5 +39,12 @@ export const updateSubChannelUnreadFromMessage = (message: Amity.RawMessage) =>
|
|
|
36
39
|
unreadCount: Math.max(unreadCount, 0),
|
|
37
40
|
};
|
|
38
41
|
|
|
42
|
+
console.log(
|
|
43
|
+
'[updateSubChannelUnreadFromMessage] updatedCachedUnreadCount => key',
|
|
44
|
+
cacheKeyUnreadCount,
|
|
45
|
+
'value =>',
|
|
46
|
+
updatedCachedUnreadCount,
|
|
47
|
+
);
|
|
48
|
+
|
|
39
49
|
pushToCache(cacheKeyUnreadCount, updatedCachedUnreadCount);
|
|
40
50
|
};
|
|
@@ -32,6 +32,8 @@ export const onMessageCreatedMqtt = (
|
|
|
32
32
|
const filter = async (rawPayload: Amity.MessagePayload) => {
|
|
33
33
|
const payload = await prepareMessagePayload(rawPayload);
|
|
34
34
|
|
|
35
|
+
console.log('onMessageCreatedMqtt', payload);
|
|
36
|
+
|
|
35
37
|
// update unreadCountInfo in cache
|
|
36
38
|
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
37
39
|
rawPayload.messages.forEach(message => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { markAsRead } from '~/channelRepository/api/markAsRead';
|
|
2
|
+
import { shallowClone } from '../shallowClone';
|
|
2
3
|
|
|
3
4
|
export const channelLinkedObject = (channel: Amity.InternalChannel): Amity.Channel => {
|
|
4
|
-
return {
|
|
5
|
-
...channel,
|
|
5
|
+
return shallowClone(channel, {
|
|
6
6
|
markAsRead: () => markAsRead(channel.channelInternalId),
|
|
7
|
-
};
|
|
7
|
+
});
|
|
8
8
|
};
|
|
@@ -12,9 +12,12 @@
|
|
|
12
12
|
* @category utility
|
|
13
13
|
* @private
|
|
14
14
|
*/
|
|
15
|
-
export function shallowClone(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
export function shallowClone(source: object, target: object) {
|
|
16
|
+
return Object.create(
|
|
17
|
+
Object.getPrototypeOf(source), // Use the prototype of the source object
|
|
18
|
+
{
|
|
19
|
+
...Object.getOwnPropertyDescriptors(source), // Copy all descriptors (methods, properties) from the source
|
|
20
|
+
...Object.getOwnPropertyDescriptors(target), // Merge/override with descriptors (getters, properties) from the target
|
|
21
|
+
},
|
|
22
|
+
);
|
|
20
23
|
}
|