@amityco/ts-sdk 7.28.1-1ea66ee3.0 → 7.28.1-6dd86e81.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.
@@ -2,6 +2,14 @@ declare type ActivityFields = {
2
2
  lastActivity?: boolean;
3
3
  lastMessageAt?: boolean;
4
4
  };
5
+ /**
6
+ * The channel cache is keyed by `channelInternalId`, but a message names its
7
+ * channel by whichever id the producer had: the raw MQTT payload carries the
8
+ * internal id, a converted `Amity.InternalMessage` carries the public id, and
9
+ * the optimistic message carries the sub-channel's `channelId`. Try the direct
10
+ * key first, then match any of the three ids.
11
+ */
12
+ export declare const findCachedChannel: (channelId: string) => Amity.StaticInternalChannel | undefined;
5
13
  /**
6
14
  * Single owner of every local write to a channel's ordering timestamps,
7
15
  * `lastActivity` and `lastMessageAt` (ChannelActivityService v1).
@@ -1 +1 @@
1
- {"version":3,"file":"updateChannelActivityTimestamps.d.ts","sourceRoot":"","sources":["../../../src/channelRepository/utils/updateChannelActivityTimestamps.ts"],"names":[],"mappings":"AAOA,aAAK,cAAc,GAAG;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAoDF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,+BAA+B,cAC/B,MAAM,GAAG,SAAS,MACzB,MAAM,SAAS,GAAG,SAAS,WACvB,cAAc,KACrB,OAaF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,cACjB,MAAM,GAAG,SAAS,WACpB,MAAM,SAAS,GAAG,SAAS,YAC1B,MAAM,SAAS,GAAG,SAAS,KACpC,OAcF,CAAC"}
1
+ {"version":3,"file":"updateChannelActivityTimestamps.d.ts","sourceRoot":"","sources":["../../../src/channelRepository/utils/updateChannelActivityTimestamps.ts"],"names":[],"mappings":"AAOA,aAAK,cAAc,GAAG;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAIF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,cAAe,MAAM,KAAG,MAAM,qBAAqB,GAAG,SAUnF,CAAC;AA+BF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,+BAA+B,cAC/B,MAAM,GAAG,SAAS,MACzB,MAAM,SAAS,GAAG,SAAS,WACvB,cAAc,KACrB,OAaF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,cACjB,MAAM,GAAG,SAAS,WACpB,MAAM,SAAS,GAAG,SAAS,YAC1B,MAAM,SAAS,GAAG,SAAS,KACpC,OAcF,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -19827,7 +19827,7 @@ const getLocalId = () => `LOCAL_${uuid()}`;
19827
19827
  // FIXME: temp solution
19828
19828
  let uniqueId;
19829
19829
  const createMessageOptimistic = (bundle) => {
19830
- var _a, _b;
19830
+ var _a, _b, _c, _d;
19831
19831
  const client = getActiveClient();
19832
19832
  if (!client.cache)
19833
19833
  return;
@@ -19859,9 +19859,13 @@ const createMessageOptimistic = (bundle) => {
19859
19859
  // as reused to update created and updated time, which should be the same
19860
19860
  const createdTime = new Date().toISOString();
19861
19861
  const message = Object.assign({
19862
- // The optimistic message must name its channel so the session-wide channel
19863
- // activity handler can move lastActivity / lastMessageAt at send time.
19864
- channelId: subChannel === null || subChannel === void 0 ? void 0 : subChannel.data.channelId, 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);
19862
+ // The optimistic message must name its channel (public id) so the own-send
19863
+ // update can move lastActivity / lastMessageAt at send time. Take it from the
19864
+ // cached sub-channel; when that is not cached, resolve the sub-channel id
19865
+ // through the channel cache, which for a channel's default sub-channel is
19866
+ // the channel itself (ChannelActivityService migration row I2). A thread or
19867
+ // unknown channel resolves to undefined, as before.
19868
+ channelId: (_b = subChannel === null || subChannel === void 0 ? void 0 : subChannel.data.channelId) !== null && _b !== void 0 ? _b : (_c = findCachedChannel(bundle.subChannelId)) === null || _c === void 0 ? void 0 : _c.channelId, creatorId: client.userId, creatorPrivateId: getActiveUser()._id, channelSegment: ((_d = subChannel === null || subChannel === void 0 ? void 0 : subChannel.data.messageCount) !== null && _d !== void 0 ? _d : 0) + 1, childrenNumber: 0, createdAt: createdTime, updatedAt: createdTime, syncState: "syncing" /* Amity.SyncState.Syncing */, isDeleted: false }, bundleWithMessageId);
19865
19869
  const cachedAt = UNSYNCED_OBJECT_CACHED_AT_VALUE;
19866
19870
  pushToCache(['message', 'get', message.messageId], message, { cachedAt });
19867
19871
  // Own-send update (ChannelActivityService row 1): move the channel at send
package/dist/index.esm.js CHANGED
@@ -19827,7 +19827,7 @@ const getLocalId = () => `LOCAL_${uuid()}`;
19827
19827
  // FIXME: temp solution
19828
19828
  let uniqueId;
19829
19829
  const createMessageOptimistic = (bundle) => {
19830
- var _a, _b;
19830
+ var _a, _b, _c, _d;
19831
19831
  const client = getActiveClient();
19832
19832
  if (!client.cache)
19833
19833
  return;
@@ -19859,9 +19859,13 @@ const createMessageOptimistic = (bundle) => {
19859
19859
  // as reused to update created and updated time, which should be the same
19860
19860
  const createdTime = new Date().toISOString();
19861
19861
  const message = Object.assign({
19862
- // The optimistic message must name its channel so the session-wide channel
19863
- // activity handler can move lastActivity / lastMessageAt at send time.
19864
- channelId: subChannel === null || subChannel === void 0 ? void 0 : subChannel.data.channelId, 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);
19862
+ // The optimistic message must name its channel (public id) so the own-send
19863
+ // update can move lastActivity / lastMessageAt at send time. Take it from the
19864
+ // cached sub-channel; when that is not cached, resolve the sub-channel id
19865
+ // through the channel cache, which for a channel's default sub-channel is
19866
+ // the channel itself (ChannelActivityService migration row I2). A thread or
19867
+ // unknown channel resolves to undefined, as before.
19868
+ channelId: (_b = subChannel === null || subChannel === void 0 ? void 0 : subChannel.data.channelId) !== null && _b !== void 0 ? _b : (_c = findCachedChannel(bundle.subChannelId)) === null || _c === void 0 ? void 0 : _c.channelId, creatorId: client.userId, creatorPrivateId: getActiveUser()._id, channelSegment: ((_d = subChannel === null || subChannel === void 0 ? void 0 : subChannel.data.messageCount) !== null && _d !== void 0 ? _d : 0) + 1, childrenNumber: 0, createdAt: createdTime, updatedAt: createdTime, syncState: "syncing" /* Amity.SyncState.Syncing */, isDeleted: false }, bundleWithMessageId);
19865
19869
  const cachedAt = UNSYNCED_OBJECT_CACHED_AT_VALUE;
19866
19870
  pushToCache(['message', 'get', message.messageId], message, { cachedAt });
19867
19871
  // Own-send update (ChannelActivityService row 1): move the channel at send