mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
fix tablet switch recovery and inbox rejoin
Signed-off-by: kenny lopez <klopez4212@gmail.com>
This commit is contained in:
@@ -101,6 +101,25 @@ class ActivityPage extends HookConsumerWidget {
|
||||
|
||||
final channels = channelsAsync.asData?.value ?? const <Channel>[];
|
||||
final channelById = {for (final c in channels) c.id: c};
|
||||
final memberChannelIds = {
|
||||
for (final channel in channels)
|
||||
if (channel.isMember) channel.id,
|
||||
};
|
||||
final memberChannelIdsKey = memberChannelIds.toList()..sort();
|
||||
final previousMemberChannelIds = useRef<Set<String>>(memberChannelIds);
|
||||
useEffect(() {
|
||||
final rejoinedChannelIds = leftChannelIds.value.where(
|
||||
(channelId) =>
|
||||
!previousMemberChannelIds.value.contains(channelId) &&
|
||||
memberChannelIds.contains(channelId),
|
||||
);
|
||||
if (rejoinedChannelIds.isNotEmpty) {
|
||||
leftChannelIds.value = {...leftChannelIds.value}
|
||||
..removeAll(rejoinedChannelIds);
|
||||
}
|
||||
previousMemberChannelIds.value = memberChannelIds;
|
||||
return null;
|
||||
}, [memberChannelIdsKey.join('\u0000')]);
|
||||
|
||||
int? markerOf(String contextId) => readState.effectiveTimestamp(contextId);
|
||||
bool isDone(InboxItem item) => isInboxItemDone(
|
||||
|
||||
@@ -34,7 +34,7 @@ class WideChannelsNavigation extends HookConsumerWidget {
|
||||
final bool isCommunitySwitching;
|
||||
final ValueChanged<String?> onCommunitySwitchStart;
|
||||
final String? pendingCommunityId;
|
||||
final bool isActivityReady;
|
||||
final bool isActivitySettled;
|
||||
final VoidCallback onCommunitySwitchComplete;
|
||||
final List<WideNavigationDestination> destinations;
|
||||
|
||||
@@ -48,7 +48,7 @@ class WideChannelsNavigation extends HookConsumerWidget {
|
||||
required this.isCommunitySwitching,
|
||||
required this.onCommunitySwitchStart,
|
||||
required this.pendingCommunityId,
|
||||
required this.isActivityReady,
|
||||
required this.isActivitySettled,
|
||||
required this.onCommunitySwitchComplete,
|
||||
required this.destinations,
|
||||
});
|
||||
@@ -69,8 +69,8 @@ class WideChannelsNavigation extends HookConsumerWidget {
|
||||
() {
|
||||
if (pendingCommunityId != activeCommunityId ||
|
||||
channelsAsync.isLoading ||
|
||||
!channelsAsync.hasValue ||
|
||||
!isActivityReady) {
|
||||
!(channelsAsync.hasValue || channelsAsync.hasError) ||
|
||||
!isActivitySettled) {
|
||||
return null;
|
||||
}
|
||||
final timer = Timer(
|
||||
@@ -84,7 +84,8 @@ class WideChannelsNavigation extends HookConsumerWidget {
|
||||
activeCommunityId,
|
||||
channelsAsync.isLoading,
|
||||
channelsAsync.hasValue,
|
||||
isActivityReady,
|
||||
channelsAsync.hasError,
|
||||
isActivitySettled,
|
||||
],
|
||||
);
|
||||
final channels = (channelsAsync.asData?.value ?? const <Channel>[])
|
||||
|
||||
@@ -80,7 +80,9 @@ class HomePage extends HookConsumerWidget {
|
||||
}
|
||||
final isCommunitySwitching = pendingCommunityId.value != null;
|
||||
final activityAsync = ref.watch(activityProvider);
|
||||
final isActivityReady = activityAsync.hasValue && !activityAsync.isLoading;
|
||||
final isActivitySettled =
|
||||
!activityAsync.isLoading &&
|
||||
(activityAsync.hasValue || activityAsync.hasError);
|
||||
final systemBottomInset = MediaQuery.paddingOf(context).bottom;
|
||||
final navigationBarWidth = _floatingTabBarWidth(
|
||||
MediaQuery.sizeOf(context).width,
|
||||
@@ -175,7 +177,7 @@ class HomePage extends HookConsumerWidget {
|
||||
pendingCommunityId.value = communityId;
|
||||
},
|
||||
pendingCommunityId: pendingCommunityId.value,
|
||||
isActivityReady: isActivityReady,
|
||||
isActivitySettled: isActivitySettled,
|
||||
onCommunitySwitchComplete: () {
|
||||
pendingCommunityId.value = null;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user