mirror of
https://github.com/block/buzz.git
synced 2026-11-25 10:42:26 +00:00
fix(mobile): name the switched-to member from storage and drop additional data
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost> Signed-off-by: Tom Brow <tomb@block.xyz>
This commit is contained in:
@@ -526,7 +526,9 @@ class CommunityListNotifier extends AsyncNotifier<List<Community>> {
|
||||
if (activeId == id) return;
|
||||
await ref.read(communityTransitionProvider).run();
|
||||
await storage.saveActiveId(id);
|
||||
_reportAs(state.value?.where((c) => c.id == id).firstOrNull);
|
||||
// From storage: while the list reloads (after sign-in, say), state can
|
||||
// still hold the previous list.
|
||||
_reportAs((await storage.loadAll()).where((c) => c.id == id).firstOrNull);
|
||||
// Reassign list state to trigger activeCommunityProvider (which watches
|
||||
// communityListProvider.future) to rebuild and pick up the new active ID.
|
||||
// We can't use ref.invalidate(activeCommunityProvider) here because that
|
||||
|
||||
@@ -160,6 +160,9 @@ abstract final class DiagnosticFilter {
|
||||
SentryRuntime.fromJson(_only(runtime.toJson(), _runtime)),
|
||||
];
|
||||
event.tags?.removeWhere((key, _) => !_allowsTag(key));
|
||||
// Nothing sets additional data today; drop it so nothing later can.
|
||||
// ignore: deprecated_member_use
|
||||
event.extra = null;
|
||||
event.message = switch (event.message) {
|
||||
final message? => SentryMessage(stripUrlTails(message.formatted)),
|
||||
null => null,
|
||||
|
||||
@@ -939,6 +939,29 @@ void main() {
|
||||
expect(reporter.member, isNull);
|
||||
});
|
||||
|
||||
test('switching names the member from storage, not a stale list', () async {
|
||||
final reporter = _MemberRecorder();
|
||||
container = createContainer(
|
||||
overrides: [diagnosticReporterProvider.overrideWithValue(reporter)],
|
||||
);
|
||||
await container.read(communityListProvider.future);
|
||||
final keys = nostr.Keys.generate();
|
||||
final saved = Community.create(
|
||||
name: 'Saved',
|
||||
relayUrl: 'https://saved.example.com',
|
||||
nsec: keys.nsec,
|
||||
);
|
||||
// Saved, but not yet in the provider's list, as while it reloads after
|
||||
// sign-in.
|
||||
await communityStorage.save(saved);
|
||||
|
||||
await container
|
||||
.read(communityListProvider.notifier)
|
||||
.switchCommunity(saved.id);
|
||||
|
||||
expect(reporter.member, keys.public);
|
||||
});
|
||||
|
||||
group('activeCommunityProvider', () {
|
||||
test('returns null when no communities', () async {
|
||||
container = createContainer();
|
||||
|
||||
@@ -97,6 +97,19 @@ void main() {
|
||||
)).message?.formatted,
|
||||
'failed https://e.org/p and wss://r.org/x',
|
||||
),
|
||||
(
|
||||
'an event without a message gets none',
|
||||
() async => (await event(SentryEvent())).message,
|
||||
null,
|
||||
),
|
||||
(
|
||||
'additional data is dropped',
|
||||
() async => (await event(
|
||||
// ignore: deprecated_member_use
|
||||
SentryEvent(extra: {'body': 'private-marker'}),
|
||||
)).extra, // ignore: deprecated_member_use
|
||||
null,
|
||||
),
|
||||
(
|
||||
'a tag not on the list is dropped',
|
||||
() async => (await event(
|
||||
|
||||
Reference in New Issue
Block a user