@amityco/ts-sdk-react-native 7.0.1-91b5585.0 → 7.0.2-3cbb4fc.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/linkPreview.d.ts +12 -0
- package/dist/@types/core/linkPreview.d.ts.map +1 -0
- package/dist/@types/domains/client.d.ts +0 -1
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/client/api/createClient.d.ts.map +1 -1
- package/dist/client/api/fetchLinkPreview.d.ts +14 -0
- package/dist/client/api/fetchLinkPreview.d.ts.map +1 -0
- package/dist/client/api/index.d.ts +1 -0
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/core/model/index.d.ts +0 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/index.cjs.js +48 -122
- package/dist/index.esm.js +48 -122
- package/dist/index.umd.js +3 -3
- package/dist/messageRepository/api/createMessage.d.ts.map +1 -1
- package/dist/messageRepository/utils/getMessageFromMainDB.d.ts.map +1 -1
- package/dist/messageRepository/utils/index.d.ts +0 -1
- package/dist/messageRepository/utils/index.d.ts.map +1 -1
- package/dist/messageRepository/utils/prepareMessagePayload.d.ts.map +1 -1
- package/dist/utils/event.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/linkPreview.ts +12 -0
- package/src/@types/domains/client.ts +0 -2
- package/src/client/api/createClient.ts +0 -26
- package/src/client/api/fetchLinkPreview.ts +30 -0
- package/src/client/api/index.ts +1 -0
- package/src/core/model/index.ts +0 -1
- package/src/messageRepository/api/createMessage.ts +0 -7
- package/src/messageRepository/observers/getMessages/MessageQueryStreamController.ts +4 -4
- package/src/messageRepository/utils/getMessageFromMainDB.ts +5 -9
- package/src/messageRepository/utils/index.ts +0 -1
- package/src/messageRepository/utils/prepareMessagePayload.ts +17 -22
- package/src/utils/event.ts +2 -19
- package/dist/core/model/localReferenceId.d.ts +0 -2
- package/dist/core/model/localReferenceId.d.ts.map +0 -1
- package/dist/messageRepository/utils/getMessageIdentifierIds.d.ts +0 -2
- package/dist/messageRepository/utils/getMessageIdentifierIds.d.ts.map +0 -1
- package/src/core/model/localReferenceId.ts +0 -12
- package/src/messageRepository/utils/getMessageIdentifierIds.ts +0 -37
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkPreview.d.ts","sourceRoot":"","sources":["../../../src/@types/core/linkPreview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,WAAW,GAAG;YACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;YACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;YAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;YACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;SACtB,CAAC;KACH;CACF"}
|
|
@@ -49,7 +49,6 @@ declare global {
|
|
|
49
49
|
getMessagePreviewSetting: (refresh?: boolean) => Promise<Amity.MessagePreviewSetting>;
|
|
50
50
|
getMarkerSyncConsistentMode: () => boolean;
|
|
51
51
|
prefixDeviceIdKey?: string;
|
|
52
|
-
objectSyncMap: Map<string, string | undefined>;
|
|
53
52
|
};
|
|
54
53
|
type Device = {
|
|
55
54
|
deviceId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/client.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,MAAM,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;QAEtD,WAAW,sBAAsB;YAC/B,UAAU,cAAc;YACxB,YAAY,gBAAgB;YAC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E,OAAO,CAAC;YACpC,UAAU,EAAE;gBACV,iBAAiB,EAAE,OAAO,CAAC;gBAC3B,gBAAgB,EAAE,OAAO,CAAC;gBAC1B,iBAAiB,EAAE,OAAO,CAAC;gBAC3B,UAAU,EAAE,OAAO,CAAC;gBACpB,cAAc,EAAE,OAAO,CAAC;aACzB,CAAC;YACF,kBAAkB,EAAE,QAAQ,GAAG,SAAS,CAAC;SAC1C,CAAC;QAEF,KAAK,mBAAmB,GAAG;YACzB,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YACrC,WAAW,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;YAChD,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;SACrC,CAAC;QAEF,KAAK,mBAAmB,GAAG;YACzB,UAAU,EAAE,OAAO,CAAC;SACrB,CAAC;QAEF,KAAK,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,aAAa,CAAC,CAAC;QAEtF,KAAK,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG;YACxD,WAAW,EAAE,OAAO,CAAC;SACtB,CAAC;KACH;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.d.ts","sourceRoot":"","sources":["../../../src/client/api/createClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAc,MAAM,0BAA0B,CAAC;AAuBnE;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,YAAY,WACf,MAAM,cACH,CAAA,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;;;;;;;;MAYtD,MAAM,
|
|
1
|
+
{"version":3,"file":"createClient.d.ts","sourceRoot":"","sources":["../../../src/client/api/createClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAc,MAAM,0BAA0B,CAAC;AAuBnE;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,YAAY,WACf,MAAM,cACH,CAAA,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;;;;;;;;MAYtD,MAAM,MA0FR,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ```js
|
|
3
|
+
* import { fetchLinkPreview } from '@amityco/ts-sdk'
|
|
4
|
+
* const { title, description, imageUrl } = fetchLinkPreview('https://www.example.com/')
|
|
5
|
+
* ```
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @param url the url to fetch link preview
|
|
9
|
+
* @returns A {@link Amity.LinkPreview} instance
|
|
10
|
+
*
|
|
11
|
+
* @category Client API
|
|
12
|
+
* */
|
|
13
|
+
export declare const fetchLinkPreview: (url: string) => Promise<Amity.LinkPreview>;
|
|
14
|
+
//# sourceMappingURL=fetchLinkPreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchLinkPreview.d.ts","sourceRoot":"","sources":["../../../src/client/api/fetchLinkPreview.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;KAWK;AAEL,eAAO,MAAM,gBAAgB,QAAe,MAAM,KAAG,QAAQ,MAAM,WAAW,CAc7E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,cAAc,cAAc,CAAC;AAE7B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,cAAc,eAAe,CAAC;AAE9B,cAAc,mBAAmB,CAAC;AAElC,cAAc,WAAW,CAAC;AAE1B,cAAc,cAAc,CAAC;AAE7B,cAAc,qBAAqB,CAAC;AAEpC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAE7C,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,cAAc,cAAc,CAAC;AAE7B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,cAAc,eAAe,CAAC;AAE9B,cAAc,mBAAmB,CAAC;AAElC,cAAc,WAAW,CAAC;AAE1B,cAAc,cAAc,CAAC;AAE7B,cAAc,qBAAqB,CAAC;AAEpC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAE7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CA+CtD,CAAC;AAEF,aAAa;AACb,eAAO,MAAM,UAAU,2DAA0D,OAMhF,CAAC;AAEF,aAAa;AACb,wBAAgB,aAAa,CAAC,IAAI,GAAE,MAAM,GAAG,SAAoC,GAAG,MAAM,CAEzF;AAED,aAAa;AACb,wBAAgB,WAAW,CAAC,IAAI,GAAE,MAAM,GAAG,SAAoC,GAAG,MAAM,CAEvF"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -123,8 +123,8 @@ const PostContentType = Object.freeze({
|
|
|
123
123
|
|
|
124
124
|
function getVersion() {
|
|
125
125
|
try {
|
|
126
|
-
// the string ''v7.0.
|
|
127
|
-
return 'v7.0.
|
|
126
|
+
// the string ''v7.0.1-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
127
|
+
return 'v7.0.1-cjs';
|
|
128
128
|
}
|
|
129
129
|
catch (error) {
|
|
130
130
|
return '__dev__';
|
|
@@ -572,18 +572,6 @@ const idResolvers = {
|
|
|
572
572
|
*/
|
|
573
573
|
const getResolver = (name) => idResolvers[name];
|
|
574
574
|
|
|
575
|
-
/*
|
|
576
|
-
* To check if an id is a local referenceId, the id must start with 'LOCAL_'.
|
|
577
|
-
*
|
|
578
|
-
* Example: LOCAL_155f5158-281a-4a9d-a445-9243138d2041
|
|
579
|
-
*
|
|
580
|
-
* @param id as string
|
|
581
|
-
* @returns true if the id is a local referenceId, false otherwise
|
|
582
|
-
*/
|
|
583
|
-
const isLocalId = (id) => {
|
|
584
|
-
return id.startsWith('LOCAL_');
|
|
585
|
-
};
|
|
586
|
-
|
|
587
575
|
/**
|
|
588
576
|
* A map of v3 response keys to a store name.
|
|
589
577
|
* @hidden
|
|
@@ -6493,26 +6481,20 @@ function convertFromRaw$2(_a) {
|
|
|
6493
6481
|
} }, rest), { channelId: channelPublicId, creatorId: creatorPublicId, displayName: name, lastActivity: lastMessageTimestamp, latestMessageId: lastMessageId, messageCount: childCount, subChannelId: messageFeedId, isUnreadCountSupport: isUnreadCountSupport$2({ channelType }) });
|
|
6494
6482
|
}
|
|
6495
6483
|
|
|
6496
|
-
const
|
|
6497
|
-
|
|
6498
|
-
const {
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
*
|
|
6506
|
-
* The referenceId is undefined means this message is not a local created message (optimistic creation message).
|
|
6507
|
-
*/
|
|
6508
|
-
referenceId: isLocalId(payload.messageId)
|
|
6509
|
-
? payload.messageId
|
|
6510
|
-
: objectSyncMap.get(payload.messageId) });
|
|
6484
|
+
const mergePayloadWithLocal = (payload) => {
|
|
6485
|
+
var _a, _b, _c;
|
|
6486
|
+
const localMessage = (_b = (_a = queryCache(['message', 'get'])) === null || _a === void 0 ? void 0 : _a.find(({ data }) => data.messageId === payload.messageId)) === null || _b === void 0 ? void 0 : _b.data;
|
|
6487
|
+
if (localMessage) {
|
|
6488
|
+
return Object.assign(Object.assign(Object.assign({}, localMessage), payload), {
|
|
6489
|
+
// NOTE: referenceId is missing in the some payload event. If we have local message data with referenceId, use it instead.
|
|
6490
|
+
referenceId: (_c = localMessage.referenceId) !== null && _c !== void 0 ? _c : payload.referenceId });
|
|
6491
|
+
}
|
|
6492
|
+
return payload;
|
|
6511
6493
|
};
|
|
6512
6494
|
function convertFromRaw$1(message, reactors, event) {
|
|
6513
6495
|
var _a;
|
|
6514
|
-
const
|
|
6515
|
-
const { channelPublicId, childCount, creatorPublicId, mentionedUsers, messageFeedId, myReactions, reactionCount, reactions, referenceId, segment, messageId, creatorId } =
|
|
6496
|
+
const mergeMessage = mergePayloadWithLocal(message);
|
|
6497
|
+
const { channelPublicId, childCount, creatorPublicId, mentionedUsers, messageFeedId, myReactions, reactionCount, reactions, referenceId, segment, messageId, creatorId } = mergeMessage, rest = __rest(mergeMessage, ["channelPublicId", "childCount", "creatorPublicId", "mentionedUsers", "messageFeedId", "myReactions", "reactionCount", "reactions", "referenceId", "segment", "messageId", "creatorId"]);
|
|
6516
6498
|
let cache;
|
|
6517
6499
|
if (referenceId) {
|
|
6518
6500
|
cache = pullFromCache(['message', 'get', referenceId]);
|
|
@@ -8700,42 +8682,6 @@ const updateSubChannelUnreadFromMessage = (message) => {
|
|
|
8700
8682
|
pushToCache(cacheKeyUnreadCount, updatedCachedUnreadCount);
|
|
8701
8683
|
};
|
|
8702
8684
|
|
|
8703
|
-
/*
|
|
8704
|
-
* To get message identifier ids used as a cache key for the each message.
|
|
8705
|
-
* These ids are used to store in the query stream and use to get messages from cache.
|
|
8706
|
-
*
|
|
8707
|
-
* The query stream data keeps the message identifier ids as follows:
|
|
8708
|
-
* ['server_message_id_1', 'server_message_id_2', 'LOCAL_message_id_1', 'LOCAL_message_id_2']
|
|
8709
|
-
*
|
|
8710
|
-
* Example use case: Message created locally and then created on the server.
|
|
8711
|
-
*
|
|
8712
|
-
* 1. Message created locally has `LOCAL_message_id_2` as referenceId.
|
|
8713
|
-
* 2. The `message.created` event will be fired from server with message payload that has no the referenceId.
|
|
8714
|
-
* 3. SDK use this function to find indentifer id for each message in the payload. If the message is created locally, the identifier id will be the local reference id.
|
|
8715
|
-
* 4. The SDK use this identifier ids to check if the message is already in the query stream before appending it.
|
|
8716
|
-
*
|
|
8717
|
-
* @param The raw message payload from server response
|
|
8718
|
-
* @returns The identifier ids of the messages
|
|
8719
|
-
*/
|
|
8720
|
-
function getMessageIdentifierIds(messages) {
|
|
8721
|
-
const client = getActiveClient();
|
|
8722
|
-
const { objectSyncMap } = client;
|
|
8723
|
-
return messages
|
|
8724
|
-
.map(message => {
|
|
8725
|
-
var _a;
|
|
8726
|
-
/* NOTE: This logic is used to get identifier id for each message.
|
|
8727
|
-
*
|
|
8728
|
-
* if messageId is a local id, use it as identifier id else get identifier id from objectSyncMap.
|
|
8729
|
-
* if find referenceId in objectSyncMap, this means this message is a local created message. The identifier id will be local message id.
|
|
8730
|
-
* if cannot find identifier id in objectSyncMap, this means this message is not a local created message. The identifier id will be server message id.
|
|
8731
|
-
*/
|
|
8732
|
-
if (isLocalId(message.messageId))
|
|
8733
|
-
return message.messageId;
|
|
8734
|
-
return (_a = objectSyncMap.get(message.messageId)) !== null && _a !== void 0 ? _a : message.messageId;
|
|
8735
|
-
})
|
|
8736
|
-
.filter(Boolean);
|
|
8737
|
-
}
|
|
8738
|
-
|
|
8739
8685
|
/**
|
|
8740
8686
|
* ```js
|
|
8741
8687
|
* import { onMessageCreated } from '@amityco/ts-sdk-react-native'
|
|
@@ -9455,7 +9401,6 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
9455
9401
|
const sessionState = "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */;
|
|
9456
9402
|
const sessionHandler = undefined;
|
|
9457
9403
|
const isUnreadCountEnabled = false;
|
|
9458
|
-
const objectSyncMap = new Map();
|
|
9459
9404
|
const client = {
|
|
9460
9405
|
version: `${VERSION}`,
|
|
9461
9406
|
apiKey,
|
|
@@ -9492,29 +9437,6 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
9492
9437
|
* This is allow user to have multiple SDK client and Mqtt client within the same app.
|
|
9493
9438
|
*/
|
|
9494
9439
|
prefixDeviceIdKey,
|
|
9495
|
-
/*
|
|
9496
|
-
* The objectSyncMap is used to keep the map between local referenceId and server id in two ways mapping.
|
|
9497
|
-
*
|
|
9498
|
-
* For objects created locally (optimistic creation), the SDK stores them with their local ID as the cache key, which is used throughout the entire SDK session (in-memory) for syncing updates.
|
|
9499
|
-
* If the payload or response only contains the remote ID of the same object, the SDK will look up the corresponding local ID to retrieve the object through ObjectSyncMap.
|
|
9500
|
-
*
|
|
9501
|
-
* This is useful for syncing updates to the object, as the SDK can find the local ID from the server ID and update the object in the cache correctly.
|
|
9502
|
-
*
|
|
9503
|
-
* Example:
|
|
9504
|
-
* In the case of message optimistically creation. The referenceId is created locally.
|
|
9505
|
-
*
|
|
9506
|
-
* 1. When creating a message optimistically, a local referenceId is created. The objectSyncMap will have the following structure.
|
|
9507
|
-
* {
|
|
9508
|
-
* "LOCAL_uuid": undefined,
|
|
9509
|
-
* }
|
|
9510
|
-
*
|
|
9511
|
-
* 2. After the message was created on the server and SDK received the response from server, the objectSyncMap will be updated to
|
|
9512
|
-
* {
|
|
9513
|
-
* "LOCAL_uuid": "server_message_id",
|
|
9514
|
-
* "server_message_id": "LOCAL_uuid"
|
|
9515
|
-
* }
|
|
9516
|
-
*/
|
|
9517
|
-
objectSyncMap,
|
|
9518
9440
|
};
|
|
9519
9441
|
try {
|
|
9520
9442
|
const activeClient = getActiveClient();
|
|
@@ -9642,6 +9564,28 @@ const unregisterPushNotification = async () => {
|
|
|
9642
9564
|
return status === 'success';
|
|
9643
9565
|
};
|
|
9644
9566
|
|
|
9567
|
+
/**
|
|
9568
|
+
* ```js
|
|
9569
|
+
* import { fetchLinkPreview } from '@amityco/ts-sdk'
|
|
9570
|
+
* const { title, description, imageUrl } = fetchLinkPreview('https://www.example.com/')
|
|
9571
|
+
* ```
|
|
9572
|
+
*
|
|
9573
|
+
*
|
|
9574
|
+
* @param url the url to fetch link preview
|
|
9575
|
+
* @returns A {@link Amity.LinkPreview} instance
|
|
9576
|
+
*
|
|
9577
|
+
* @category Client API
|
|
9578
|
+
* */
|
|
9579
|
+
const fetchLinkPreview = async (url) => {
|
|
9580
|
+
const client = getActiveClient();
|
|
9581
|
+
let fetchUrl = url;
|
|
9582
|
+
if (!/^https?:\/\//i.test(url)) {
|
|
9583
|
+
fetchUrl = `https://${url}`;
|
|
9584
|
+
}
|
|
9585
|
+
const { data } = await client.http.get(`/api/v1/link-preview?url=${encodeURIComponent(fetchUrl)}`);
|
|
9586
|
+
return data;
|
|
9587
|
+
};
|
|
9588
|
+
|
|
9645
9589
|
/**
|
|
9646
9590
|
* ```js
|
|
9647
9591
|
* import { onChannelMarkerFetched } from '@amityco/ts-sdk-react-native'
|
|
@@ -10012,6 +9956,7 @@ var index$l = /*#__PURE__*/Object.freeze({
|
|
|
10012
9956
|
registerPushNotification: registerPushNotification,
|
|
10013
9957
|
unregisterPushNotification: unregisterPushNotification,
|
|
10014
9958
|
onRTEConnectionStateChange: onRTEConnectionStateChange,
|
|
9959
|
+
fetchLinkPreview: fetchLinkPreview,
|
|
10015
9960
|
onConnectionError: onConnectionError,
|
|
10016
9961
|
onClientDisconnected: onClientDisconnected,
|
|
10017
9962
|
onClientBanned: onClientBanned,
|
|
@@ -11841,24 +11786,12 @@ function prepareBlockedUserPayload(response) {
|
|
|
11841
11786
|
}
|
|
11842
11787
|
|
|
11843
11788
|
const convertEventPayload = (eventHandler, sourceModelProp, destinationDomain) => (callback) => eventHandler(sourceModel => {
|
|
11844
|
-
var _a
|
|
11789
|
+
var _a;
|
|
11845
11790
|
if (!sourceModel) {
|
|
11846
11791
|
return sourceModel;
|
|
11847
11792
|
}
|
|
11848
|
-
const
|
|
11849
|
-
const
|
|
11850
|
-
/*
|
|
11851
|
-
* NOTE: For objects created locally (optimistic creation), the SDK stores them with their local ID as the cache key, which is used throughout the entire SDK session (in-memory) for syncing updates.
|
|
11852
|
-
* If the payload or response only contains the remote ID of the same object, the SDK will look up the corresponding local ID to retrieve the object.
|
|
11853
|
-
*/
|
|
11854
|
-
const resolvedId = isLocalId(sourceModel[sourceModelProp])
|
|
11855
|
-
? sourceModel[sourceModelProp]
|
|
11856
|
-
: (_a = objectSyncMap.get(sourceModel[sourceModelProp])) !== null && _a !== void 0 ? _a : sourceModel[sourceModelProp];
|
|
11857
|
-
const model = (_b = pullFromCache([
|
|
11858
|
-
destinationDomain,
|
|
11859
|
-
'get',
|
|
11860
|
-
`${resolvedId}`,
|
|
11861
|
-
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
11793
|
+
const cacheKey = [destinationDomain, 'get', `${sourceModel[sourceModelProp]}`];
|
|
11794
|
+
const model = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
11862
11795
|
if (!model)
|
|
11863
11796
|
return;
|
|
11864
11797
|
return callback(model);
|
|
@@ -15086,7 +15019,6 @@ let uniqueId;
|
|
|
15086
15019
|
const createMessageOptimistic = (bundle) => {
|
|
15087
15020
|
var _a, _b;
|
|
15088
15021
|
const client = getActiveClient();
|
|
15089
|
-
const { objectSyncMap } = client;
|
|
15090
15022
|
if (!client.cache)
|
|
15091
15023
|
return;
|
|
15092
15024
|
/*
|
|
@@ -15119,7 +15051,6 @@ const createMessageOptimistic = (bundle) => {
|
|
|
15119
15051
|
const message = Object.assign({ creatorId: client.userId, creatorPrivateId: getActiveUser()._id, channelSegment: ((_b = subChannel === null || subChannel === void 0 ? void 0 : subChannel.data.messageCount) !== null && _b !== void 0 ? _b : 0) + 1, childrenNumber: 0, createdAt: createdTime, updatedAt: createdTime, syncState: "syncing" /* Amity.SyncState.Syncing */, isDeleted: false }, bundleWithMessageId);
|
|
15120
15052
|
const cachedAt = UNSYNCED_OBJECT_CACHED_AT_VALUE;
|
|
15121
15053
|
pushToCache(['message', 'get', message.messageId], message, { cachedAt });
|
|
15122
|
-
objectSyncMap.set(message.messageId, undefined);
|
|
15123
15054
|
fireEvent('local.message.created', { messages: [message] });
|
|
15124
15055
|
return message;
|
|
15125
15056
|
};
|
|
@@ -15147,15 +15078,12 @@ const createMessageOptimistic = (bundle) => {
|
|
|
15147
15078
|
*/
|
|
15148
15079
|
const createMessage = async (bundle) => {
|
|
15149
15080
|
const client = getActiveClient();
|
|
15150
|
-
const { objectSyncMap } = client;
|
|
15151
15081
|
client.log('message/createMessage', bundle);
|
|
15152
15082
|
const optimisticData = createMessageOptimistic(bundle);
|
|
15153
15083
|
const referenceId = bundle.referenceId || uniqueId || getLocalId();
|
|
15154
15084
|
uniqueId = undefined;
|
|
15155
15085
|
try {
|
|
15156
15086
|
const { data: payload } = await client.http.post('/api/v5/messages', Object.assign(Object.assign({}, convertParams(bundle)), { referenceId }));
|
|
15157
|
-
objectSyncMap.set(referenceId, payload.messages[0].messageId);
|
|
15158
|
-
objectSyncMap.set(payload.messages[0].messageId, referenceId);
|
|
15159
15087
|
const data = await prepareMessagePayload(payload);
|
|
15160
15088
|
const { messages } = data;
|
|
15161
15089
|
const cachedAt = client.cache && Date.now();
|
|
@@ -15910,7 +15838,7 @@ class MessageQueryStreamController extends QueryStreamController {
|
|
|
15910
15838
|
var _a, _b;
|
|
15911
15839
|
if (refresh) {
|
|
15912
15840
|
pushToCache(this.cacheKey, {
|
|
15913
|
-
data:
|
|
15841
|
+
data: response.messages.map(getResolver('message')),
|
|
15914
15842
|
query: this.query,
|
|
15915
15843
|
});
|
|
15916
15844
|
}
|
|
@@ -15918,8 +15846,8 @@ class MessageQueryStreamController extends QueryStreamController {
|
|
|
15918
15846
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
15919
15847
|
const messages = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
15920
15848
|
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === 'next'
|
|
15921
|
-
? [...new Set([...messages, ...
|
|
15922
|
-
: [...new Set([...
|
|
15849
|
+
? [...new Set([...messages, ...response.messages.map(getResolver('message'))])]
|
|
15850
|
+
: [...new Set([...response.messages.map(getResolver('message')), ...messages])] }));
|
|
15923
15851
|
}
|
|
15924
15852
|
}
|
|
15925
15853
|
reactor(action) {
|
|
@@ -15986,12 +15914,11 @@ class MessagePaginationController extends PaginationController {
|
|
|
15986
15914
|
|
|
15987
15915
|
const getMessageFromMainDB = (messageId) => {
|
|
15988
15916
|
var _a, _b;
|
|
15989
|
-
const
|
|
15990
|
-
|
|
15991
|
-
|
|
15992
|
-
|
|
15993
|
-
|
|
15994
|
-
return (_b = pullFromCache(['message', 'get', resolvedMessageId])) === null || _b === void 0 ? void 0 : _b.data;
|
|
15917
|
+
const message = (_a = pullFromCache(['message', 'get', messageId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
15918
|
+
if (message)
|
|
15919
|
+
return message;
|
|
15920
|
+
const messages = queryCache(['message', 'get']);
|
|
15921
|
+
return (_b = messages === null || messages === void 0 ? void 0 : messages.find(({ data }) => data.messageId === messageId)) === null || _b === void 0 ? void 0 : _b.data;
|
|
15995
15922
|
};
|
|
15996
15923
|
|
|
15997
15924
|
class MessageLiveCollectionController extends LiveCollectionController {
|
|
@@ -16152,8 +16079,7 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
16152
16079
|
convertFromRaw: convertFromRaw$1,
|
|
16153
16080
|
prepareMessagePayload: prepareMessagePayload,
|
|
16154
16081
|
convertParams: convertParams,
|
|
16155
|
-
convertQueryParams: convertQueryParams$1
|
|
16156
|
-
getMessageIdentifierIds: getMessageIdentifierIds
|
|
16082
|
+
convertQueryParams: convertQueryParams$1
|
|
16157
16083
|
});
|
|
16158
16084
|
|
|
16159
16085
|
/**
|