This makes the lastPruned or lastNavigatedTo type field optional for thread activity entries (both empty is not possible). Currently, we populate thread activity entries lazily, and so the type should reflect that either field is optional.
Details
flow check
Diff Detail
- Repository
- rCOMM Comm
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
As discussed offline it might make sense to do something like
export type ThreadActivityStoreEntry = | { +lastNavigatedTo?: number, // millisecond timestamp +lastPruned: number, // millisecond timestamp } | { +lastNavigatedTo: number, // millisecond timestamp +lastPruned?: number, // millisecond timestamp };
since it could be possible for a thread to be pruned before it's ever navigated to. EG if a thread receives 100 messages when app is closed and user never navigates to that thread? I don't remember all the details of the pruning logic, so would be good to double check if that sort of scenario is possible
EDIT: Think it's possible based on the following logic:
The updateThreadLastNavigatedActionType action type is only dispatched by the ThreadScreenTracker react component. The messageStorePruneActionType is only dispatched by the MessageStorePruner.
From this comment on native/chat/chat-list/react.js, the MessageStorePruner supposedly only prunes when it is off-screen. I believe this just means if the user cannot see the messages do window size.
// This should only happen due to MessageStorePruner, // which will only prune a thread when it is off-screen
On looking at the MessageStorePruner logic, it is included in`chat.react.js` on native/web. The pruning only runs on the activeChatThreadID, but I believe we can still have an activeChatThreadID even if the app is on the background?
Can't seem to find any logic that guarantees the navigation code to run before the pruner. Would love to get confirmation on that, but it looks like you're right and we should consider the case that a prune occurs first before lastNavigatedTo is set
That is correct. The action types for ThreadActivity only updates either lastPruned or lastNavigatedTo / includes both.