* Mark an activity as seen — writes local cache immediately, then persists via trackActivity. * Call when something is shown, not when the user completes an action.
(activityName, seenAt = Date.now())
| 690 | * Call when something is shown, not when the user completes an action. |
| 691 | */ |
| 692 | markActivitySeen (activityName, seenAt = Date.now()) { |
| 693 | const userId = this.get('_id') || this.id |
| 694 | if (!userId) { return } |
| 695 | |
| 696 | const existing = userUtils.reconcileActivity( |
| 697 | userUtils.readActivityFromCache(userId, activityName), |
| 698 | this.get('activity')?.[activityName], |
| 699 | ) |
| 700 | if (existing?.last != null && seenAt <= existing.last) { return } |
| 701 | |
| 702 | const activity = { |
| 703 | first: existing?.first ?? seenAt, |
| 704 | last: seenAt, |
| 705 | count: existing?.first ? (existing.count ?? 0) + 1 : 1, |
| 706 | } |
| 707 | userUtils.writeActivityToCache(userId, activityName, activity) |
| 708 | |
| 709 | if (this.id) { |
| 710 | return this.trackActivity(activityName) |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | /** |
| 715 | * Dev/internal: clear per-user activity status local cache. Does not delete server activity. |
nothing calls this directly
no test coverage detected