getMessageById method
Look up an inbox message by its inboxMessageId.
Only refreshes if the cache is stale (> 5 min). In the typical push
notification flow, handleSyncSignal() will have already refreshed
the inbox moments before this is called, so no extra network request
is made.
Note: this searches only the currently loaded messages (first page). This is sufficient because the target message was just delivered and will be at the top of the list (sorted newest-first).
Implementation
Future<InboxMessage?> getMessageById(int inboxMessageId) async {
if (!_initialized) return null;
await refreshIfStale();
return _state.messages
.where((m) => m.inboxMessageId == inboxMessageId)
.firstOrNull;
}