@amityco/ts-sdk-react-native 6.34.1-b036e5d.0 → 6.35.1
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/domains/client.d.ts +2 -2
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/client/api/createClient.d.ts +2 -1
- package/dist/client/api/createClient.d.ts.map +1 -1
- package/dist/client/api/isConnected.d.ts.map +1 -1
- package/dist/client/api/logout.d.ts.map +1 -1
- package/dist/client/utils/modifyMqttConnection.d.ts.map +1 -1
- package/dist/core/subscription.d.ts.map +1 -1
- package/dist/index.cjs.js +130 -19
- package/dist/index.esm.js +130 -19
- package/dist/index.umd.js +3 -3
- package/dist/storyRepository/api/createImageStory.d.ts.map +1 -1
- package/dist/storyRepository/api/createVideoStory.d.ts.map +1 -1
- package/dist/storyRepository/internalApi/deleteStory.d.ts.map +1 -1
- package/dist/storyRepository/observers/getActiveStoriesByTarget.d.ts.map +1 -1
- package/dist/storyRepository/observers/getGlobalStoryTargets/GlobalStoryLiveCollectionController.d.ts.map +1 -1
- package/dist/storyRepository/utils/createOptimisticTarget.d.ts +5 -0
- package/dist/storyRepository/utils/createOptimisticTarget.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/@types/domains/client.ts +2 -2
- package/src/client/api/createClient.ts +10 -2
- package/src/client/api/isConnected.ts +4 -1
- package/src/client/api/login.ts +1 -1
- package/src/client/api/logout.ts +6 -5
- package/src/client/utils/modifyMqttConnection.ts +2 -0
- package/src/client/utils/setClientToken.ts +1 -1
- package/src/core/events.ts +2 -2
- package/src/core/subscription.ts +2 -0
- package/src/core/transports/ws.ts +1 -1
- package/src/storyRepository/api/createImageStory.ts +3 -0
- package/src/storyRepository/api/createVideoStory.ts +3 -0
- package/src/storyRepository/internalApi/deleteStory.ts +74 -0
- package/src/storyRepository/observers/getActiveStoriesByTarget.ts +16 -1
- package/src/storyRepository/observers/getGlobalStoryTargets/GlobalStoryLiveCollectionController.ts +14 -2
- package/src/storyRepository/utils/StoryComputedValue.ts +2 -2
- package/src/storyRepository/utils/createOptimisticTarget.ts +46 -0
package/.env
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
LIVE_STREAM_KEY='-----BEGIN PRIVATE KEY-----
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/
|
|
20
|
-
+
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
2
|
+
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2
|
|
3
|
+
hFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM
|
|
4
|
+
js6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR
|
|
5
|
+
iGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j
|
|
6
|
+
Lseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l
|
|
7
|
+
W3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH
|
|
8
|
+
bZWJ2a5NAgMBAAECggEASxuE+35zTFO/XydKgmvIGcWL9FbgMlXb7Vcf0nBoG945
|
|
9
|
+
biz0NVc2paraIhJXc608xbYF3qLmtAE1MVBI0ORyRdBHNxY024l/6H6SH60Ed+uI
|
|
10
|
+
M4ysp5ourY6Vj+DLwpdRiI9YDj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llgOaZOkql
|
|
25
|
+
LVMJVmgR7s6tLi1+cEP8ZcapV9aRbRzTAKXm4f8AEhtlG9F9kCOvHYCYGi6JaiWJ
|
|
26
|
+
ZkHjeex3T+eE6Di6y5Bm/Ift5jtVhJ4jCVwHOKTMej79NPUFTJfv8hCo29haBDv6
|
|
27
|
+
RXFrv+T21KCcw8k3sJeJWWQ=
|
|
28
28
|
-----END PRIVATE KEY-----'
|
|
@@ -20,8 +20,8 @@ declare global {
|
|
|
20
20
|
version: string;
|
|
21
21
|
log: Logger;
|
|
22
22
|
http: AxiosInstance;
|
|
23
|
-
mqtt
|
|
24
|
-
ws
|
|
23
|
+
mqtt?: Amity.MqttClient;
|
|
24
|
+
ws?: SocketIOClient.Socket;
|
|
25
25
|
emitter: Emitter<Amity.Events>;
|
|
26
26
|
hasPermission: (permission: string) => Amity.PermissionChecker;
|
|
27
27
|
validateUrls: (urls: string[]) => Promise<boolean>;
|
|
@@ -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;YAC5B,YAAY,iBAAiB;SAC9B;QAED,WAAW,aAAa;YACtB,aAAa,gBAAgB;YAE7B,YAAY,iBAAiB;YAC7B,WAAW,gBAAgB;YAE3B,aAAa,iBAAiB;YAW9B,UAAU,eAAe;SAC1B;QAED,KAAK,MAAM,GAAG;YACZ,OAAO,EAAE,MAAM,CAAC;YAEhB,GAAG,EAAE,MAAM,CA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AM,GAAG,aAAa,CAAC,CAAC;QAEtF,KAAK,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG;YACxD;;eAEG;YACH,YAAY,EAAE,OAAO,CAAC;YACtB,WAAW,EAAE,OAAO,CAAC;SACtB,CAAC;KACH;CACF"}
|
|
@@ -15,12 +15,13 @@ import { API_REGIONS } from '~/client/utils/endpoints';
|
|
|
15
15
|
*
|
|
16
16
|
* @category Client API
|
|
17
17
|
* */
|
|
18
|
-
export declare const createClient: (apiKey: string, apiRegion?: (typeof API_REGIONS)[keyof typeof API_REGIONS], { debugSession, apiEndpoint, prefixDeviceIdKey, }?: {
|
|
18
|
+
export declare const createClient: (apiKey: string, apiRegion?: (typeof API_REGIONS)[keyof typeof API_REGIONS], { debugSession, apiEndpoint, prefixDeviceIdKey, rteEnabled, }?: {
|
|
19
19
|
debugSession?: string | undefined;
|
|
20
20
|
apiEndpoint?: {
|
|
21
21
|
http?: string | undefined;
|
|
22
22
|
mqtt?: string | undefined;
|
|
23
23
|
} | undefined;
|
|
24
24
|
prefixDeviceIdKey?: string | undefined;
|
|
25
|
+
rteEnabled?: boolean | undefined;
|
|
25
26
|
}) => Amity.Client;
|
|
26
27
|
//# sourceMappingURL=createClient.d.ts.map
|
|
@@ -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;AAsBnE;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,YAAY,WACf,MAAM,cACH,CAAA,kBAAkB,EAAC,MAAM,kBAAkB,CAAC
|
|
1
|
+
{"version":3,"file":"createClient.d.ts","sourceRoot":"","sources":["../../../src/client/api/createClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAc,MAAM,0BAA0B,CAAC;AAsBnE;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,YAAY,WACf,MAAM,cACH,CAAA,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;;;;;;;;MAYtD,MAAM,MAkHR,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isConnected.d.ts","sourceRoot":"","sources":["../../../src/client/api/isConnected.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,QAAO,
|
|
1
|
+
{"version":3,"file":"isConnected.d.ts","sourceRoot":"","sources":["../../../src/client/api/isConnected.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,QAAO,OAY9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/client/api/logout.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,QAAa,QAAQ,OAAO,
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/client/api/logout.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,QAAa,QAAQ,OAAO,CAyD9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modifyMqttConnection.d.ts","sourceRoot":"","sources":["../../../src/client/utils/modifyMqttConnection.ts"],"names":[],"mappings":"AAOA,wBAAsB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"modifyMqttConnection.d.ts","sourceRoot":"","sources":["../../../src/client/utils/modifyMqttConnection.ts"],"names":[],"mappings":"AAOA,wBAAsB,oBAAoB,kBAezC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/core/subscription.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIzC,oBAAY,kBAAkB;IAC5B,SAAS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Aa,MAAM,YAAY,KAAG,MAA6B,CAAC;AAE5F,eAAO,MAAM,kBAAkB,eAAgB,MAAM,YAAY,KAAG,MAC5C,CAAC;AAEzB,eAAO,MAAM,eAAe,YAAa,MAAM,YAAY,KAAG,MAAsB,CAAC;AAErF,eAAO,MAAM,qBAAqB,iCAG/B,KAAK,MAAM,UAAU,EAAE,WAAW,GAAG,cAAc,CAAC,KAAG,MAIzD,CAAC;AAEF,eAAO,MAAM,sBAAsB,cAIlC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAO,MAElC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAAO,MAI3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,QAAO,MAI9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAAO,MAI3C,CAAC;AAKF,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,GACzC,KAAK,CAAC,YAAY,CAOpB"}
|
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 ''v6.
|
|
127
|
-
return 'v6.
|
|
126
|
+
// the string ''v6.35.1-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
127
|
+
return 'v6.35.1-cjs';
|
|
128
128
|
}
|
|
129
129
|
catch (error) {
|
|
130
130
|
return '__dev__';
|
|
@@ -1382,14 +1382,14 @@ const createEventEmitter = () => {
|
|
|
1382
1382
|
*/
|
|
1383
1383
|
const proxyWebsocketEvents = (ws, emitter) => {
|
|
1384
1384
|
WS_EVENTS.forEach(event => {
|
|
1385
|
-
ws.on(event, (param) => {
|
|
1385
|
+
ws === null || ws === void 0 ? void 0 : ws.on(event, (param) => {
|
|
1386
1386
|
emitter.emit(event, param);
|
|
1387
1387
|
});
|
|
1388
1388
|
});
|
|
1389
1389
|
};
|
|
1390
1390
|
const proxyMqttEvents = (mqttClient, emitter) => {
|
|
1391
1391
|
MQTT_EVENTS.forEach(event => {
|
|
1392
|
-
mqttClient.on(event, (...params) => {
|
|
1392
|
+
mqttClient === null || mqttClient === void 0 ? void 0 : mqttClient.on(event, (...params) => {
|
|
1393
1393
|
emitter.emit(event, params.length === 1 ? params[0] : params);
|
|
1394
1394
|
});
|
|
1395
1395
|
});
|
|
@@ -1447,6 +1447,8 @@ let mqttUserId;
|
|
|
1447
1447
|
async function modifyMqttConnection() {
|
|
1448
1448
|
var _a;
|
|
1449
1449
|
const { mqtt, emitter, token } = getActiveClient();
|
|
1450
|
+
if (!mqtt)
|
|
1451
|
+
return;
|
|
1450
1452
|
const accessToken = (_a = token === null || token === void 0 ? void 0 : token.accessToken) !== null && _a !== void 0 ? _a : '';
|
|
1451
1453
|
const user = getActiveUser();
|
|
1452
1454
|
if (mqttAccessToken !== accessToken || mqttUserId !== user._id) {
|
|
@@ -1557,6 +1559,8 @@ const getSmartFeedMessageTopic = () => {
|
|
|
1557
1559
|
};
|
|
1558
1560
|
function subscribeTopic(topic, callback) {
|
|
1559
1561
|
const { mqtt } = getActiveClient();
|
|
1562
|
+
if (!mqtt)
|
|
1563
|
+
return () => null;
|
|
1560
1564
|
modifyMqttConnection();
|
|
1561
1565
|
return mqtt.subscribe(topic, callback);
|
|
1562
1566
|
}
|
|
@@ -5280,8 +5284,8 @@ class StoryComputedValue {
|
|
|
5280
5284
|
return;
|
|
5281
5285
|
}
|
|
5282
5286
|
const groupByType = stories.reduce((acc, story) => {
|
|
5283
|
-
const { data: { targetId, syncState }, } = story;
|
|
5284
|
-
if (targetId === this._targetId) {
|
|
5287
|
+
const { data: { targetId, syncState, isDeleted }, } = story;
|
|
5288
|
+
if (targetId === this._targetId && !isDeleted) {
|
|
5285
5289
|
acc[syncState] += 1;
|
|
5286
5290
|
}
|
|
5287
5291
|
return acc;
|
|
@@ -7819,7 +7823,8 @@ const setClientToken = async (params) => {
|
|
|
7819
7823
|
isUserDeleted: false,
|
|
7820
7824
|
};
|
|
7821
7825
|
// manually setup the token for ws transport
|
|
7822
|
-
client.ws
|
|
7826
|
+
if (client.ws)
|
|
7827
|
+
client.ws.io.opts.query = { token: accessToken };
|
|
7823
7828
|
client.token = { accessToken, issuedAt, expiresAt };
|
|
7824
7829
|
setSessionState("established" /* Amity.SessionStates.ESTABLISHED */);
|
|
7825
7830
|
return { accessToken, users };
|
|
@@ -8167,12 +8172,13 @@ var objectResolverEngineOnLoginHandler = () => {
|
|
|
8167
8172
|
* @async
|
|
8168
8173
|
*/
|
|
8169
8174
|
const logout = async () => {
|
|
8175
|
+
var _a, _b;
|
|
8170
8176
|
const client = getActiveClient();
|
|
8171
8177
|
client.log('client/api/disconnectClient');
|
|
8172
|
-
if (client.mqtt.connected) {
|
|
8178
|
+
if (client.mqtt && client.mqtt.connected) {
|
|
8173
8179
|
client.mqtt.disconnect();
|
|
8174
8180
|
}
|
|
8175
|
-
if (client.ws.connected) {
|
|
8181
|
+
if (client.ws && client.ws.connected) {
|
|
8176
8182
|
client.ws.disconnect();
|
|
8177
8183
|
}
|
|
8178
8184
|
/*
|
|
@@ -8191,8 +8197,8 @@ const logout = async () => {
|
|
|
8191
8197
|
setSessionState("notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */);
|
|
8192
8198
|
client.emitter.all.clear();
|
|
8193
8199
|
// FIXME: it removes listener in ws.ts, it breaks global ban event
|
|
8194
|
-
client.ws.removeAllListeners();
|
|
8195
|
-
client.mqtt.removeAllListeners();
|
|
8200
|
+
(_a = client.ws) === null || _a === void 0 ? void 0 : _a.removeAllListeners();
|
|
8201
|
+
(_b = client.mqtt) === null || _b === void 0 ? void 0 : _b.removeAllListeners();
|
|
8196
8202
|
client.userId = undefined;
|
|
8197
8203
|
client.token = undefined;
|
|
8198
8204
|
client.http.defaults.headers.common.Authorization = '';
|
|
@@ -8201,7 +8207,8 @@ const logout = async () => {
|
|
|
8201
8207
|
isGlobalBanned: false,
|
|
8202
8208
|
isUserDeleted: false,
|
|
8203
8209
|
};
|
|
8204
|
-
client.ws
|
|
8210
|
+
if (client.ws)
|
|
8211
|
+
client.ws.io.opts.query = { token: '' };
|
|
8205
8212
|
if (typeof document !== 'undefined') {
|
|
8206
8213
|
document.cookie = '_ascSession=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
|
|
8207
8214
|
}
|
|
@@ -9184,6 +9191,7 @@ async function runMqtt() {
|
|
|
9184
9191
|
* @async
|
|
9185
9192
|
*/
|
|
9186
9193
|
const login = async (params, sessionHandler, config) => {
|
|
9194
|
+
var _a;
|
|
9187
9195
|
const client = getActiveClient();
|
|
9188
9196
|
let unsubWatcher;
|
|
9189
9197
|
client.log('client/api/connectClient', Object.assign({ apiKey: client.apiKey, sessionState: client.sessionState }, params));
|
|
@@ -9218,7 +9226,7 @@ const login = async (params, sessionHandler, config) => {
|
|
|
9218
9226
|
// FIXME: events are duplicated if connectClient is called few times without disconnectClient
|
|
9219
9227
|
// wire websocket events to our event emitter
|
|
9220
9228
|
proxyWebsocketEvents(client.ws, client.emitter);
|
|
9221
|
-
client.ws.open();
|
|
9229
|
+
(_a = client.ws) === null || _a === void 0 ? void 0 : _a.open();
|
|
9222
9230
|
client.userId = user.userId;
|
|
9223
9231
|
client.sessionHandler = sessionHandler;
|
|
9224
9232
|
/*
|
|
@@ -9423,7 +9431,7 @@ const DEFAULT_DEBUG_SESSION = 'amity';
|
|
|
9423
9431
|
*
|
|
9424
9432
|
* @category Client API
|
|
9425
9433
|
* */
|
|
9426
|
-
const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAULT_DEBUG_SESSION, apiEndpoint, prefixDeviceIdKey, } = {}) => {
|
|
9434
|
+
const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAULT_DEBUG_SESSION, apiEndpoint, prefixDeviceIdKey, rteEnabled = true, } = {}) => {
|
|
9427
9435
|
var _a, _b;
|
|
9428
9436
|
const log = createLogger(debugSession);
|
|
9429
9437
|
log('client/api/createClient', {
|
|
@@ -9433,8 +9441,12 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
9433
9441
|
const httpEndpoint = (_a = apiEndpoint === null || apiEndpoint === void 0 ? void 0 : apiEndpoint.http) !== null && _a !== void 0 ? _a : computeUrl('http', apiRegion);
|
|
9434
9442
|
const mqttEndpoint = (_b = apiEndpoint === null || apiEndpoint === void 0 ? void 0 : apiEndpoint.mqtt) !== null && _b !== void 0 ? _b : computeUrl('mqtt', apiRegion);
|
|
9435
9443
|
const http = createHttpTransport(httpEndpoint);
|
|
9436
|
-
|
|
9437
|
-
|
|
9444
|
+
let ws;
|
|
9445
|
+
let mqtt;
|
|
9446
|
+
if (rteEnabled) {
|
|
9447
|
+
ws = createWebsocketTransport(httpEndpoint);
|
|
9448
|
+
mqtt = createMqttTransport(mqttEndpoint);
|
|
9449
|
+
}
|
|
9438
9450
|
const emitter = createEventEmitter();
|
|
9439
9451
|
/*
|
|
9440
9452
|
* Since v6 cache is enabled by default
|
|
@@ -9558,9 +9570,11 @@ const isConnected = () => {
|
|
|
9558
9570
|
var _a, _b;
|
|
9559
9571
|
const client = getActiveClient();
|
|
9560
9572
|
client.log('client/api/isConnected', client);
|
|
9573
|
+
// if client is connected to ws, it means client is connected. If ws is undefined, it means ws is not used.
|
|
9574
|
+
const isWsConnected = (client.ws && client.ws.connected) || !!client.ws;
|
|
9561
9575
|
return !!(client.userId &&
|
|
9562
9576
|
((_b = String((_a = client.http.defaults.headers.common) === null || _a === void 0 ? void 0 : _a.Authorization)) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
9563
|
-
|
|
9577
|
+
isWsConnected);
|
|
9564
9578
|
};
|
|
9565
9579
|
|
|
9566
9580
|
var _GlobalFileAccessType_fileAccessType;
|
|
@@ -25432,7 +25446,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
25432
25446
|
getPoll: getPoll
|
|
25433
25447
|
});
|
|
25434
25448
|
|
|
25435
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
25449
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM\njs6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR\niGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j\nLseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l\nW3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH\nbZWJ2a5NAgMBAAECggEASxuE+35zTFO/XydKgmvIGcWL9FbgMlXb7Vcf0nBoG945\nbiz0NVc2paraIhJXc608xbYF3qLmtAE1MVBI0ORyRdBHNxY024l/6H6SH60Ed+uI\nM4ysp5ourY6Vj+DLwpdRiI9YDjqYAQDIUmhNxJP7XPhOMoZI6st+xZQBM34ic/bv\nAMSJm9OZphSp3+qXVkFZztr2mxD2EZSJJLYxi8BCdgM2qhazalbcJ6zDKHCZWVWm\n8RRxDGldyMb/237JxETzP40tAlzOZDmBAbUgEnurDJ93RVDIE3rbZUshwgeQd18a\nem096mWgvB1AIKYgsTAR3pw+V19YWAjq/glP6fz8wQKBgQD/oQq+ukKF0PRgBeM5\ngeTjSwsdGppQLmf5ndujvoiz/TpdjDEPu6R8kigQr1rG2t4K/yfdZoI8RdmJD1al\n3Q7N9hofooSy4rj6E3txzWZCHJjHad2cnCp/O26HiReGAl7wTcfTmNdiFHhZQzm5\nJBkvWAiwuvQMNfEbnXxw6/vIDwKBgQDH7fX8gsc77JLvAWgp1MaQN/sbqVb6JeT1\nFQfR8E/WFCSmzQBtNzd5KgYuCeelwr/8DyYytvN2BzCYZXp73gI1jF3YlW5jVn74\nOY6TwQ095digwo6Z0yuxopdIOApKgAkL9PRKgNrqAf3NAyMua6lOGifzjDojC3KU\nfylQmxMn4wKBgHp2B9O/H0dEBw5JQ8W0+JX6yWQz7mEjGiR2/1W+XXb8hQ1zr709\nw1r6Gb+EghRpnZ3fBpYGGbYOMFx8wKHM+N6qW3F0ReX8v2juFGE8aRSa5oYBrWzt\nU16Idjbv8hj84cZ1PJmdyvDtpYn9rpWHOZl4rxEbPvbqkIsOMyNVqdT5AoGAOSge\nmwIIU2le2FVeohbibXiToWTYKMuMmURZ5/r72AgKMmWJKbAPe+Q3wBG01/7FRBpQ\noU8Ma0HC8s6QJbliiEyIx9JwrJWd1vkdecBHONrtA4ibm/5zD2WcOllLF+FitLhi\n3qnX6+6F0IaFGFBPJrTzlv0P4dTz/OAdv52V7GECgYEA2TttOKBAqWllgOaZOkql\nLVMJVmgR7s6tLi1+cEP8ZcapV9aRbRzTAKXm4f8AEhtlG9F9kCOvHYCYGi6JaiWJ\nZkHjeex3T+eE6Di6y5Bm/Ift5jtVhJ4jCVwHOKTMej79NPUFTJfv8hCo29haBDv6\nRXFrv+T21KCcw8k3sJeJWWQ=\n-----END PRIVATE KEY-----";
|
|
25436
25450
|
/*
|
|
25437
25451
|
* The crypto algorithm used for importing key and signing string
|
|
25438
25452
|
*/
|
|
@@ -25868,6 +25882,30 @@ const createStory = async (payload) => {
|
|
|
25868
25882
|
};
|
|
25869
25883
|
};
|
|
25870
25884
|
|
|
25885
|
+
const createOptimisticTarget = async ({ targetId, targetType, }) => {
|
|
25886
|
+
var _a, _b;
|
|
25887
|
+
const targetCache = pullFromCache([
|
|
25888
|
+
"storyTarget" /* STORY_KEY_CACHE.STORY_TARGET */,
|
|
25889
|
+
'get',
|
|
25890
|
+
targetId,
|
|
25891
|
+
]);
|
|
25892
|
+
if (!targetCache) {
|
|
25893
|
+
let optimisticTarget = {
|
|
25894
|
+
targetId,
|
|
25895
|
+
targetType,
|
|
25896
|
+
};
|
|
25897
|
+
if (targetType === 'community') {
|
|
25898
|
+
const community = await getCommunity$1(targetId);
|
|
25899
|
+
optimisticTarget = Object.assign(Object.assign({}, optimisticTarget), { targetPublicId: community.data.communityId, targetUpdatedAt: (_a = community.data.updatedAt) !== null && _a !== void 0 ? _a : new Date().toISOString() });
|
|
25900
|
+
}
|
|
25901
|
+
if (targetType === 'user') {
|
|
25902
|
+
const user = await getUser$2(targetId);
|
|
25903
|
+
optimisticTarget = Object.assign(Object.assign({}, optimisticTarget), { targetPublicId: user.data.userPublicId, targetUpdatedAt: (_b = user.data.updatedAt) !== null && _b !== void 0 ? _b : new Date().toISOString() });
|
|
25904
|
+
}
|
|
25905
|
+
pushToCache(["storyTarget" /* STORY_KEY_CACHE.STORY_TARGET */, 'get', targetId], optimisticTarget);
|
|
25906
|
+
}
|
|
25907
|
+
};
|
|
25908
|
+
|
|
25871
25909
|
/**
|
|
25872
25910
|
* ```js
|
|
25873
25911
|
* import { StoryRepository } from '@amityco/ts-sdk-react-native'
|
|
@@ -25917,6 +25955,7 @@ const createImageStory = async (targetType, targetId, formData, metadata = {}, i
|
|
|
25917
25955
|
throw new Error('Failed to upload image');
|
|
25918
25956
|
const { fileId } = data[0];
|
|
25919
25957
|
payload = Object.assign(Object.assign({}, payload), { data: Object.assign(Object.assign({}, payload.data), { fileId }) });
|
|
25958
|
+
createOptimisticTarget({ targetId, targetType });
|
|
25920
25959
|
// Fire optimistic event - update fileId
|
|
25921
25960
|
createOptimisticEvent({ payload, formData }, optimisticData => {
|
|
25922
25961
|
fireEvent('local.story.created', optimisticData);
|
|
@@ -25970,6 +26009,7 @@ const createVideoStory = async (targetType, targetId, formData, metadata = {}, i
|
|
|
25970
26009
|
pushToCache(["story-sync-state" /* STORY_KEY_CACHE.SYNC_STATE */, targetId], "syncing" /* Amity.SyncState.Syncing */);
|
|
25971
26010
|
// Update local story expires time
|
|
25972
26011
|
pushToCache(["story-expire" /* STORY_KEY_CACHE.EXPIRE */, targetId], new Date(date.setFullYear(date.getFullYear() + 1)));
|
|
26012
|
+
createOptimisticTarget({ targetId, targetType });
|
|
25973
26013
|
// Fire optimistic event
|
|
25974
26014
|
createOptimisticEvent({ payload, formData, isVideo: true }, optimisticData => {
|
|
25975
26015
|
fireEvent('local.story.created', optimisticData);
|
|
@@ -26007,6 +26047,7 @@ const getStoryCache = (storyId) => {
|
|
|
26007
26047
|
};
|
|
26008
26048
|
|
|
26009
26049
|
const deleteStory = async (storyId, permanent = false) => {
|
|
26050
|
+
var _a, _b, _c;
|
|
26010
26051
|
const client = getActiveClient();
|
|
26011
26052
|
client.log('story/deleteStory', storyId);
|
|
26012
26053
|
let cached;
|
|
@@ -26023,6 +26064,57 @@ const deleteStory = async (storyId, permanent = false) => {
|
|
|
26023
26064
|
users: [],
|
|
26024
26065
|
stories: [Object.assign(Object.assign({}, data), { isDeleted: true })],
|
|
26025
26066
|
});
|
|
26067
|
+
/* ------ Unsynced story case ------ */
|
|
26068
|
+
if (data.syncState !== "synced" /* Amity.SyncState.Synced */) {
|
|
26069
|
+
if (permanent) {
|
|
26070
|
+
dropFromCache(["story" /* STORY_KEY_CACHE.STORY */, 'get', storyId]);
|
|
26071
|
+
}
|
|
26072
|
+
else {
|
|
26073
|
+
pushToCache(["story" /* STORY_KEY_CACHE.STORY */, 'get', storyId], Object.assign(Object.assign({}, cached.data), { isDeleted: true }));
|
|
26074
|
+
}
|
|
26075
|
+
const unsyncedStoriesCache = (_a = queryCache([
|
|
26076
|
+
"story" /* STORY_KEY_CACHE.STORY */,
|
|
26077
|
+
'get',
|
|
26078
|
+
])) === null || _a === void 0 ? void 0 : _a.filter(story => story.data.syncState !== "synced" /* Amity.SyncState.Synced */ &&
|
|
26079
|
+
story.data.targetId === data.targetId &&
|
|
26080
|
+
story.data.isDeleted !== true);
|
|
26081
|
+
// update localLastStoryExpiresAt to be the last story expires
|
|
26082
|
+
if (unsyncedStoriesCache && unsyncedStoriesCache.length > 0) {
|
|
26083
|
+
const lastStoryExpires = unsyncedStoriesCache.reduce((acc, story) => {
|
|
26084
|
+
const expireAt = new Date(story.data.expiresAt || 0);
|
|
26085
|
+
return expireAt > acc ? expireAt : acc;
|
|
26086
|
+
}, new Date(0));
|
|
26087
|
+
pushToCache(["story-expire" /* STORY_KEY_CACHE.EXPIRE */, cached.data.targetId], lastStoryExpires.toISOString());
|
|
26088
|
+
}
|
|
26089
|
+
else {
|
|
26090
|
+
// if no unsynced stories, remove last story expires since there is no more story
|
|
26091
|
+
dropFromCache(["story-expire" /* STORY_KEY_CACHE.EXPIRE */, cached.data.targetId]);
|
|
26092
|
+
}
|
|
26093
|
+
return true;
|
|
26094
|
+
}
|
|
26095
|
+
/* ------ Synced story case ------ */
|
|
26096
|
+
const targetCache = (_b = pullFromCache([
|
|
26097
|
+
"storyTarget" /* STORY_KEY_CACHE.STORY_TARGET */,
|
|
26098
|
+
'get',
|
|
26099
|
+
data.targetId,
|
|
26100
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
26101
|
+
const syncedStoriesCache = (_c = queryCache([
|
|
26102
|
+
"story" /* STORY_KEY_CACHE.STORY */,
|
|
26103
|
+
'get',
|
|
26104
|
+
])) === null || _c === void 0 ? void 0 : _c.filter(story => story.data.syncState === "synced" /* Amity.SyncState.Synced */ &&
|
|
26105
|
+
story.data.targetId === data.targetId &&
|
|
26106
|
+
story.data.isDeleted !== true);
|
|
26107
|
+
let lastStoryExpiresAt;
|
|
26108
|
+
if (syncedStoriesCache && syncedStoriesCache.length > 0) {
|
|
26109
|
+
lastStoryExpiresAt = syncedStoriesCache === null || syncedStoriesCache === void 0 ? void 0 : syncedStoriesCache.reduce((acc, story) => {
|
|
26110
|
+
const expireAt = new Date(story.data.expiresAt || 0);
|
|
26111
|
+
return expireAt > acc ? expireAt : acc;
|
|
26112
|
+
}, new Date(0));
|
|
26113
|
+
}
|
|
26114
|
+
// update lastStoryExpiresAt from lastest synced story
|
|
26115
|
+
if (targetCache) {
|
|
26116
|
+
pushToCache(["storyTarget" /* STORY_KEY_CACHE.STORY_TARGET */, 'get', data.targetId], Object.assign(Object.assign({}, targetCache), { lastStoryExpiresAt }));
|
|
26117
|
+
}
|
|
26026
26118
|
}
|
|
26027
26119
|
}
|
|
26028
26120
|
const response = await client.http.delete(`/api/v4/stories/${storyId}`, {
|
|
@@ -26335,6 +26427,7 @@ const getActiveStoriesByTarget = (params, callback) => {
|
|
|
26335
26427
|
});
|
|
26336
26428
|
};
|
|
26337
26429
|
const processNewData = (result, event, initial = false, loading = false, error = false) => {
|
|
26430
|
+
var _a;
|
|
26338
26431
|
const cached = pullFromCache(cacheKey);
|
|
26339
26432
|
const data = {
|
|
26340
26433
|
loading,
|
|
@@ -26353,6 +26446,14 @@ const getActiveStoriesByTarget = (params, callback) => {
|
|
|
26353
26446
|
: [...new Set([...data.data, ...result.map(getResolver('story'))])];
|
|
26354
26447
|
}
|
|
26355
26448
|
}
|
|
26449
|
+
const unSyncedStories = (_a = queryCache(["story" /* STORY_KEY_CACHE.STORY */, 'get'])) === null || _a === void 0 ? void 0 : _a.filter(story => story.data.targetId === params.targetId &&
|
|
26450
|
+
story.data.syncState !== "synced" /* Amity.SyncState.Synced */).map(story => getResolver('story')(story.data));
|
|
26451
|
+
if (unSyncedStories && (unSyncedStories === null || unSyncedStories === void 0 ? void 0 : unSyncedStories.length) > 0) {
|
|
26452
|
+
unSyncedStories.forEach(referenceId => {
|
|
26453
|
+
if (!data.data.includes(referenceId))
|
|
26454
|
+
data.data.push(referenceId);
|
|
26455
|
+
});
|
|
26456
|
+
}
|
|
26356
26457
|
pushToCache(cacheKey, data.data);
|
|
26357
26458
|
responder(data);
|
|
26358
26459
|
};
|
|
@@ -26784,13 +26885,23 @@ class GlobalStoryLiveCollectionController extends LiveCollectionController {
|
|
|
26784
26885
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26785
26886
|
if (!collection)
|
|
26786
26887
|
return;
|
|
26787
|
-
|
|
26888
|
+
const targetIds = collection.data;
|
|
26889
|
+
const cachedTargets = queryCache(["storyTarget" /* STORY_KEY_CACHE.STORY_TARGET */]);
|
|
26890
|
+
if (cachedTargets && (cachedTargets === null || cachedTargets === void 0 ? void 0 : cachedTargets.length) > 0) {
|
|
26891
|
+
cachedTargets === null || cachedTargets === void 0 ? void 0 : cachedTargets.forEach(({ key }) => {
|
|
26892
|
+
if (!collection.data.includes(key[2]))
|
|
26893
|
+
targetIds.push(key[2]);
|
|
26894
|
+
});
|
|
26895
|
+
}
|
|
26896
|
+
let data = targetIds
|
|
26788
26897
|
.map(targetId => pullFromCache(["storyTarget" /* STORY_KEY_CACHE.STORY_TARGET */, 'get', targetId]))
|
|
26789
26898
|
.filter(Boolean)
|
|
26790
26899
|
.map(storyTarget => LinkedObject.storyTarget(storyTarget.data));
|
|
26791
26900
|
if (!this.shouldNotify(data) && origin === 'event')
|
|
26792
26901
|
return;
|
|
26793
26902
|
data = this.applyFilter(data)
|
|
26903
|
+
// exclude story targets with invalid stories
|
|
26904
|
+
.filter(({ localSortingDate }) => !!localSortingDate)
|
|
26794
26905
|
// Remove internal fields
|
|
26795
26906
|
.map((_a) => {
|
|
26796
26907
|
var rest = __rest(_a, ["localFilter", "localLastExpires", "localLastSeen", "localSortingDate"]);
|