chore: don't lazy load members, account for left memebers when determ… (#3653)

* chore: don't lazy load members, account for left memebers when determining if activity is finished

* chore: always show continue button in unfinished activities
pull/2245/head
ggurdin 3 months ago committed by GitHub
parent 0ac33f96fa
commit 867004243f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -202,11 +202,6 @@ class ChatView extends StatelessWidget {
if (scrollUpBannerEventId != null) { if (scrollUpBannerEventId != null) {
appbarBottomHeight += ChatAppBarListTile.fixedHeight; appbarBottomHeight += ChatAppBarListTile.fixedHeight;
} }
// #Pangea
if (controller.room.isActiveInActivity) {
appbarBottomHeight += ChatAppBarListTile.fixedHeight;
}
// Pangea#
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
// #Pangea // #Pangea
@ -281,9 +276,6 @@ class ChatView extends StatelessWidget {
child: Text(L10n.of(context).jump), child: Text(L10n.of(context).jump),
), ),
), ),
// #Pangea
ActivityPinnedMessage(controller),
// Pangea#
], ],
), ),
), ),
@ -474,6 +466,7 @@ class ChatView extends StatelessWidget {
], ],
), ),
), ),
ActivityPinnedMessage(controller),
// Pangea# // Pangea#
], ],
), ),

