Skip to content

Commit 06077cd

Browse files
author
Pranav Joshi
committed
minor fix
1 parent eb4ff2c commit 06077cd

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

packages/api/src/providers/ActivityKeyer/ActivityKeyerComposer.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type KeyToActivitiesMap = Map<string, readonly WebChatActivity[]>;
3131
*
3232
* Local key are only persisted in memory. On refresh, they will be a new random key.
3333
*/
34+
// eslint-disable-next-line complexity
3435
const ActivityKeyerComposer = ({ children }: Readonly<{ children?: ReactNode | undefined }>) => {
3536
const existingContext = useActivityKeyerContext(false);
3637

@@ -51,6 +52,9 @@ const ActivityKeyerComposer = ({ children }: Readonly<{ children?: ReactNode | u
5152
// eslint-disable-next-line security/detect-object-injection
5253
const activity = activities[i];
5354
const activityId = getActivityId(activity);
55+
if (!activityId) {
56+
break;
57+
}
5458
const clientActivityId = getClientActivityId(activity);
5559
const typingActivityId = getActivityLivestreamingMetadata(activity)?.sessionId;
5660

@@ -67,8 +71,8 @@ const ActivityKeyerComposer = ({ children }: Readonly<{ children?: ReactNode | u
6771
activityToKeyMapRef.current.set(activity, key);
6872
const existingList = keyToActivitiesMapRef.current.get(key) ?? [];
6973
keyToActivitiesMapRef.current.set(key, Object.freeze([...existingList, activity]));
74+
lastProcessedIndexRef.current = activities.length;
7075
}
71-
lastProcessedIndexRef.current = activities.length;
7276
}
7377
const getActivitiesByKey: (key?: string | undefined) => readonly WebChatActivity[] | undefined = useCallback(
7478
(key?: string | undefined): readonly WebChatActivity[] | undefined => key && keyToActivitiesMapRef.current.get(key),

0 commit comments

Comments
 (0)