@amityco/ts-sdk-react-native 6.32.4-a4e315c.0 → 6.32.5-2629e79.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/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/getChannel.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/index.cjs.js +138 -128
- package/dist/index.esm.js +138 -128
- package/dist/index.umd.js +3 -3
- package/dist/marker/events/onMessageMarked.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 +1 -1
- 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/getChannel.ts +4 -1
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +11 -9
- 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/marker/events/onMessageMarked.ts +0 -2
- package/src/subChannelRepository/utils/updateSubChannelCache.ts +1 -1
- package/src/utils/linkedObject/channelLinkedObject.ts +3 -3
- package/src/utils/shallowClone.ts +8 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onMessageMarked.d.ts","sourceRoot":"","sources":["../../../src/marker/events/onMessageMarked.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"onMessageMarked.d.ts","sourceRoot":"","sources":["../../../src/marker/events/onMessageMarked.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,aAChB,MAAM,QAAQ,CAAC,MAAM,aAAa,CAAC,KAC5C,MAAM,YAoER,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channelLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/channelLinkedObject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"channelLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/channelLinkedObject.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,YAAa,MAAM,eAAe,KAAG,MAAM,OAI1E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shallowClone.d.ts","sourceRoot":"","sources":["../../src/utils/shallowClone.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"shallowClone.d.ts","sourceRoot":"","sources":["../../src/utils/shallowClone.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAQ1D"}
|
package/package.json
CHANGED
|
@@ -199,7 +199,7 @@ declare global {
|
|
|
199
199
|
|
|
200
200
|
type LocalEvents = {
|
|
201
201
|
'local.channel.updated': MakeRequired<Amity.ProcessedChannelPayload, 'channels'>;
|
|
202
|
-
'local.channel.fetched': Amity.
|
|
202
|
+
'local.channel.fetched': Amity.StaticInternalChannel[];
|
|
203
203
|
'local.channel-moderator.role-added': Amity.ProcessedChannelPayload;
|
|
204
204
|
'local.channel-moderator.role-removed': Amity.ProcessedChannelPayload;
|
|
205
205
|
'local.message.created': MakeRequired<Amity.ProcessedMessagePayload, 'messages'>;
|
package/src/@types/core/model.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare global {
|
|
|
14
14
|
story: Amity.InternalStory;
|
|
15
15
|
storyTarget: Amity.RawStoryTarget;
|
|
16
16
|
|
|
17
|
-
channel: Amity.
|
|
17
|
+
channel: Amity.StaticInternalChannel;
|
|
18
18
|
subChannel: Amity.SubChannel;
|
|
19
19
|
channelUsers: Amity.Membership<'channel'>;
|
|
20
20
|
message: Amity.InternalMessage;
|
|
@@ -75,7 +75,7 @@ declare global {
|
|
|
75
75
|
ChannelPayload,
|
|
76
76
|
'channels' | 'channelUsers' | 'messagePreviews' | 'messageFeedsInfo' | 'users'
|
|
77
77
|
> & {
|
|
78
|
-
channels: Amity.
|
|
78
|
+
channels: Amity.StaticInternalChannel<T>[];
|
|
79
79
|
channelUsers: Amity.Membership<'channel'>[];
|
|
80
80
|
users: Amity.InternalUser[];
|
|
81
81
|
};
|
|
@@ -80,6 +80,11 @@ declare global {
|
|
|
80
80
|
subChannelsUnreadCount: number;
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
+
type StaticInternalChannel<T extends ChannelType = any> = Omit<
|
|
84
|
+
InternalChannel<T>,
|
|
85
|
+
'unreadCount' | 'subChannelsUnreadCount' | 'hasMentioned' | 'isMentioned'
|
|
86
|
+
>;
|
|
87
|
+
|
|
83
88
|
/* public type */
|
|
84
89
|
type Channel<T extends ChannelType = any> = Omit<
|
|
85
90
|
InternalChannel<T>,
|
|
@@ -3,6 +3,7 @@ import { getActiveClient } from '~/client/api';
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
|
|
5
5
|
import { prepareChannelPayload } from '../utils';
|
|
6
|
+
import { constructChannelDynamicValue } from '../utils/constructChannelDynamicValue';
|
|
6
7
|
|
|
7
8
|
/* begin_public_function
|
|
8
9
|
id: channel.create
|
|
@@ -52,7 +53,7 @@ export const createChannel = async <T extends Amity.ChannelType>(
|
|
|
52
53
|
|
|
53
54
|
const { channels } = data;
|
|
54
55
|
return {
|
|
55
|
-
data: channels[0],
|
|
56
|
+
data: constructChannelDynamicValue(channels[0]),
|
|
56
57
|
cachedAt,
|
|
57
58
|
};
|
|
58
59
|
};
|
|
@@ -9,6 +9,7 @@ import { pushToTombstone } from '~/cache/api/pushToTombstone';
|
|
|
9
9
|
|
|
10
10
|
import { prepareChannelPayload } from '../utils';
|
|
11
11
|
import { prepareUnreadCountInfo } from '../utils/prepateUnreadCountInfo';
|
|
12
|
+
import { constructChannelDynamicValue } from '../utils/constructChannelDynamicValue';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* ```js
|
|
@@ -59,7 +60,7 @@ export const getChannel = async (
|
|
|
59
60
|
const { channels } = data;
|
|
60
61
|
|
|
61
62
|
return {
|
|
62
|
-
data: channels.find(channel => channel.channelId === channelId)
|
|
63
|
+
data: constructChannelDynamicValue(channels.find(channel => channel.channelId === channelId)!),
|
|
63
64
|
cachedAt,
|
|
64
65
|
};
|
|
65
66
|
};
|
|
@@ -86,14 +87,14 @@ getChannel.locally = (
|
|
|
86
87
|
if (!client.cache) return;
|
|
87
88
|
|
|
88
89
|
// use queryCache to get all channel caches and filter by channelPublicId since we use channelPrivateId as cache key
|
|
89
|
-
const cached = queryCache<Amity.
|
|
90
|
+
const cached = queryCache<Amity.StaticInternalChannel>(['channel', 'get'])?.filter(({ data }) => {
|
|
90
91
|
return data.channelPublicId === channelId;
|
|
91
92
|
});
|
|
92
93
|
|
|
93
94
|
if (!cached || cached?.length === 0) return;
|
|
94
95
|
|
|
95
96
|
return {
|
|
96
|
-
data: cached[0].data,
|
|
97
|
+
data: constructChannelDynamicValue(cached[0].data),
|
|
97
98
|
cachedAt: cached[0].cachedAt,
|
|
98
99
|
};
|
|
99
100
|
};
|
|
@@ -9,6 +9,7 @@ import { prepareChannelPayload } from '../utils';
|
|
|
9
9
|
import { fireEvent } from '~/core/events';
|
|
10
10
|
import { prepareUnreadCountInfo } from '../utils/prepateUnreadCountInfo';
|
|
11
11
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
12
|
+
import { constructChannelDynamicValue } from '../utils/constructChannelDynamicValue';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* ```js
|
|
@@ -64,7 +65,7 @@ export const getChannelByIds = async (
|
|
|
64
65
|
fireEvent('local.channel.fetched', data.channels);
|
|
65
66
|
|
|
66
67
|
return {
|
|
67
|
-
data: data.channels.map(channel => LinkedObject.channel(channel)),
|
|
68
|
+
data: data.channels.map(channel => LinkedObject.channel(constructChannelDynamicValue(channel))),
|
|
68
69
|
cachedAt,
|
|
69
70
|
};
|
|
70
71
|
};
|
|
@@ -3,6 +3,7 @@ import { getActiveClient } from '~/client/api';
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
|
|
5
5
|
import { prepareChannelPayload } from '../utils';
|
|
6
|
+
import { constructChannelDynamicValue } from '../utils/constructChannelDynamicValue';
|
|
6
7
|
|
|
7
8
|
/* begin_public_function
|
|
8
9
|
id: channel.update
|
|
@@ -42,7 +43,7 @@ export const updateChannel = async (
|
|
|
42
43
|
const { channels } = data;
|
|
43
44
|
|
|
44
45
|
return {
|
|
45
|
-
data: channels.find(channel => channel.channelId === channelId)
|
|
46
|
+
data: constructChannelDynamicValue(channels.find(channel => channel.channelId === channelId)!),
|
|
46
47
|
cachedAt,
|
|
47
48
|
};
|
|
48
49
|
};
|
|
@@ -72,7 +72,7 @@ export class ChannelMemberQueryStreamController extends QueryStreamController<
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
reactor(action: string) {
|
|
75
|
-
return (channel: Amity.
|
|
75
|
+
return (channel: Amity.StaticInternalChannel, channelMember: Amity.Membership<'channel'>) => {
|
|
76
76
|
if (this.query.channelId !== channelMember.channelId) return;
|
|
77
77
|
|
|
78
78
|
const collection = pullFromCache<Amity.ChannelMembersLiveCollectionCache>(
|
|
@@ -100,7 +100,7 @@ export class ChannelMemberQueryStreamController extends QueryStreamController<
|
|
|
100
100
|
createSubscriber: {
|
|
101
101
|
fn: (
|
|
102
102
|
reactor: (
|
|
103
|
-
channel: Amity.
|
|
103
|
+
channel: Amity.StaticInternalChannel,
|
|
104
104
|
channelMember: Amity.Membership<'channel'>,
|
|
105
105
|
) => void,
|
|
106
106
|
) => Amity.Unsubscriber;
|
|
@@ -5,7 +5,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
5
5
|
|
|
6
6
|
import { prepareChannelPayload } from '../utils';
|
|
7
7
|
|
|
8
|
-
type CallbackFn = (channel: Amity.
|
|
8
|
+
type CallbackFn = (channel: Amity.StaticInternalChannel) => void;
|
|
9
9
|
const callbacks: CallbackFn[] = [];
|
|
10
10
|
let mainDisposer: (() => void) | null = null;
|
|
11
11
|
|
|
@@ -19,7 +19,7 @@ const dispose = (cb: CallbackFn) => {
|
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export const onChannelCreated = (callback: Amity.Listener<Amity.
|
|
22
|
+
export const onChannelCreated = (callback: Amity.Listener<Amity.StaticInternalChannel>) => {
|
|
23
23
|
if (callbacks.length === 0) {
|
|
24
24
|
const client = getActiveClient();
|
|
25
25
|
|
|
@@ -7,7 +7,7 @@ import { prepareChannelPayload } from '../utils/prepareChannelPayload';
|
|
|
7
7
|
import { addFlagIsDeletedSubChannelUnreadByChannelId } from '~/marker/utils/addFlagIsDeletedSubChannelUnreadByChannelId';
|
|
8
8
|
import { deleteChannelUnreadByChannelId } from '../../marker/utils/deleteChannelUnreadByChannelId';
|
|
9
9
|
|
|
10
|
-
type CallbackFn = (channel: Amity.
|
|
10
|
+
type CallbackFn = (channel: Amity.StaticInternalChannel) => void;
|
|
11
11
|
const callbacks: CallbackFn[] = [];
|
|
12
12
|
let mainDisposer: (() => void) | null = null;
|
|
13
13
|
|
|
@@ -21,7 +21,7 @@ const dispose = (cb: CallbackFn) => {
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export const onChannelDeleted = (callback: Amity.Listener<Amity.
|
|
24
|
+
export const onChannelDeleted = (callback: Amity.Listener<Amity.StaticInternalChannel>) => {
|
|
25
25
|
if (callbacks.length === 0) {
|
|
26
26
|
const client = getActiveClient();
|
|
27
27
|
|
|
@@ -2,7 +2,7 @@ import { createEventSubscriber } from '~/core/events';
|
|
|
2
2
|
|
|
3
3
|
import { getActiveClient } from '~/client/api/activeClient';
|
|
4
4
|
|
|
5
|
-
type CallbackFn = (channel: Amity.
|
|
5
|
+
type CallbackFn = (channel: Amity.StaticInternalChannel[]) => void;
|
|
6
6
|
const callbacks: CallbackFn[] = [];
|
|
7
7
|
let mainDisposer: (() => void) | null = null;
|
|
8
8
|
|
|
@@ -16,11 +16,11 @@ const dispose = (cb: CallbackFn) => {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export const onChannelFetched = (callback: Amity.Listener<Amity.
|
|
19
|
+
export const onChannelFetched = (callback: Amity.Listener<Amity.StaticInternalChannel[]>) => {
|
|
20
20
|
if (callbacks.length === 0) {
|
|
21
21
|
const client = getActiveClient();
|
|
22
22
|
|
|
23
|
-
const filter = async (payload: Amity.
|
|
23
|
+
const filter = async (payload: Amity.StaticInternalChannel[]) => {
|
|
24
24
|
callbacks.forEach(cb => cb(payload));
|
|
25
25
|
};
|
|
26
26
|
|
|
@@ -5,7 +5,10 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
5
5
|
|
|
6
6
|
import { prepareChannelPayload } from '../utils';
|
|
7
7
|
|
|
8
|
-
type CallbackFn = (
|
|
8
|
+
type CallbackFn = (
|
|
9
|
+
channel: Amity.StaticInternalChannel,
|
|
10
|
+
member: Amity.Membership<'channel'>,
|
|
11
|
+
) => void;
|
|
9
12
|
const callbacks: CallbackFn[] = [];
|
|
10
13
|
let mainDisposer: (() => void) | null = null;
|
|
11
14
|
|
|
@@ -20,7 +23,7 @@ const dispose = (cb: CallbackFn) => {
|
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
export const onChannelJoined = (
|
|
23
|
-
callback: (channel: Amity.
|
|
26
|
+
callback: (channel: Amity.StaticInternalChannel, member: Amity.Membership<'channel'>) => void,
|
|
24
27
|
) => {
|
|
25
28
|
if (callbacks.length === 0) {
|
|
26
29
|
const client = getActiveClient();
|
|
@@ -7,7 +7,10 @@ import { prepareChannelPayload } from '../utils';
|
|
|
7
7
|
import { deleteChannelUnreadByChannelId } from '../../marker/utils/deleteChannelUnreadByChannelId';
|
|
8
8
|
import { addFlagIsDeletedSubChannelUnreadByChannelId } from '~/marker/utils/addFlagIsDeletedSubChannelUnreadByChannelId';
|
|
9
9
|
|
|
10
|
-
type CallbackFn = (
|
|
10
|
+
type CallbackFn = (
|
|
11
|
+
channel: Amity.StaticInternalChannel,
|
|
12
|
+
member: Amity.Membership<'channel'>,
|
|
13
|
+
) => void;
|
|
11
14
|
const callbacks: CallbackFn[] = [];
|
|
12
15
|
let mainDisposer: (() => void) | null = null;
|
|
13
16
|
|
|
@@ -22,7 +25,7 @@ const dispose = (cb: CallbackFn) => {
|
|
|
22
25
|
};
|
|
23
26
|
|
|
24
27
|
export const onChannelLeft = (
|
|
25
|
-
callback: (channel: Amity.
|
|
28
|
+
callback: (channel: Amity.StaticInternalChannel, member: Amity.Membership<'channel'>) => void,
|
|
26
29
|
) => {
|
|
27
30
|
if (callbacks.length === 0) {
|
|
28
31
|
const client = getActiveClient();
|
|
@@ -4,7 +4,10 @@ import { createEventSubscriber } from '~/core/events';
|
|
|
4
4
|
|
|
5
5
|
import { prepareChannelPayload } from '../utils';
|
|
6
6
|
|
|
7
|
-
type CallbackFn = (
|
|
7
|
+
type CallbackFn = (
|
|
8
|
+
channel: Amity.StaticInternalChannel,
|
|
9
|
+
member: Amity.Membership<'channel'>,
|
|
10
|
+
) => void;
|
|
8
11
|
const callbacks: CallbackFn[] = [];
|
|
9
12
|
let mainDisposer: (() => void) | null = null;
|
|
10
13
|
|
|
@@ -19,7 +22,7 @@ const dispose = (cb: CallbackFn) => {
|
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
export const onChannelMemberAdded = (
|
|
22
|
-
callback: (channel: Amity.
|
|
25
|
+
callback: (channel: Amity.StaticInternalChannel, member: Amity.Membership<'channel'>) => void,
|
|
23
26
|
): Amity.Unsubscriber => {
|
|
24
27
|
if (callbacks.length === 0) {
|
|
25
28
|
const client = getActiveClient();
|
|
@@ -7,7 +7,10 @@ import { prepareChannelPayload } from '../utils';
|
|
|
7
7
|
import { addFlagIsDeletedSubChannelUnreadByChannelId } from '~/marker/utils/addFlagIsDeletedSubChannelUnreadByChannelId';
|
|
8
8
|
import { deleteChannelUnreadByChannelId } from '../../marker/utils/deleteChannelUnreadByChannelId';
|
|
9
9
|
|
|
10
|
-
type CallbackFn = (
|
|
10
|
+
type CallbackFn = (
|
|
11
|
+
channel: Amity.StaticInternalChannel,
|
|
12
|
+
member: Amity.Membership<'channel'>,
|
|
13
|
+
) => void;
|
|
11
14
|
const callbacks: CallbackFn[] = [];
|
|
12
15
|
let mainDisposer: (() => void) | null = null;
|
|
13
16
|
|
|
@@ -22,7 +25,7 @@ const dispose = (cb: CallbackFn) => {
|
|
|
22
25
|
};
|
|
23
26
|
|
|
24
27
|
export const onChannelMemberBanned = (
|
|
25
|
-
callback: (channel: Amity.
|
|
28
|
+
callback: (channel: Amity.StaticInternalChannel, member: Amity.Membership<'channel'>) => void,
|
|
26
29
|
) => {
|
|
27
30
|
const client = getActiveClient();
|
|
28
31
|
|
|
@@ -5,7 +5,10 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
5
5
|
|
|
6
6
|
import { prepareChannelPayload } from '../utils';
|
|
7
7
|
|
|
8
|
-
type CallbackFn = (
|
|
8
|
+
type CallbackFn = (
|
|
9
|
+
channel: Amity.StaticInternalChannel,
|
|
10
|
+
member: Amity.Membership<'channel'>,
|
|
11
|
+
) => void;
|
|
9
12
|
const callbacks: CallbackFn[] = [];
|
|
10
13
|
let mainDisposer: (() => void) | null = null;
|
|
11
14
|
|
|
@@ -20,7 +23,7 @@ const dispose = (cb: CallbackFn) => {
|
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
export const onChannelMemberRemoved = (
|
|
23
|
-
callback: (channel: Amity.
|
|
26
|
+
callback: (channel: Amity.StaticInternalChannel, member: Amity.Membership<'channel'>) => void,
|
|
24
27
|
) => {
|
|
25
28
|
if (callbacks.length === 0) {
|
|
26
29
|
const client = getActiveClient();
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
2
|
import { createEventSubscriber } from '~/core/events';
|
|
3
3
|
|
|
4
|
-
type CallbackFn = (
|
|
4
|
+
type CallbackFn = (
|
|
5
|
+
channel: Amity.StaticInternalChannel,
|
|
6
|
+
member: Amity.Membership<'channel'>,
|
|
7
|
+
) => void;
|
|
5
8
|
const callbacks: CallbackFn[] = [];
|
|
6
9
|
let mainDisposer: (() => void) | null = null;
|
|
7
10
|
|
|
@@ -16,7 +19,7 @@ const dispose = (cb: CallbackFn) => {
|
|
|
16
19
|
};
|
|
17
20
|
|
|
18
21
|
export const onChannelMemberRoleAdded = (
|
|
19
|
-
callback: (channel: Amity.
|
|
22
|
+
callback: (channel: Amity.StaticInternalChannel, member: Amity.Membership<'channel'>) => void,
|
|
20
23
|
): Amity.Unsubscriber => {
|
|
21
24
|
if (callbacks.length === 0) {
|
|
22
25
|
const client = getActiveClient();
|
|
@@ -4,7 +4,10 @@ import { createEventSubscriber } from '~/core/events';
|
|
|
4
4
|
|
|
5
5
|
import { prepareChannelPayload } from '../utils';
|
|
6
6
|
|
|
7
|
-
type CallbackFn = (
|
|
7
|
+
type CallbackFn = (
|
|
8
|
+
channel: Amity.StaticInternalChannel,
|
|
9
|
+
member: Amity.Membership<'channel'>,
|
|
10
|
+
) => void;
|
|
8
11
|
const callbacks: CallbackFn[] = [];
|
|
9
12
|
let mainDisposer: (() => void) | null = null;
|
|
10
13
|
|
|
@@ -19,7 +22,7 @@ const dispose = (cb: CallbackFn) => {
|
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
export const onChannelMemberRoleRemoved = (
|
|
22
|
-
callback: (channel: Amity.
|
|
25
|
+
callback: (channel: Amity.StaticInternalChannel, member: Amity.Membership<'channel'>) => void,
|
|
23
26
|
): Amity.Unsubscriber => {
|
|
24
27
|
if (callbacks.length === 0) {
|
|
25
28
|
const client = getActiveClient();
|
|
@@ -5,7 +5,10 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
5
5
|
|
|
6
6
|
import { prepareChannelPayload } from '../utils';
|
|
7
7
|
|
|
8
|
-
type CallbackFn = (
|
|
8
|
+
type CallbackFn = (
|
|
9
|
+
channel: Amity.StaticInternalChannel,
|
|
10
|
+
member: Amity.Membership<'channel'>,
|
|
11
|
+
) => void;
|
|
9
12
|
const callbacks: CallbackFn[] = [];
|
|
10
13
|
let mainDisposer: (() => void) | null = null;
|
|
11
14
|
|
|
@@ -20,7 +23,7 @@ const dispose = (cb: CallbackFn) => {
|
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
export const onChannelMemberUnbanned = (
|
|
23
|
-
callback: (channel: Amity.
|
|
26
|
+
callback: (channel: Amity.StaticInternalChannel, member: Amity.Membership<'channel'>) => void,
|
|
24
27
|
) => {
|
|
25
28
|
if (callbacks.length === 0) {
|
|
26
29
|
const client = getActiveClient();
|
|
@@ -4,8 +4,9 @@ import { createEventSubscriber } from '~/core/events';
|
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
5
|
|
|
6
6
|
import { prepareChannelPayload } from '../utils';
|
|
7
|
+
import { constructChannelDynamicValue } from '../utils/constructChannelDynamicValue';
|
|
7
8
|
|
|
8
|
-
type CallbackFn = Amity.Listener<Amity.
|
|
9
|
+
type CallbackFn = Amity.Listener<Amity.StaticInternalChannel>;
|
|
9
10
|
const callbacks: CallbackFn[] = [];
|
|
10
11
|
let mainDisposer: (() => void) | null = null;
|
|
11
12
|
|
|
@@ -19,7 +20,7 @@ const dispose = (cb: CallbackFn) => {
|
|
|
19
20
|
}
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
export const onChannelMuted = (callback: Amity.Listener<Amity.
|
|
23
|
+
export const onChannelMuted = (callback: Amity.Listener<Amity.StaticInternalChannel>) => {
|
|
23
24
|
if (callbacks.length === 0) {
|
|
24
25
|
const client = getActiveClient();
|
|
25
26
|
|
|
@@ -11,10 +11,10 @@ import { createEventSubscriber } from '~/core/events';
|
|
|
11
11
|
*
|
|
12
12
|
* @category Channel Events
|
|
13
13
|
*/
|
|
14
|
-
export const onChannelResolved = (callback: Amity.Listener<Amity.
|
|
14
|
+
export const onChannelResolved = (callback: Amity.Listener<Amity.StaticInternalChannel[]>) => {
|
|
15
15
|
const client = getActiveClient();
|
|
16
16
|
|
|
17
|
-
const filter = async (payload: Amity.
|
|
17
|
+
const filter = async (payload: Amity.StaticInternalChannel[]) => {
|
|
18
18
|
callback(payload);
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -4,7 +4,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
4
4
|
|
|
5
5
|
import { prepareChannelPayload } from '../utils';
|
|
6
6
|
|
|
7
|
-
type CallbackFn = Amity.Listener<Amity.
|
|
7
|
+
type CallbackFn = Amity.Listener<Amity.StaticInternalChannel>;
|
|
8
8
|
const callbacks: CallbackFn[] = [];
|
|
9
9
|
const mainDisposers: (() => void)[] = [];
|
|
10
10
|
|
|
@@ -18,7 +18,7 @@ const dispose = (cb: CallbackFn) => {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const onChannelUpdated = (callback: Amity.Listener<Amity.
|
|
21
|
+
export const onChannelUpdated = (callback: Amity.Listener<Amity.StaticInternalChannel>) => {
|
|
22
22
|
const client = getActiveClient();
|
|
23
23
|
|
|
24
24
|
if (callbacks.length === 0) {
|
|
@@ -7,7 +7,9 @@ import { getResolver } from '~/core/model';
|
|
|
7
7
|
|
|
8
8
|
export const onUserDeleted =
|
|
9
9
|
(channelId: string) =>
|
|
10
|
-
(
|
|
10
|
+
(
|
|
11
|
+
callback: (channel: Amity.StaticInternalChannel, member: Amity.Membership<'channel'>) => void,
|
|
12
|
+
) => {
|
|
11
13
|
const client = getActiveClient();
|
|
12
14
|
|
|
13
15
|
const filter = (payload: Amity.UserPayload) => {
|
|
@@ -35,7 +37,11 @@ export const onUserDeleted =
|
|
|
35
37
|
user,
|
|
36
38
|
});
|
|
37
39
|
|
|
38
|
-
const channel = pullFromCache<Amity.
|
|
40
|
+
const channel = pullFromCache<Amity.StaticInternalChannel>([
|
|
41
|
+
'channel',
|
|
42
|
+
'get',
|
|
43
|
+
channelId,
|
|
44
|
+
])?.data;
|
|
39
45
|
|
|
40
46
|
if (!channel) return;
|
|
41
47
|
|
|
@@ -35,6 +35,7 @@ import { onChannelMarkerUpdated } from '~/marker/events/onChannelMarkerUpdated';
|
|
|
35
35
|
import { onSubChannelCreated } from '~/subChannelRepository';
|
|
36
36
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
37
37
|
import { onChannelUnreadUpdatedLocal } from '~/marker/events/onChannelUnreadUpdatedLocal';
|
|
38
|
+
import { constructChannelDynamicValue } from '../utils/constructChannelDynamicValue';
|
|
38
39
|
|
|
39
40
|
/* begin_public_function
|
|
40
41
|
id: channel.get
|
|
@@ -73,7 +74,9 @@ export const getChannel = (
|
|
|
73
74
|
|
|
74
75
|
const data = {
|
|
75
76
|
...response,
|
|
76
|
-
data: LinkedObject.channel(
|
|
77
|
+
data: LinkedObject.channel(
|
|
78
|
+
constructChannelDynamicValue(getChannelMessagePreviewWithUser(response.data)),
|
|
79
|
+
),
|
|
77
80
|
};
|
|
78
81
|
|
|
79
82
|
const { origin, ...newSnapshot } = data;
|
|
@@ -57,6 +57,7 @@ import { onChannelResolved } from '~/channelRepository/events/onChannelResolved'
|
|
|
57
57
|
import { onUserMessageFeedMarkerResolved } from '~/marker/events/onUserMessageFeedMarkerResolved';
|
|
58
58
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
59
59
|
import { onChannelUnreadUpdatedLocal } from '~/marker/events/onChannelUnreadUpdatedLocal';
|
|
60
|
+
import { constructChannelDynamicValue } from '~/channelRepository/utils/constructChannelDynamicValue';
|
|
60
61
|
|
|
61
62
|
export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
62
63
|
'channel',
|
|
@@ -138,6 +139,7 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
|
138
139
|
.filter(Boolean)
|
|
139
140
|
.map(({ data }) => data)
|
|
140
141
|
.map(getChannelMessagePreviewWithUser)
|
|
142
|
+
.map(constructChannelDynamicValue)
|
|
141
143
|
.map(LinkedObject.channel) ?? [];
|
|
142
144
|
|
|
143
145
|
if (this.paginationController instanceof ChannelPaginationController) {
|
|
@@ -267,7 +269,7 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
|
267
269
|
}
|
|
268
270
|
});
|
|
269
271
|
},
|
|
270
|
-
'
|
|
272
|
+
'channelId',
|
|
271
273
|
'channel',
|
|
272
274
|
),
|
|
273
275
|
action: Amity.ChannelActionType.OnUpdate,
|
|
@@ -291,7 +293,7 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
|
291
293
|
callback(message);
|
|
292
294
|
});
|
|
293
295
|
},
|
|
294
|
-
'
|
|
296
|
+
'channelId',
|
|
295
297
|
'channel',
|
|
296
298
|
),
|
|
297
299
|
action: Amity.ChannelActionType.OnUpdate,
|
|
@@ -300,7 +302,7 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
|
300
302
|
{ fn: onChannelUpdated, action: Amity.ChannelActionType.OnUpdate },
|
|
301
303
|
{ fn: onChannelMuted, action: Amity.ChannelActionType.OnMute },
|
|
302
304
|
{
|
|
303
|
-
fn: (callback: Amity.Listener<Amity.
|
|
305
|
+
fn: (callback: Amity.Listener<Amity.StaticInternalChannel>) => {
|
|
304
306
|
return onChannelJoined(channel => {
|
|
305
307
|
resolveUnreadInfoOnChannelEvent(channel, callback);
|
|
306
308
|
});
|
|
@@ -308,9 +310,9 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
|
308
310
|
action: Amity.ChannelActionType.OnJoin,
|
|
309
311
|
},
|
|
310
312
|
{
|
|
311
|
-
fn: (reactor: Amity.Listener<Amity.
|
|
313
|
+
fn: (reactor: Amity.Listener<Amity.StaticInternalChannel>) => {
|
|
312
314
|
const callback = (
|
|
313
|
-
channel: Amity.
|
|
315
|
+
channel: Amity.StaticInternalChannel,
|
|
314
316
|
member: Amity.Membership<'channel'>,
|
|
315
317
|
) => {
|
|
316
318
|
const { userId } = getActiveClient();
|
|
@@ -527,7 +529,7 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
|
527
529
|
action: Amity.ChannelActionType.OnResolve,
|
|
528
530
|
},
|
|
529
531
|
{
|
|
530
|
-
fn: (callback: Amity.Listener<Amity.
|
|
532
|
+
fn: (callback: Amity.Listener<Amity.StaticInternalChannel[]>) => {
|
|
531
533
|
const handleUserFeedMarkerResolved = async (
|
|
532
534
|
marker: Amity.UserMessageFeedMarkerPayload,
|
|
533
535
|
) => {
|
|
@@ -539,9 +541,9 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
|
539
541
|
const channels = channelIds
|
|
540
542
|
.map(
|
|
541
543
|
channelId =>
|
|
542
|
-
pullFromCache<Amity.
|
|
544
|
+
pullFromCache<Amity.StaticInternalChannel>(['channel', 'get', channelId])?.data,
|
|
543
545
|
)
|
|
544
|
-
.filter(Boolean) as Amity.
|
|
546
|
+
.filter(Boolean) as Amity.StaticInternalChannel[];
|
|
545
547
|
|
|
546
548
|
callback(channels);
|
|
547
549
|
}
|
|
@@ -560,7 +562,7 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
|
560
562
|
return [
|
|
561
563
|
...subscriptions,
|
|
562
564
|
{
|
|
563
|
-
fn: (callback: Amity.Listener<Amity.
|
|
565
|
+
fn: (callback: Amity.Listener<Amity.StaticInternalChannel>) => {
|
|
564
566
|
return onChannelCreated(channel => {
|
|
565
567
|
resolveUnreadInfoOnChannelEvent(channel, callback);
|
|
566
568
|
});
|
|
@@ -65,7 +65,7 @@ export class ChannelQueryStreamController extends QueryStreamController<
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
reactor(action: Amity.ChannelActionType) {
|
|
68
|
-
return (payload: Amity.
|
|
68
|
+
return (payload: Amity.StaticInternalChannel | Amity.StaticInternalChannel[]) => {
|
|
69
69
|
const collection = pullFromCache<Amity.ChannelLiveCollectionCache>(this.cacheKey)?.data;
|
|
70
70
|
if (!collection) return;
|
|
71
71
|
|
|
@@ -94,7 +94,7 @@ export class ChannelQueryStreamController extends QueryStreamController<
|
|
|
94
94
|
subscribeRTE(
|
|
95
95
|
createSubscriber: {
|
|
96
96
|
fn: (
|
|
97
|
-
reactor: Amity.Listener<Amity.
|
|
97
|
+
reactor: Amity.Listener<Amity.StaticInternalChannel | Amity.StaticInternalChannel[]>,
|
|
98
98
|
) => Amity.Unsubscriber;
|
|
99
99
|
action: Amity.ChannelActionType;
|
|
100
100
|
}[],
|