Skip to content

Commit b58b263

Browse files
committed
Incorporate PR changes
1 parent c12afba commit b58b263

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

docs/SORTING.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
## How activities are being grouped?
1+
## How are activities grouped?
22

33
Before sorting, activities are grouped as a unit:
44

5-
- Activities within same part grouping will be inserted next to each other
5+
- Activities within the same part grouping are inserted next to each other
66
- Order is based on the `position` property
77
- Logical timestamp of the part grouping is the "maximum logical timestamp" of all parts
8-
- Parts can contains livestream session or ungrouped activities
9-
- Activities within same livestream session will be inserted next to each other
8+
- Parts can contain livestream session or ungrouped activities
9+
- Activities within the same livestream session will be inserted next to each other
1010
- Order is based on the `streamSequence` property
1111
- Logical timestamp of the livestream session is the logical timestamp of the finalizing activity (if any), or the logical timestamp of the first activity
1212
- In other words, livestream will be reordered when they are inserted for the first time, or when they are finalized
1313
- Interim updates will not reorder the livestream to avoid too much flickering
14-
- All other activities are not grouped, they are unit of themselves
14+
- All other activities are not grouped, they are individual units
1515

16-
## How activities are being sorted?
16+
## How are activities sorted?
1717

18-
Short answer: activities are sorted by logical timestamp on insertion.
18+
Short answer: activities are sorted by logical timestamp when inserted.
1919

2020
Long answer:
2121

22-
- For grouped activities (such as part grouping or livestream sessions), all activities within the group are treated as a unit
23-
- For ungrouped activities, each activity is a unit of itself
22+
- For grouped activities (such as part groupings or livestream sessions), all activities within the group are treated as a unit
23+
- For ungrouped activities, each activity is a unit on its own
2424

25-
Units are sorted using logical timestamp on insertion. If the unit is already in the chat history, they will be removed before re-inserting.
25+
Units are sorted using their logical timestamp on insertion. If the unit is already in the chat history, they will be removed before being re-inserted.
2626

2727
## What is logical timestamp?
2828

@@ -36,19 +36,19 @@ logicalTimestamp = activity.channelData['webchat:sequence-id'] ?? +new Date(acti
3636
- This field represents the order of the activity in the chat history and can be a sparse number;
3737
- This field is OPTIONAL, but RECOMMENDED;
3838
- This field MUST be an integer number;
39-
- This field MUST be an unique number assigned by the chat service;
39+
- This field MUST be a unique number assigned by the chat service;
4040
- This field SHOULD be consistent across all members of the conversation.
4141
1. Otherwise, `activity.timestamp: string`
4242
- This field represents the server timestamp of the activity;
4343
- This field is REQUIRED;
44-
- This field MUST be an ISO date time string, for example, `2000-01-23T12:34:56.000Z`;
44+
- This field MUST be an ISO date-time string, for example, `2000-01-23T12:34:56.000Z`;
4545
- This field MUST be assigned by the chat service, a.k.a. server timestamp;
4646
- This field SHOULD have resolution up to 1 millisecond;
4747
- This field MUST be the same across all members of the conversation.
4848
1. Otherwise, `activity.localTimestamp: string`
4949
- This field represents the local timestamp of an outgoing activity;
5050
- This field is REQUIRED for all outgoing activities;
51-
- This field MUST be an ISO date time string, for example, `2000-01-23T12:34:56.000Z`;
51+
- This field MUST be an ISO date-time string, for example, `2000-01-23T12:34:56.000Z`;
5252
- This field MUST be assigned by the sender, a.k.a. Web Chat;
5353
- This field SHOULD have resolution up to 1 millisecond;
5454
- This field MUST be the same across all members of the conversation.

packages/core/src/reducers/activities/sort/upsert.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ function upsert(ponyfill: Pick<GlobalScopePonyfill, 'Date'>, state: State, activ
111111
);
112112

113113
// This is a special case.
114-
// In the future, we should revisit this and see how we should process this activity (or drop it.)
114+
// TODO: [P1] Revisit this and see how we should process activity after the livestream is finalized.
115+
// 1. Received a previous-and-valid revision while the livestream is finalized (probably should keep to maintain history)
116+
// 2. Received a final activity while the livestream is already finalized (probably drop due to bad packet)
115117
// Related to /__tests__/html2/livestream/concludedLivestream.html.
116118
return state;
117119
}

0 commit comments

Comments
 (0)