Page MenuHomePhabricator

[lib] Make `lastPruned` and `lastNavigatedTo` type optional for thread activity entry
ClosedPublic

Authored by will on Apr 10 2024, 10:45 AM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 28 2024, 7:49 PM
Unknown Object (File)
Oct 25 2024, 1:19 AM
Unknown Object (File)
Oct 25 2024, 1:19 AM
Unknown Object (File)
Oct 25 2024, 1:19 AM
Unknown Object (File)
Oct 25 2024, 1:19 AM
Unknown Object (File)
Oct 25 2024, 1:18 AM
Unknown Object (File)
Oct 2 2024, 1:05 PM
Unknown Object (File)
Sep 29 2024, 12:22 PM
Subscribers

Details

Summary

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.

Context: https://linear.app/comm/issue/ENG-7663/missing-lastpruned-field-in-current-thread-activity-redux-persist#comment-d17294bb

Test Plan

flow check

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

will requested review of this revision.Apr 10 2024, 11:14 AM

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:

fbb9f4.png (388×1 px, 70 KB)

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

will retitled this revision from [lib] Make `lastPruned` type optional for thread activity entry to [lib] Make `lastPruned` or `lastNavigatedTo` type optional for thread activity entry.
will edited the summary of this revision. (Show Details)
will retitled this revision from [lib] Make `lastPruned` or `lastNavigatedTo` type optional for thread activity entry to [lib] Make `lastPruned` and `lastNavigatedTo` type optional for thread activity entry.

Add lastNavigatedTo

Make lastNavigatedTo optional as well

It's not possible for ThreadActivityStoreEntry to be an empty object?

This revision is now accepted and ready to land.Apr 11 2024, 6:18 PM

It's not possible for ThreadActivityStoreEntry to be an empty object?

That is correct. The action types for ThreadActivity only updates either lastPruned or lastNavigatedTo / includes both.