@ -6,6 +6,7 @@ import 'package:matrix/matrix.dart';
import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/l10n/l10n.dart'; import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/pangea/activity_planner/activity_room_extension.dart';
import 'package:fluffychat/pangea/instructions/instructions_enum.dart'; import 'package:fluffychat/pangea/instructions/instructions_enum.dart';
import 'package:fluffychat/pangea/instructions/instructions_inline_tooltip.dart'; import 'package:fluffychat/pangea/instructions/instructions_inline_tooltip.dart';
import 'package:fluffychat/utils/date_time_extension.dart'; import 'package:fluffychat/utils/date_time_extension.dart';
@ -66,6 +67,9 @@ class RoomCreationStateEventState extends State<RoomCreationStateEvent> {
// child: ConstrainedBox( // child: ConstrainedBox(
child: Column( child: Column(
children: [ children: [
// https://github.com/pangeachat/client/issues/3639
if (widget.event.room.isActiveInActivity)
const SizedBox(height: 60.0),
ConstrainedBox( ConstrainedBox(
// Pangea# // Pangea#
constraints: const BoxConstraints(maxWidth: 256), constraints: const BoxConstraints(maxWidth: 256),

@ -38,6 +38,10 @@ class ActivityFinishedStatusMessageState
void initState() { void initState() {
super.initState(); super.initState();
_setDefaultHighlightedRole(); _setDefaultHighlightedRole();
if (widget.room.activityIsFinished && widget.room.activitySummary == null) {
widget.room.fetchSummaries();
}
} }
@override @override

@ -73,7 +73,12 @@ class ActivityPinnedMessageState extends State<ActivityPinnedMessage> {
final theme = Theme.of(context); final theme = Theme.of(context);
final isColumnMode = FluffyThemes.isColumnMode(context); final isColumnMode = FluffyThemes.isColumnMode(context);
return Column( return Positioned(
top: 0,
left: 0,
right: 0,
bottom: _showDropdown ? 0 : null,
child: Column(
children: [ children: [
AnimatedContainer( AnimatedContainer(
duration: FluffyThemes.animationDuration, duration: FluffyThemes.animationDuration,
@ -88,7 +93,8 @@ class ActivityPinnedMessageState extends State<ActivityPinnedMessage> {
trailing: Padding( trailing: Padding(
padding: const EdgeInsets.only(right: 12.0), padding: const EdgeInsets.only(right: 12.0),
child: ElevatedButton( child: ElevatedButton(
onPressed: _showDropdown ? null : () => _setShowDropdown(true), onPressed:
_showDropdown ? null : () => _setShowDropdown(true),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
minimumSize: Size.zero, minimumSize: Size.zero,
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
@ -97,7 +103,8 @@ class ActivityPinnedMessageState extends State<ActivityPinnedMessage> {
), ),
backgroundColor: AppConfig.yellowDark, backgroundColor: AppConfig.yellowDark,
foregroundColor: theme.colorScheme.surface, foregroundColor: theme.colorScheme.surface,
disabledBackgroundColor: AppConfig.yellowDark.withAlpha(100), disabledBackgroundColor:
AppConfig.yellowDark.withAlpha(100),
disabledForegroundColor: disabledForegroundColor:
theme.colorScheme.surface.withAlpha(100), theme.colorScheme.surface.withAlpha(100),
), ),
@ -178,6 +185,7 @@ class ActivityPinnedMessageState extends State<ActivityPinnedMessage> {
), ),
), ),
], ],
),
); );
} }
} }

@ -1,6 +1,7 @@
import 'dart:math'; import 'dart:math';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:collection/collection.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
import 'package:fluffychat/pangea/activity_planner/activity_plan_model.dart'; import 'package:fluffychat/pangea/activity_planner/activity_plan_model.dart';
@ -262,7 +263,17 @@ extension ActivityRoomExtension on Room {
activityRole(client.userID!)?.isFinished ?? false; activityRole(client.userID!)?.isFinished ?? false;
bool get activityIsFinished { bool get activityIsFinished {
return activityRoles.isNotEmpty && activityRoles.every((r) => r.isFinished); return activityRoles.isNotEmpty &&
activityRoles.every((r) {
if (r.isFinished) return true;
// if the user is in the chat (not null && membership is join),
// then the activity is not finished for them
final user = getParticipants().firstWhereOrNull(
(u) => u.id == r.userId,
);
return user == null || user.membership != Membership.join;
});
} }
int? get numberOfParticipants { int? get numberOfParticipants {

@ -31,19 +31,22 @@ class ActivityUnfinishedStatusMessageState
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final unassignedRoles = widget.room.remainingRoles; debugPrint("HELLO. remainingRoles: ${widget.room.remainingRoles}");
final theme = Theme.of(context); final theme = Theme.of(context);
final isColumnMode = FluffyThemes.isColumnMode(context); final isColumnMode = FluffyThemes.isColumnMode(context);
final remainingRoles = widget.room.remainingRoles;
final completed = widget.room.hasCompletedActivity;
return Column( return Column(
children: [ children: [
if (!widget.room.hasCompletedActivity) ...[ if (!completed) ...[
if (unassignedRoles > 0) if (remainingRoles > 0)
Wrap( Wrap(
spacing: 12.0, spacing: 12.0,
runSpacing: 12.0, runSpacing: 12.0,
children: List.generate(unassignedRoles, (index) { children: List.generate(remainingRoles, (index) {
return ActivityParticipantIndicator( return ActivityParticipantIndicator(
selected: _selectedRole == index, selected: _selectedRole == index,
onTap: () => _selectRole(index), onTap: () => _selectRole(index),
@ -52,7 +55,7 @@ class ActivityUnfinishedStatusMessageState
), ),
const SizedBox(height: 16.0), const SizedBox(height: 16.0),
Text( Text(
unassignedRoles > 0 remainingRoles > 0
? L10n.of(context).unjoinedActivityMessage ? L10n.of(context).unjoinedActivityMessage
: L10n.of(context).fullActivityMessage, : L10n.of(context).fullActivityMessage,
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -62,7 +65,6 @@ class ActivityUnfinishedStatusMessageState
), ),
const SizedBox(height: 16.0), const SizedBox(height: 16.0),
], ],
if (unassignedRoles > 0)
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
@ -72,7 +74,7 @@ class ActivityUnfinishedStatusMessageState
foregroundColor: theme.colorScheme.onPrimaryContainer, foregroundColor: theme.colorScheme.onPrimaryContainer,
backgroundColor: theme.colorScheme.primaryContainer, backgroundColor: theme.colorScheme.primaryContainer,
), ),
onPressed: widget.room.hasCompletedActivity onPressed: completed
? () { ? () {
showFutureLoadingDialog( showFutureLoadingDialog(
context: context, context: context,
@ -91,7 +93,7 @@ class ActivityUnfinishedStatusMessageState
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( Text(
widget.room.hasCompletedActivity completed
? L10n.of(context).continueText ? L10n.of(context).continueText
: L10n.of(context).confirmRole, : L10n.of(context).confirmRole,
style: TextStyle( style: TextStyle(

@ -108,17 +108,6 @@ extension AnalyticsClientExtension on Client {
} }
} }
Future<void> loadAnalyticsRequests() async {
if (prevBatch == null) await onSync.stream.first;
if (userID == null || userID == BotName.byEnvironment) return;
for (final analyticsRoom in allMyAnalyticsRooms) {
if (!isLogged()) return;
analyticsRoom.requestParticipants([Membership.knock], false, true);
analyticsRoom.postLoad();
}
}
/// Space admins join analytics rooms in spaces via the space hierarchy, /// Space admins join analytics rooms in spaces via the space hierarchy,
/// so other members of the space need to add their analytics rooms to the space. /// so other members of the space need to add their analytics rooms to the space.
Future<void> addAnalyticsRoomsToSpaces() async { Future<void> addAnalyticsRoomsToSpaces() async {

@ -78,7 +78,6 @@ class GetAnalyticsController extends BaseController {
await GetStorage.init("analytics_storage"); await GetStorage.init("analytics_storage");
_client.updateAnalyticsRoomJoinRules(); _client.updateAnalyticsRoomJoinRules();
_client.addAnalyticsRoomsToSpaces(); _client.addAnalyticsRoomsToSpaces();
_client.loadAnalyticsRequests();
_analyticsUpdateSubscription ??= _pangeaController _analyticsUpdateSubscription ??= _pangeaController
.putAnalytics.analyticsUpdateStream.stream .putAnalytics.analyticsUpdateStream.stream

@ -79,7 +79,7 @@ class PangeaInvitationSelectionController
extends State<PangeaInvitationSelection> { extends State<PangeaInvitationSelection> {
TextEditingController controller = TextEditingController(); TextEditingController controller = TextEditingController();
bool loading = true; bool loading = false;
List<Profile> foundProfiles = []; List<Profile> foundProfiles = [];
Timer? coolDown; Timer? coolDown;
@ -103,34 +103,6 @@ class PangeaInvitationSelectionController
searchUser(context, ''); searchUser(context, '');
} }
_room?.requestParticipants(
[
Membership.join,
Membership.invite,
Membership.knock,
],
false,
true,
).then((_) {
if (mounted) {
setState(() {
loading = false;
});
}
});
spaceParent?.requestParticipants(
[
Membership.join,
Membership.invite,
Membership.knock,
],
false,
true,
).then((_) {
if (mounted) setState(() {});
});
controller.addListener(() { controller.addListener(() {
setState(() {}); setState(() {});
}); });

@ -230,12 +230,6 @@ class SpaceAnalyticsState extends State<SpaceAnalytics> {
} }
Future<void> _loadProfiles() async { Future<void> _loadProfiles() async {
await room?.requestParticipants(
[Membership.join],
false,
true,
);
final futures = _availableUsers.map((u) async { final futures = _availableUsers.map((u) async {
final resp = await MatrixState.pangeaController.userController final resp = await MatrixState.pangeaController.userController
.getPublicProfile(u.id); .getPublicProfile(u.id);

@ -51,12 +51,6 @@ class LoadParticipantsUtilState extends State<LoadParticipantsUtil> {
error = null; error = null;
}); });
await widget.space.requestParticipants(
[Membership.join, Membership.invite, Membership.knock],
false,
true,
);
await _cacheLevels(); await _cacheLevels();
} catch (err, s) { } catch (err, s) {
error = err.toString(); error = err.toString();

@ -48,11 +48,12 @@ class KnockingUsersIndicatorState extends State<KnockingUsersIndicator> {
super.dispose(); super.dispose();
} }
Future<void> _setKnockingUsers({bool loadParticipants = false}) async { void _setKnockingUsers() {
_knockingUsers = loadParticipants if (mounted) {
? await widget.room.requestParticipants([Membership.knock]) setState(() {
: widget.room.getParticipants([Membership.knock]); _knockingUsers = widget.room.getParticipants([Membership.knock]);
if (mounted) setState(() {}); });
}
} }
@override @override

@ -129,12 +129,13 @@ abstract class ClientManager {
// #Pangea // #Pangea
// The things in this list will be loaded in the first sync, without having // The things in this list will be loaded in the first sync, without having
// to postLoad to confirm that these state events are completely loaded // to postLoad to confirm that these state events are completely loaded
EventTypes.RoomPowerLevels,
EventTypes.RoomJoinRules,
EventTypes.RoomMember,
PangeaEventTypes.rules, PangeaEventTypes.rules,
PangeaEventTypes.botOptions, PangeaEventTypes.botOptions,
PangeaEventTypes.capacity, PangeaEventTypes.capacity,
EventTypes.RoomPowerLevels,
PangeaEventTypes.userSetLemmaInfo, PangeaEventTypes.userSetLemmaInfo,
EventTypes.RoomJoinRules,
PangeaEventTypes.activityPlan, PangeaEventTypes.activityPlan,
PangeaEventTypes.activityRole, PangeaEventTypes.activityRole,
PangeaEventTypes.activitySummary, PangeaEventTypes.activitySummary,
@ -161,7 +162,6 @@ abstract class ClientManager {
// #Pangea // #Pangea
syncFilter: Filter( syncFilter: Filter(
room: RoomFilter( room: RoomFilter(
state: StateFilter(lazyLoadMembers: true),
timeline: StateFilter( timeline: StateFilter(
notTypes: [ notTypes: [
PangeaEventTypes.construct, PangeaEventTypes.construct,

Loading…
Cancel
Save