Skip to content

Commit f9e5b49

Browse files
klopez4212Terp
andcommitted
Preserve attribution, forum insets, and retention in conversation headers
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Signed-off-by: kenny lopez <[email protected]>
1 parent 95ffc34 commit f9e5b49

6 files changed

Lines changed: 68 additions & 9 deletions

File tree

‎mobile/lib/features/channels/channel_detail_page.dart‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,12 @@ class _ResolvedChannelDetailPage extends HookConsumerWidget {
691691
alwaysFrosted: true,
692692
nativeViewSuppressed: messageActionBackdropActive,
693693
nativeTitle: dmHeader.label,
694-
nativeSubtitle: '',
694+
nativeSubtitle: retention == null
695+
? ''
696+
: [
697+
'Temporary',
698+
if (retention.detailLabel != null) retention.detailLabel!,
699+
].join(' · '),
695700
nativeEphemeralLabel: retention?.tooltipLabel,
696701
nativeTitleAvatars: dmHeader.avatars,
697702
nativeTitleMaxWidth: conversationTitleMaxWidth(
@@ -757,6 +762,7 @@ class _ResolvedChannelDetailPage extends HookConsumerWidget {
757762
fit: StackFit.expand,
758763
children: [
759764
ForumPostsView(
765+
titleContentHeight: appBarTitleContentHeight,
760766
channel: resolvedChannel,
761767
currentPubkey: currentPubkey,
762768
),

‎mobile/lib/features/channels/message_author_visibility.dart‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ bool showMessageAuthorName(
1818
);
1919
if (channel == null) return true;
2020
final members = ref.watch(channelMembersProvider(channelId)).value;
21+
// The DM header still uses metadata. Keep attribution while that snapshot
22+
// disagrees with current membership, even if only one counterpart remains.
23+
if (channel.isDm && members != null) {
24+
final metadata = channel.participantPubkeys
25+
.map((key) => key.trim().toLowerCase())
26+
.where((key) => key.isNotEmpty)
27+
.toSet();
28+
final current = members
29+
.map((member) => member.pubkey.trim().toLowerCase())
30+
.where((key) => key.isNotEmpty)
31+
.toSet();
32+
if (metadata.length != current.length || !metadata.containsAll(current)) {
33+
return true;
34+
}
35+
}
2136
final participants =
2237
(members?.map((member) => member.pubkey) ??
2338
(channel.isDm ? channel.participantPubkeys : const <String>[]))

‎mobile/lib/features/forum/forum_posts_view.dart‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ import 'forum_thread_page.dart';
2525
class ForumPostsView extends HookConsumerWidget {
2626
final Channel channel;
2727
final String? currentPubkey;
28+
final double titleContentHeight;
2829

2930
const ForumPostsView({
3031
super.key,
3132
required this.channel,
3233
required this.currentPubkey,
34+
this.titleContentHeight = 0,
3335
});
3436

3537
@override
@@ -82,7 +84,12 @@ class ForumPostsView extends HookConsumerWidget {
8284
// A retry from an error shows loading, not the stale error and its Retry.
8385
skipLoadingOnRefresh: !postsAsync.hasError,
8486
loading: () => Padding(
85-
padding: EdgeInsets.only(top: frostedAppBarHeight(context)),
87+
padding: EdgeInsets.only(
88+
top: frostedAppBarHeight(
89+
context,
90+
titleContentHeight: titleContentHeight,
91+
),
92+
),
8693
child: const Center(
8794
child: BuzzLoadingIndicator(
8895
size: 44,
@@ -91,7 +98,12 @@ class ForumPostsView extends HookConsumerWidget {
9198
),
9299
),
93100
error: (e, _) => Padding(
94-
padding: EdgeInsets.only(top: frostedAppBarHeight(context)),
101+
padding: EdgeInsets.only(
102+
top: frostedAppBarHeight(
103+
context,
104+
titleContentHeight: titleContentHeight,
105+
),
106+
),
95107
child: LoadErrorView(
96108
message: 'Failed to load posts',
97109
onRetry: () => ref.invalidate(forumPostsProvider(channel.id)),
@@ -112,7 +124,10 @@ class ForumPostsView extends HookConsumerWidget {
112124
},
113125
child: ListView.separated(
114126
padding: EdgeInsets.only(
115-
top: frostedAppBarHeight(context),
127+
top: frostedAppBarHeight(
128+
context,
129+
titleContentHeight: titleContentHeight,
130+
),
116131
left: Grid.gutter,
117132
right: Grid.gutter,
118133
bottom: Grid.xs,

‎mobile/test/features/channels/channel_detail_page_test.dart‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:buzz/features/forum/forum_posts_view.dart';
12
import 'package:buzz/features/channels/me/me_chat_settings.dart';
23
import 'package:buzz/shared/widgets/dm_header_portrait.dart';
34
import 'package:buzz/features/channels/dm_voice_agent_provider.dart';
@@ -4314,6 +4315,8 @@ void main() {
43144315
});
43154316

43164317
testWidgets('shows forum posts view for forum channels', (tester) async {
4318+
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
4319+
addTearDown(() => debugDefaultTargetPlatformOverride = null);
43174320
final forumChannel = Channel(
43184321
id: _channelId,
43194322
name: 'design-forum',
@@ -4342,6 +4345,9 @@ void main() {
43424345
find.byType(FrostedScaffold).first,
43434346
);
43444347
expect(scaffold.resizeToAvoidBottomInset, isTrue);
4348+
final forum = tester.widget<ForumPostsView>(find.byType(ForumPostsView));
4349+
expect(forum.titleContentHeight, scaffold.appBar.titleContentHeight);
4350+
expect(forum.titleContentHeight, greaterThanOrEqualTo(104));
43454351
});
43464352

43474353
testWidgets('renders video attachments from imeta tags in the timeline', (
@@ -14404,7 +14410,7 @@ void main() {
1440414410
payload['ephemeralLabel'],
1440514411
contains('after 1 hour of inactivity'),
1440614412
);
14407-
expect(payload['subtitle'], isEmpty);
14413+
expect(payload['subtitle'], contains('Temporary'));
1440814414
const bridge = MethodChannel('buzz/ios_navigation_bar/297');
1440914415
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(bridge, (
1441014416
call,
@@ -14427,7 +14433,7 @@ void main() {
1442714433
container.invalidate(channelDetailsProvider(_channelId));
1442814434
await tester.pumpAndSettle();
1442914435
expect(payload['ephemeralLabel'], contains('Cleanup is due now'));
14430-
expect(payload['subtitle'], isEmpty);
14436+
expect(payload['subtitle'], contains('Cleanup due'));
1443114437
current = conversation();
1443214438
container.invalidate(channelDetailsProvider(_channelId));
1443314439
await tester.pumpAndSettle();

‎mobile/test/features/channels/channel_detail_page_test/author_visibility_tests.dart‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ void messageAuthorVisibilityTests() {
1010
'pair-channel',
1111
'unknown',
1212
'outsider',
13+
'stale-dm',
1314
]) {
1415
testWidgets('message identity: $kind dark=$dark', (tester) async {
1516
final participants = kind == 'unknown'
1617
? <String>[]
1718
: [
1819
'self',
1920
'alice',
20-
if (kind == 'group' || kind == 'channel') 'bob',
21+
if (kind == 'group' || kind == 'channel' || kind == 'stale-dm')
22+
'bob',
2123
];
2224
final channel = Channel(
2325
id: _channelId,
@@ -42,7 +44,9 @@ void messageAuthorVisibilityTests() {
4244
darkTheme: dark,
4345
signingPubkey: 'self',
4446
members: [
45-
for (final pubkey in participants)
47+
for (final pubkey in participants.where(
48+
(key) => kind != 'stale-dm' || key != 'bob',
49+
))
4650
ChannelMember(
4751
pubkey: pubkey,
4852
role: 'member',

‎mobile/test/features/forum/forum_widgets_test.dart‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:buzz/shared/widgets/frosted_app_bar.dart';
12
import 'dart:async';
23

34
import 'package:flutter/material.dart';
@@ -95,6 +96,7 @@ Widget _buildPostCard({
9596
Widget _buildPostsView({
9697
required ForumPostsResponse postsResponse,
9798
Channel? channel,
99+
double titleContentHeight = 0,
98100
Map<String, UserProfile> users = const {},
99101
}) {
100102
final ch = channel ?? _forumChannel;
@@ -110,7 +112,11 @@ Widget _buildPostsView({
110112
child: MaterialApp(
111113
theme: AppTheme.light(),
112114
home: Scaffold(
113-
body: ForumPostsView(channel: ch, currentPubkey: 'self'),
115+
body: ForumPostsView(
116+
channel: ch,
117+
currentPubkey: 'self',
118+
titleContentHeight: titleContentHeight,
119+
),
114120
),
115121
),
116122
);
@@ -744,6 +750,7 @@ void main() {
744750
testWidgets('renders post list', (tester) async {
745751
await tester.pumpWidget(
746752
_buildPostsView(
753+
titleContentHeight: 104,
747754
postsResponse: ForumPostsResponse(
748755
posts: [
749756
_makePost(content: 'First post'),
@@ -755,6 +762,12 @@ void main() {
755762
);
756763
await tester.pumpAndSettle();
757764

765+
final first = find.byType(ForumPostCard).first;
766+
final list = find.byType(ListView).first;
767+
expect(
768+
tester.getTopLeft(first).dy - tester.getTopLeft(list).dy,
769+
frostedAppBarHeight(tester.element(list), titleContentHeight: 104),
770+
);
758771
expect(find.text('First post'), findsOneWidget);
759772
expect(find.text('Second post'), findsOneWidget);
760773
});

0 commit comments

Comments
 (0)