fix(mobile): skip the hidden-DM check for newly created DMs

A DM the relay just created cannot be in an older visibility snapshot,
so reading it only adds a way to report failure after the DM exists.
Check visibility only when the relay reports a reopen.

Signed-off-by: Tom Brow <tomb@block.xyz>
This commit is contained in:
Tom Brow
2026-10-27 21:58:21 -07:00
parent a352ce1fd4
commit 84444d214a
2 changed files with 18 additions and 2 deletions

View File

@@ -148,8 +148,9 @@ class ChannelActions {
// Reopening a hidden DM unhides it, but the relay still accepts the open
// when that visibility snapshot fails. Check it here so the failure shows
// and Done can retry, rather than leaving the DM hidden from the sidebar.
// A newly created DM cannot be in an older snapshot.
final pk = _currentPubkey;
final hiddenRequest = pk == null
final hiddenRequest = pk == null || response?['created'] == true
? Future.value(const <NostrEvent>[])
: _session.fetchHistory(NostrFilters.hiddenDms(pk));
final channelRequest = findJoinedChannel(channelId);

View File

@@ -75,6 +75,17 @@ void main() {
actions.openDm(pubkeys: [_peer], waitForChannelList: false),
throwsStateError,
);
expect(session.visibilityReads, greaterThan(0));
// A newly created DM cannot be in an older snapshot, so it skips that
// read and cannot fail on it after the relay created the DM.
session.created = true;
final reads = session.visibilityReads;
expect(
(await actions.openDm(pubkeys: [_peer], waitForChannelList: false)).id,
_dmId,
);
expect(session.visibilityReads, reads);
session.created = false;
session.hidden = {};
// Hidden-DM resurfacing keeps waiting for the list that clears its
@@ -106,6 +117,8 @@ class _DmSession extends RelaySessionNotifier {
final String self;
bool member = true;
Set<String> hidden = {};
bool created = false;
int visibilityReads = 0;
void Function()? onRead;
final published = <NostrEvent>[];
Completer<List<NostrEvent>> stalledList = Completer();
@@ -141,7 +154,8 @@ class _DmSession extends RelaySessionNotifier {
createdAt: event.createdAt,
kind: event.kind,
tags: event.tags,
content: 'response:${jsonEncode({'channel_id': _dmId})}',
content:
'response:${jsonEncode({'channel_id': _dmId, 'created': created})}',
sig: event.sig,
);
}
@@ -152,6 +166,7 @@ class _DmSession extends RelaySessionNotifier {
Duration timeout = const Duration(seconds: 8),
}) async {
if (filter.kinds.single == EventKind.dmVisibility) {
visibilityReads++;
expect(filter.tags, {
'#p': [self],
});