@amityco/ts-sdk 7.32.1-23b143a2.0 → 7.32.1-4ee0bce9.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/domains/comment.d.ts +2 -2
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +15 -1
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/cache/api/dropFromCache.d.ts.map +1 -1
- package/dist/cache/api/pushToCache.d.ts.map +1 -1
- package/dist/cache/api/queryCache.d.ts.map +1 -1
- package/dist/commentRepository/api/createComment.d.ts +1 -1
- package/dist/commentRepository/api/createComment.d.ts.map +1 -1
- package/dist/commentRepository/api/tests/createComment.gif.test.d.ts +2 -0
- package/dist/commentRepository/api/tests/createComment.gif.test.d.ts.map +1 -0
- package/dist/commentRepository/api/tests/deleteComment.gif.test.d.ts +2 -0
- package/dist/commentRepository/api/tests/deleteComment.gif.test.d.ts.map +1 -0
- package/dist/commentRepository/api/tests/updateComment.gif.test.d.ts +2 -0
- package/dist/commentRepository/api/tests/updateComment.gif.test.d.ts.map +1 -0
- package/dist/commentRepository/api/updateComment.d.ts +9 -2
- package/dist/commentRepository/api/updateComment.d.ts.map +1 -1
- package/dist/commentRepository/observers/tests/getComments.gif.test.d.ts +2 -0
- package/dist/commentRepository/observers/tests/getComments.gif.test.d.ts.map +1 -0
- package/dist/commentRepository/utils/dataTypes.d.ts +2 -0
- package/dist/commentRepository/utils/dataTypes.d.ts.map +1 -0
- package/dist/index.cjs.js +69 -136
- package/dist/index.esm.js +69 -136
- package/dist/index.umd.js +2 -2
- package/dist/messageRepository/utils/getMessageFromMainDB.d.ts.map +1 -1
- package/dist/messageRepository/utils/prepareMessagePayload.d.ts.map +1 -1
- package/dist/utils/gifAttachment.d.ts +5 -0
- package/dist/utils/gifAttachment.d.ts.map +1 -0
- package/dist/utils/linkedObject/channelLinkedObject.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cache/api/queryCacheByProperty.d.ts +0 -3
- package/dist/cache/api/queryCacheByProperty.d.ts.map +0 -1
- package/dist/cache/api/tests/queryCache.test.d.ts +0 -2
- package/dist/cache/api/tests/queryCache.test.d.ts.map +0 -1
- package/dist/cache/utils/cacheIndex.d.ts +0 -15
- package/dist/cache/utils/cacheIndex.d.ts.map +0 -1
- package/dist/utils/linkedObject/tests/channelCachePerformance.test.d.ts +0 -2
- package/dist/utils/linkedObject/tests/channelCachePerformance.test.d.ts.map +0 -1
|
@@ -11,7 +11,7 @@ declare global {
|
|
|
11
11
|
* Absent on the wire means `approved` — see `prepareCommentPayload`.
|
|
12
12
|
*/
|
|
13
13
|
type CommentApprovalStatus = `${CommentApprovalStatusEnum}`;
|
|
14
|
-
type CommentContentType = 'text';
|
|
14
|
+
type CommentContentType = 'text' | 'gif';
|
|
15
15
|
type CommentReferenceType = 'content' | 'post' | 'story';
|
|
16
16
|
type CommentActionType = 'onFetch' | 'onCreate' | 'onUpdate' | 'onDelete' | 'onFlagged' | 'onUnflagged' | 'onReactionAdded' | 'onReactionRemoved';
|
|
17
17
|
type RawComment<T extends CommentContentType = any> = {
|
|
@@ -57,7 +57,7 @@ declare global {
|
|
|
57
57
|
limit?: number;
|
|
58
58
|
page?: Amity.Token;
|
|
59
59
|
dataTypes?: {
|
|
60
|
-
values: ('image' | 'text')[];
|
|
60
|
+
values: ('image' | 'text' | 'gif')[];
|
|
61
61
|
matchType: 'any' | 'exact';
|
|
62
62
|
};
|
|
63
63
|
excludeBlockUserComments?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/comment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,WAAW,yBAAyB;YAClC,OAAO,YAAY;YACnB,QAAQ,aAAa;YACrB,QAAQ,aAAa;SACtB;QAED;;;WAGG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,QAAQ,CAAC,EAAE,MAAM,CAAC;SACnB,CAAC;QAEF,KAAK,gCAAgC,GAAG,KAAK,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;QAE5F,KAAK,qCAAqC,GAAG,KAAK,CAAC,mBAAmB,CACpE,KAAK,CAAC,eAAe,CAAC,WAAW,CAAC,EAClC;YAAE,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CACnB,CAAC;KACH;CACF"}
|
|
@@ -49,11 +49,25 @@ declare global {
|
|
|
49
49
|
fileId: Amity.File<'image'>['fileId'];
|
|
50
50
|
caption?: string;
|
|
51
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* A GIF picked by the app from its own provider. It is a link, not a file: nothing is
|
|
54
|
+
* uploaded and there is no `fileId`. Leave out a size that has no value; `null` is refused,
|
|
55
|
+
* and so is any other key (alt text and provider fields included).
|
|
56
|
+
*/
|
|
57
|
+
type GifAttachment = {
|
|
58
|
+
type: 'gif';
|
|
59
|
+
/** https, path ends in `.gif`, at most 2,000 characters. Checked by the server. */
|
|
60
|
+
url: string;
|
|
61
|
+
/** 1 to 4096 */
|
|
62
|
+
width?: number;
|
|
63
|
+
/** 1 to 4096 */
|
|
64
|
+
height?: number;
|
|
65
|
+
};
|
|
52
66
|
type Attachment = {
|
|
53
67
|
type: 'image' | 'link';
|
|
54
68
|
url?: string;
|
|
55
69
|
fileId?: Amity.File<'image'>['fileId'];
|
|
56
|
-
};
|
|
70
|
+
} | GifAttachment;
|
|
57
71
|
type ContentDataVideo = {
|
|
58
72
|
/**
|
|
59
73
|
* Null until the server has finished transcoding the video: the field is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/content.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;EAM1B,CAAC;AAEH,oBAAY,qBAAqB;IAC/B,mBAAmB,iCAAiC;IACpD,iBAAiB,uBAAuB;IACxC,oBAAoB,2BAA2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AC,EAAE,CAAC,EAAE,CAAC;YAChB,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;SACvB,CAAC;QAEF,KAAK,kBAAkB,GAAG;YACxB,WAAW,EAAE,MAAM,CAAC;YACpB,OAAO,EAAE,OAAO,CAAC;SAClB,CAAC;QAEF,KAAK,mBAAmB,GAAG;YACzB,WAAW,EAAE,OAAO,CAAC;YACrB,OAAO,EAAE,OAAO,CAAC;YACjB,kBAAkB,EAAE,MAAM,CAAC;YAC3B,eAAe,EAAE;gBACf,aAAa,EAAE,KAAK,CAAC,eAAe,CAAC;gBACrC,aAAa,EAAE,KAAK,CAAC,eAAe,CAAC;aACtC,CAAC;SACH,CAAC;QAEF,KAAK,cAAc,CAAC,CAAC,SAAS,WAAW,GAAG,MAAM,GAAG,OAAO,IAAI,CAAC,SAAS,MAAM,GAC5E,kBAAkB,GAClB,CAAC,SAAS,OAAO,GACjB,mBAAmB,GACnB,KAAK,CAAC;KACX;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropFromCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/dropFromCache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dropFromCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/dropFromCache.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,4CAAyC,OAsBlE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushToCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/pushToCache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pushToCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/pushToCache.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,8BAEhB,OAAO,YACJ,MAAM,YAAY,KAC1B,OAkBF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/queryCache.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,+
|
|
1
|
+
{"version":3,"file":"queryCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/queryCache.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,+EActB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare type CreateCommentBundle = Pick<Amity.Comment<
|
|
1
|
+
declare type CreateCommentBundle = Pick<Amity.Comment<'text'>, 'data' | 'referenceType' | 'referenceId' | 'parentId' | 'metadata' | 'mentionees' | 'attachments' | 'links'>;
|
|
2
2
|
/**
|
|
3
3
|
* ```js
|
|
4
4
|
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/createComment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/createComment.ts"],"names":[],"mappings":"AA2BA,aAAK,mBAAmB,GAAG,IAAI,CAC7B,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EACnB,MAAM,GACN,eAAe,GACf,aAAa,GACb,UAAU,GACV,UAAU,GACV,YAAY,GACZ,aAAa,GACb,OAAO,CACV,CAAC;AAqEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,aAAa,WAChB,mBAAmB,6BAE1B,QAAQ,MAAM,MAAM,CAAC,aAAa,CAAC,CAmHrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createComment.gif.test.d.ts","sourceRoot":"","sources":["../../../../src/commentRepository/api/tests/createComment.gif.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteComment.gif.test.d.ts","sourceRoot":"","sources":["../../../../src/commentRepository/api/tests/deleteComment.gif.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateComment.gif.test.d.ts","sourceRoot":"","sources":["../../../../src/commentRepository/api/tests/updateComment.gif.test.ts"],"names":[],"mappings":""}
|
|
@@ -4,9 +4,16 @@
|
|
|
4
4
|
* const updated = await CommentRepository.updateComment(commentId, {
|
|
5
5
|
* data: { text: 'hello world' }
|
|
6
6
|
* })
|
|
7
|
+
*
|
|
8
|
+
* // Replace the GIF, or remove it and keep the text
|
|
9
|
+
* await CommentRepository.updateComment(commentId, {
|
|
10
|
+
* attachments: [{ type: 'gif', url: 'https://media.giphy.com/media/l0MYt5jPR6QX5pnqM/giphy.gif' }],
|
|
11
|
+
* })
|
|
12
|
+
* await CommentRepository.updateComment(commentId, { attachments: [] })
|
|
7
13
|
* ```
|
|
8
14
|
*
|
|
9
|
-
* Updates an {@link Amity.Comment}
|
|
15
|
+
* Updates an {@link Amity.Comment}. `attachments` replaces the current ones, `[]` removes them,
|
|
16
|
+
* and leaving `attachments` out keeps them as they are.
|
|
10
17
|
*
|
|
11
18
|
* @param commentId The ID of the {@link Amity.Comment} to edit
|
|
12
19
|
* @param patch The patch data to apply
|
|
@@ -15,5 +22,5 @@
|
|
|
15
22
|
* @category Comment API
|
|
16
23
|
* @async
|
|
17
24
|
*/
|
|
18
|
-
export declare const updateComment: (commentId: Amity.Comment['commentId'], patch: Patch<Amity.Comment, 'data' | 'metadata' | 'mentionees' | 'links'>) => Promise<Amity.Cached<Amity.Comment>>;
|
|
25
|
+
export declare const updateComment: (commentId: Amity.Comment['commentId'], patch: Patch<Amity.Comment, 'data' | 'metadata' | 'mentionees' | 'links' | 'attachments'>) => Promise<Amity.Cached<Amity.Comment>>;
|
|
19
26
|
//# sourceMappingURL=updateComment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/updateComment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updateComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/updateComment.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,aAAa,cACb,aAAa,CAAC,WAAW,CAAC,SAC9B,MAAM,aAAa,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,OAAO,GAAG,aAAa,CAAC,KACxF,QAAQ,MAAM,MAAM,CAAC,aAAa,CAAC,CAoCrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getComments.gif.test.d.ts","sourceRoot":"","sources":["../../../../src/commentRepository/observers/tests/getComments.gif.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataTypes.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/utils/dataTypes.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,SACvB,MAAM,GAAG,SAAS,eACX,MAAM,UAAU,EAAE,GAAG,SAAS,KAC1C,MAAM,kBAAkB,EAI1B,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1184,116 +1184,6 @@ const wipeCache = async (storageKey = 'amitySdk') => {
|
|
|
1184
1184
|
return true;
|
|
1185
1185
|
};
|
|
1186
1186
|
|
|
1187
|
-
// Indexes never enter persisted cache data. Replacing data (restore/wipe/enable) starts a new index.
|
|
1188
|
-
const indexes = new WeakMap();
|
|
1189
|
-
const prefixesFor = (key) => {
|
|
1190
|
-
if (typeof key[0] !== 'string')
|
|
1191
|
-
return [];
|
|
1192
|
-
const prefixes = [JSON.stringify([key[0]])];
|
|
1193
|
-
if (typeof key[1] === 'string')
|
|
1194
|
-
prefixes.push(JSON.stringify([key[0], key[1]]));
|
|
1195
|
-
return prefixes;
|
|
1196
|
-
};
|
|
1197
|
-
const removePropertyValue = (property, indexed) => {
|
|
1198
|
-
const previous = property.previousValues.get(indexed.encodedKey);
|
|
1199
|
-
if (previous === undefined)
|
|
1200
|
-
return;
|
|
1201
|
-
const matches = property.values.get(previous);
|
|
1202
|
-
matches.delete(indexed);
|
|
1203
|
-
if (!matches.size)
|
|
1204
|
-
property.values.delete(previous);
|
|
1205
|
-
property.previousValues.delete(indexed.encodedKey);
|
|
1206
|
-
};
|
|
1207
|
-
const addPropertyValue = (data, property, indexed) => {
|
|
1208
|
-
var _a;
|
|
1209
|
-
if (!partialMatch(property.prefix, indexed.key))
|
|
1210
|
-
return;
|
|
1211
|
-
const value = (_a = data[indexed.encodedKey].data) === null || _a === void 0 ? void 0 : _a[property.property];
|
|
1212
|
-
if (typeof value !== 'string')
|
|
1213
|
-
return;
|
|
1214
|
-
let matches = property.values.get(value);
|
|
1215
|
-
if (!matches) {
|
|
1216
|
-
matches = new Set();
|
|
1217
|
-
property.values.set(value, matches);
|
|
1218
|
-
}
|
|
1219
|
-
matches.add(indexed);
|
|
1220
|
-
property.previousValues.set(indexed.encodedKey, value);
|
|
1221
|
-
};
|
|
1222
|
-
const addKey = (index, encodedKey) => {
|
|
1223
|
-
const indexed = { encodedKey, key: decodeKey(encodedKey), order: index.nextOrder };
|
|
1224
|
-
index.nextOrder += 1; // eslint-disable-line no-param-reassign
|
|
1225
|
-
index.keys.set(encodedKey, indexed);
|
|
1226
|
-
prefixesFor(indexed.key).forEach(prefix => {
|
|
1227
|
-
let keys = index.prefixes.get(prefix);
|
|
1228
|
-
if (!keys) {
|
|
1229
|
-
keys = new Map();
|
|
1230
|
-
index.prefixes.set(prefix, keys);
|
|
1231
|
-
}
|
|
1232
|
-
keys.set(encodedKey, indexed);
|
|
1233
|
-
});
|
|
1234
|
-
return indexed;
|
|
1235
|
-
};
|
|
1236
|
-
const getIndex = (data) => {
|
|
1237
|
-
let index = indexes.get(data);
|
|
1238
|
-
if (!index) {
|
|
1239
|
-
index = { keys: new Map(), prefixes: new Map(), properties: new Map(), nextOrder: 0 };
|
|
1240
|
-
Object.keys(data).forEach(encodedKey => addKey(index, encodedKey));
|
|
1241
|
-
indexes.set(data, index);
|
|
1242
|
-
}
|
|
1243
|
-
return index;
|
|
1244
|
-
};
|
|
1245
|
-
const candidatesFor = (index, key) => {
|
|
1246
|
-
var _a, _b;
|
|
1247
|
-
const prefixes = prefixesFor(key);
|
|
1248
|
-
if (!prefixes.length)
|
|
1249
|
-
return index.keys.values();
|
|
1250
|
-
return (_b = (_a = index.prefixes.get(prefixes[prefixes.length - 1])) === null || _a === void 0 ? void 0 : _a.values()) !== null && _b !== void 0 ? _b : [];
|
|
1251
|
-
};
|
|
1252
|
-
/** @hidden */
|
|
1253
|
-
const getMatchingCacheKeys = (data, key) => Array.from(candidatesFor(getIndex(data), key)).filter(indexed => partialMatch(key, indexed.key));
|
|
1254
|
-
/** Update only an index that has already been used; writes alone need no index build. @hidden */
|
|
1255
|
-
const updateCacheIndex = (data, encodedKey) => {
|
|
1256
|
-
var _a;
|
|
1257
|
-
const index = indexes.get(data);
|
|
1258
|
-
if (!index)
|
|
1259
|
-
return;
|
|
1260
|
-
const indexed = (_a = index.keys.get(encodedKey)) !== null && _a !== void 0 ? _a : addKey(index, encodedKey);
|
|
1261
|
-
index.properties.forEach(property => {
|
|
1262
|
-
removePropertyValue(property, indexed);
|
|
1263
|
-
addPropertyValue(data, property, indexed);
|
|
1264
|
-
});
|
|
1265
|
-
};
|
|
1266
|
-
/** @hidden */
|
|
1267
|
-
const removeFromCacheIndex = (data, encodedKey) => {
|
|
1268
|
-
const index = indexes.get(data);
|
|
1269
|
-
const indexed = index === null || index === void 0 ? void 0 : index.keys.get(encodedKey);
|
|
1270
|
-
if (!index || !indexed)
|
|
1271
|
-
return;
|
|
1272
|
-
index.properties.forEach(property => removePropertyValue(property, indexed));
|
|
1273
|
-
prefixesFor(indexed.key).forEach(prefix => {
|
|
1274
|
-
const keys = index.prefixes.get(prefix);
|
|
1275
|
-
keys.delete(encodedKey);
|
|
1276
|
-
if (!keys.size)
|
|
1277
|
-
index.prefixes.delete(prefix);
|
|
1278
|
-
});
|
|
1279
|
-
index.keys.delete(encodedKey);
|
|
1280
|
-
};
|
|
1281
|
-
/** Index a string model property within one domain/operation, retaining cache insertion order. @hidden */
|
|
1282
|
-
const getCacheEntriesByProperty = (data, prefix, property, value) => {
|
|
1283
|
-
var _a;
|
|
1284
|
-
const index = getIndex(data);
|
|
1285
|
-
const identity = JSON.stringify([prefix, property]);
|
|
1286
|
-
let propertyIndex = index.properties.get(identity);
|
|
1287
|
-
if (!propertyIndex) {
|
|
1288
|
-
propertyIndex = { prefix, property, values: new Map(), previousValues: new Map() };
|
|
1289
|
-
index.properties.set(identity, propertyIndex);
|
|
1290
|
-
Array.from(candidatesFor(index, prefix)).forEach(indexed => addPropertyValue(data, propertyIndex, indexed));
|
|
1291
|
-
}
|
|
1292
|
-
return Array.from((_a = propertyIndex.values.get(value)) !== null && _a !== void 0 ? _a : [])
|
|
1293
|
-
.sort((a, b) => a.order - b.order)
|
|
1294
|
-
.map(({ encodedKey }) => data[encodedKey]);
|
|
1295
|
-
};
|
|
1296
|
-
|
|
1297
1187
|
/**
|
|
1298
1188
|
* ```js
|
|
1299
1189
|
* import { queryCache } from '@amityco/ts-sdk'
|
|
@@ -1314,7 +1204,12 @@ const queryCache = (key) => {
|
|
|
1314
1204
|
if (!cache)
|
|
1315
1205
|
return;
|
|
1316
1206
|
log('cache/api/queryCache', { key });
|
|
1317
|
-
return
|
|
1207
|
+
return Object.keys(cache.data)
|
|
1208
|
+
.filter(stringKey => {
|
|
1209
|
+
const decodedKey = decodeKey(stringKey);
|
|
1210
|
+
return partialMatch(key, decodedKey);
|
|
1211
|
+
})
|
|
1212
|
+
.map(stringKey => cache.data[stringKey]);
|
|
1318
1213
|
};
|
|
1319
1214
|
|
|
1320
1215
|
/**
|
|
@@ -1370,7 +1265,6 @@ const pushToCache = (key, data, options = { cachedAt: Date.now() }) => {
|
|
|
1370
1265
|
}
|
|
1371
1266
|
const encodedKey = encodeKey(key);
|
|
1372
1267
|
cache.data[encodedKey] = Object.assign({ key, data }, options);
|
|
1373
|
-
updateCacheIndex(cache.data, encodedKey);
|
|
1374
1268
|
return true;
|
|
1375
1269
|
};
|
|
1376
1270
|
|
|
@@ -1455,14 +1349,15 @@ const dropFromCache = (key, exact = false) => {
|
|
|
1455
1349
|
return false;
|
|
1456
1350
|
log('cache/api/dropFromCache', { key, exact });
|
|
1457
1351
|
if (!exact) {
|
|
1458
|
-
return
|
|
1459
|
-
.map(
|
|
1352
|
+
return Object.keys(cache.data)
|
|
1353
|
+
.map(stringKey => decodeKey(stringKey))
|
|
1354
|
+
.filter(candidate => partialMatch(key, candidate))
|
|
1355
|
+
.map(filteredKey => dropFromCache(filteredKey, true))
|
|
1460
1356
|
.every(returned => returned);
|
|
1461
1357
|
}
|
|
1462
1358
|
const encodedKey = encodeKey(key);
|
|
1463
1359
|
if (encodedKey in cache.data) {
|
|
1464
1360
|
delete cache.data[encodedKey];
|
|
1465
|
-
removeFromCacheIndex(cache.data, encodedKey);
|
|
1466
1361
|
return true;
|
|
1467
1362
|
}
|
|
1468
1363
|
return false;
|
|
@@ -3851,20 +3746,13 @@ const getUserMarker = async () => {
|
|
|
3851
3746
|
return { data: latestUserMarker, cachedAt };
|
|
3852
3747
|
};
|
|
3853
3748
|
|
|
3854
|
-
/** Internal model lookup; deliberately excluded from the public Cache API. @hidden */
|
|
3855
|
-
const queryCacheByProperty = (prefix, property, value) => {
|
|
3856
|
-
const { cache } = getActiveClient();
|
|
3857
|
-
if (!cache)
|
|
3858
|
-
return;
|
|
3859
|
-
return getCacheEntriesByProperty(cache.data, prefix, property, value);
|
|
3860
|
-
};
|
|
3861
|
-
|
|
3862
3749
|
const getMessageFromMainDB = (messageId) => {
|
|
3863
|
-
var _a, _b
|
|
3750
|
+
var _a, _b;
|
|
3864
3751
|
const message = (_a = pullFromCache(['message', 'get', messageId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
3865
3752
|
if (message)
|
|
3866
3753
|
return message;
|
|
3867
|
-
|
|
3754
|
+
const messages = queryCache(['message', 'get']);
|
|
3755
|
+
return (_b = messages === null || messages === void 0 ? void 0 : messages.find(({ data }) => data.messageId === messageId)) === null || _b === void 0 ? void 0 : _b.data;
|
|
3868
3756
|
};
|
|
3869
3757
|
|
|
3870
3758
|
/** @hidden */
|
|
@@ -4006,8 +3894,7 @@ function convertFromRaw$2(_a) {
|
|
|
4006
3894
|
|
|
4007
3895
|
const mergePayloadWithLocal = (payload) => {
|
|
4008
3896
|
var _a, _b, _c;
|
|
4009
|
-
|
|
4010
|
-
const localMessage = (_b = (_a = queryCacheByProperty(['message', 'get'], 'messageId', payload.messageId)) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.data;
|
|
3897
|
+
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;
|
|
4011
3898
|
if (localMessage) {
|
|
4012
3899
|
return Object.assign(Object.assign(Object.assign({}, localMessage), payload), {
|
|
4013
3900
|
// NOTE: referenceId is missing in the some payload event. If we have local message data with referenceId, use it instead.
|
|
@@ -5574,9 +5461,9 @@ const channelLinkedObject = (channel) => {
|
|
|
5574
5461
|
var _a;
|
|
5575
5462
|
let previewMembers = [];
|
|
5576
5463
|
if (['conversation', 'community'].includes(channel.type)) {
|
|
5577
|
-
const channelUsers =
|
|
5464
|
+
const channelUsers = queryCache(['channelUsers', 'get']);
|
|
5578
5465
|
if (channelUsers && (channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.length) > 0) {
|
|
5579
|
-
previewMembers = ((_a = channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(({ data }) => data.membership !== 'none')) !== null && _a !== void 0 ? _a : [])
|
|
5466
|
+
previewMembers = ((_a = channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(({ data }) => data.channelId === channel.channelId && data.membership !== 'none')) !== null && _a !== void 0 ? _a : [])
|
|
5580
5467
|
// sort in ascending order by userInternalId
|
|
5581
5468
|
.sort((a, b) => a.data.userInternalId.localeCompare(b.data.userInternalId))
|
|
5582
5469
|
// Select only first 4 members
|
|
@@ -27856,8 +27743,40 @@ getCommentByIds.locally = (commentIds) => {
|
|
|
27856
27743
|
};
|
|
27857
27744
|
};
|
|
27858
27745
|
|
|
27746
|
+
const GIF_OPTIONAL_KEYS = ['width', 'height'];
|
|
27747
|
+
/*
|
|
27748
|
+
* The server refuses a GIF attachment that carries `null` or any key it does not know, so the
|
|
27749
|
+
* request keeps `type`, `url` and only the optional fields that have a value. The SDK does not
|
|
27750
|
+
* check the values themselves: the server answers 400 for a bad one.
|
|
27751
|
+
*/
|
|
27752
|
+
const toGifAttachmentPayload = (gif) => {
|
|
27753
|
+
const payload = { type: 'gif', url: gif.url };
|
|
27754
|
+
GIF_OPTIONAL_KEYS.forEach(key => {
|
|
27755
|
+
const value = gif[key];
|
|
27756
|
+
if (value !== undefined && value !== null)
|
|
27757
|
+
Object.assign(payload, { [key]: value });
|
|
27758
|
+
});
|
|
27759
|
+
return payload;
|
|
27760
|
+
};
|
|
27761
|
+
/* Builds each GIF from its known keys; every other attachment is sent as the caller gave it. */
|
|
27762
|
+
const toAttachmentsPayload = (attachments) => attachments.map(attachment => attachment.type === 'gif'
|
|
27763
|
+
? toGifAttachmentPayload(attachment)
|
|
27764
|
+
: attachment);
|
|
27765
|
+
|
|
27766
|
+
/*
|
|
27767
|
+
* The data types the server lists for a comment, known before it answers: one per attachment
|
|
27768
|
+
* type, plus `text` when there is text. Sorted, as the server sorts them.
|
|
27769
|
+
*/
|
|
27770
|
+
const commentDataTypesOf = (text, attachments) => {
|
|
27771
|
+
const types = new Set((attachments !== null && attachments !== void 0 ? attachments : []).map(attachment => attachment.type));
|
|
27772
|
+
if (text)
|
|
27773
|
+
types.add('text');
|
|
27774
|
+
return [...types].sort();
|
|
27775
|
+
};
|
|
27776
|
+
|
|
27859
27777
|
const getLocalCommentId = () => uuid();
|
|
27860
27778
|
const createCommentOptimistic = (bundle) => {
|
|
27779
|
+
var _a;
|
|
27861
27780
|
const client = getActiveClient();
|
|
27862
27781
|
if (!client.cache)
|
|
27863
27782
|
return;
|
|
@@ -27892,6 +27811,7 @@ const createCommentOptimistic = (bundle) => {
|
|
|
27892
27811
|
targetId: '',
|
|
27893
27812
|
targetType: 'community',
|
|
27894
27813
|
dataType: 'text',
|
|
27814
|
+
dataTypes: commentDataTypesOf((_a = bundle.data) === null || _a === void 0 ? void 0 : _a.text, bundle.attachments),
|
|
27895
27815
|
syncState: "syncing" /* Amity.SyncState.Syncing */,
|
|
27896
27816
|
// In a gated community the optimistic object stays out of public collections until the
|
|
27897
27817
|
// response settles the status; the author's own view still updates through the local event
|
|
@@ -27938,12 +27858,15 @@ const createCommentOptimistic = (bundle) => {
|
|
|
27938
27858
|
const createComment = async (bundle, isOptimistic = true) => {
|
|
27939
27859
|
const client = getActiveClient();
|
|
27940
27860
|
client.log('comment/createComment', Object.assign(Object.assign({}, bundle), { isOptimistic }));
|
|
27861
|
+
// A GIF is sent with its known keys only; the server refuses `null` and unknown keys.
|
|
27862
|
+
const request = bundle.attachments
|
|
27863
|
+
? Object.assign(Object.assign({}, bundle), { attachments: toAttachmentsPayload(bundle.attachments) }) : bundle;
|
|
27941
27864
|
// Without a local comment the server assigns the id; with one, the same id travels through the
|
|
27942
27865
|
// optimistic object, the response and every realtime event so each step recognises it.
|
|
27943
|
-
const optimisticData = isOptimistic ? createCommentOptimistic(
|
|
27866
|
+
const optimisticData = isOptimistic ? createCommentOptimistic(request) : undefined;
|
|
27944
27867
|
const commentId = optimisticData === null || optimisticData === void 0 ? void 0 : optimisticData.commentId;
|
|
27945
27868
|
try {
|
|
27946
|
-
const { data: payload } = await client.http.post('/api/v3/comments', Object.assign(Object.assign({},
|
|
27869
|
+
const { data: payload } = await client.http.post('/api/v3/comments', Object.assign(Object.assign({}, request), { commentId }));
|
|
27947
27870
|
// BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
|
|
27948
27871
|
if (payload.comments.length === 0)
|
|
27949
27872
|
throw new Error('Comment not created');
|
|
@@ -28036,9 +27959,16 @@ const createComment = async (bundle, isOptimistic = true) => {
|
|
|
28036
27959
|
* const updated = await CommentRepository.updateComment(commentId, {
|
|
28037
27960
|
* data: { text: 'hello world' }
|
|
28038
27961
|
* })
|
|
27962
|
+
*
|
|
27963
|
+
* // Replace the GIF, or remove it and keep the text
|
|
27964
|
+
* await CommentRepository.updateComment(commentId, {
|
|
27965
|
+
* attachments: [{ type: 'gif', url: 'https://media.giphy.com/media/l0MYt5jPR6QX5pnqM/giphy.gif' }],
|
|
27966
|
+
* })
|
|
27967
|
+
* await CommentRepository.updateComment(commentId, { attachments: [] })
|
|
28039
27968
|
* ```
|
|
28040
27969
|
*
|
|
28041
|
-
* Updates an {@link Amity.Comment}
|
|
27970
|
+
* Updates an {@link Amity.Comment}. `attachments` replaces the current ones, `[]` removes them,
|
|
27971
|
+
* and leaving `attachments` out keeps them as they are.
|
|
28042
27972
|
*
|
|
28043
27973
|
* @param commentId The ID of the {@link Amity.Comment} to edit
|
|
28044
27974
|
* @param patch The patch data to apply
|
|
@@ -28052,7 +27982,10 @@ const updateComment = async (commentId, patch) => {
|
|
|
28052
27982
|
const client = getActiveClient();
|
|
28053
27983
|
client.log('user/updateComment', patch);
|
|
28054
27984
|
const previous = (_a = pullFromCache(['comment', 'get', commentId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28055
|
-
|
|
27985
|
+
// A GIF is sent with its known keys only; the server refuses `null` and unknown keys.
|
|
27986
|
+
const body = patch.attachments
|
|
27987
|
+
? Object.assign(Object.assign({}, patch), { attachments: toAttachmentsPayload(patch.attachments) }) : patch;
|
|
27988
|
+
const { data: payload } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, body);
|
|
28056
27989
|
const data = prepareCommentPayload(payload);
|
|
28057
27990
|
const updated = data.comments.find(comment => comment.commentId === commentId);
|
|
28058
27991
|
const cachedAt = client.cache && Date.now();
|
|
@@ -28183,13 +28116,13 @@ const deleteComment = async (commentId, permanent = false) => {
|
|
|
28183
28116
|
permanent,
|
|
28184
28117
|
},
|
|
28185
28118
|
});
|
|
28186
|
-
// to support hard deletion
|
|
28187
|
-
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
|
|
28119
|
+
// to support hard deletion; the server empties a deleted comment's attachments
|
|
28120
|
+
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true, attachments: [] });
|
|
28188
28121
|
if (permanent) {
|
|
28189
28122
|
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
28190
28123
|
}
|
|
28191
28124
|
else {
|
|
28192
|
-
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
28125
|
+
upsertInCache(['comment', 'get', commentId], { isDeleted: true, attachments: [] });
|
|
28193
28126
|
}
|
|
28194
28127
|
if (comment.data.referenceType === 'story') {
|
|
28195
28128
|
const story = await getStoryByStoryId$1(comment.data.referenceId);
|