Page MenuHomePhabricator

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

Authored by will on Wed, Apr 10, 10:45 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 2, 3:07 AM
Unknown Object (File)
Fri, Apr 26, 7:18 PM
Unknown Object (File)
Mon, Apr 22, 12:20 PM
Unknown Object (File)
Mon, Apr 22, 11:08 AM
Unknown Object (File)
Sun, Apr 21, 11:11 AM
Unknown Object (File)
Sun, Apr 21, 12:50 AM
Unknown Object (File)
Mon, Apr 15, 7:30 PM
Unknown Object (File)
Sun, Apr 14, 4:59 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.Wed, Apr 10, 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.Thu, Apr 11, 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.