chore: wait for space default rooms in sync before adding them to space (#2861)
This commit is contained in:
parent
c45415749b
commit
21d703d640
4 changed files with 51 additions and 45 deletions
|
|
@ -4952,5 +4952,7 @@
|
|||
"inviteOtherUsersToRoom": "Invite other users",
|
||||
"changeTheNameOfTheSpace": "Change the name of the space",
|
||||
"changeTheDescription": "Change the description",
|
||||
"changeThePermissions": "Change the permissions"
|
||||
"changeThePermissions": "Change the permissions",
|
||||
"introductions": "Introductions",
|
||||
"announcements": "Announcements"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import 'package:go_router/go_router.dart';
|
|||
import 'package:matrix/matrix.dart' as sdk;
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pages/new_group/new_group_view.dart';
|
||||
import 'package:fluffychat/pangea/activity_planner/activity_plan_model.dart';
|
||||
import 'package:fluffychat/pangea/chat/constants/default_power_level.dart';
|
||||
|
|
@ -188,10 +187,8 @@ class NewGroupController extends State<NewGroup> {
|
|||
);
|
||||
}
|
||||
}
|
||||
// if a timeout happened, don't redirect to the chat
|
||||
if (error != null) return;
|
||||
// Pangea#
|
||||
context.go('/rooms/$roomId/invite?filter=groups');
|
||||
// Pangea#
|
||||
}
|
||||
|
||||
Future<void> _createSpace() async {
|
||||
|
|
@ -220,6 +217,8 @@ class NewGroupController extends State<NewGroup> {
|
|||
// context.pop<String>(spaceId);
|
||||
final spaceId = await Matrix.of(context).client.createPangeaSpace(
|
||||
name: nameController.text,
|
||||
introChatName: L10n.of(context).introductions,
|
||||
announcementsChatName: L10n.of(context).announcements,
|
||||
visibility:
|
||||
groupCanBeFound ? sdk.Visibility.public : sdk.Visibility.private,
|
||||
joinRules:
|
||||
|
|
@ -237,8 +236,6 @@ class NewGroupController extends State<NewGroup> {
|
|||
GoogleAnalytics.createClass(room.name, spaceCode);
|
||||
}
|
||||
|
||||
// if a timeout happened, don't redirect to the space
|
||||
if (error != null) return;
|
||||
context.go("/rooms?spaceId=$spaceId");
|
||||
// Pangea#
|
||||
}
|
||||
|
|
@ -273,23 +270,9 @@ class NewGroupController extends State<NewGroup> {
|
|||
|
||||
switch (createGroupType) {
|
||||
case CreateGroupType.group:
|
||||
// #Pangea
|
||||
// await _createGroup();
|
||||
await _createGroup().timeout(
|
||||
const Duration(
|
||||
seconds: AppConfig.roomCreationTimeoutSeconds,
|
||||
),
|
||||
);
|
||||
// Pangea#
|
||||
await _createGroup();
|
||||
case CreateGroupType.space:
|
||||
// #Pangea
|
||||
// await _createSpace();
|
||||
await _createSpace().timeout(
|
||||
const Duration(
|
||||
seconds: AppConfig.roomCreationTimeoutSeconds,
|
||||
),
|
||||
);
|
||||
// Pangea#
|
||||
await _createSpace();
|
||||
}
|
||||
} catch (e, s) {
|
||||
sdk.Logs().d('Unable to create group', e, s);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import 'package:fluffychat/pangea/spaces/utils/space_code.dart';
|
|||
extension SpacesClientExtension on Client {
|
||||
Future<String> createPangeaSpace({
|
||||
required String name,
|
||||
required String introChatName,
|
||||
required String announcementsChatName,
|
||||
Visibility visibility = Visibility.private,
|
||||
JoinRules joinRules = JoinRules.public,
|
||||
Uint8List? avatar,
|
||||
|
|
@ -39,7 +41,11 @@ extension SpacesClientExtension on Client {
|
|||
final space = await _waitForRoom(roomId);
|
||||
if (space == null) return roomId;
|
||||
|
||||
await _addDefaultSpaceChats(space: space);
|
||||
await _addDefaultSpaceChats(
|
||||
space: space,
|
||||
introductionsName: introChatName,
|
||||
announcementsName: announcementsChatName,
|
||||
);
|
||||
return roomId;
|
||||
}
|
||||
|
||||
|
|
@ -109,6 +115,13 @@ extension SpacesClientExtension on Client {
|
|||
throw Exception('Failed to create default space chats');
|
||||
}
|
||||
|
||||
for (final roomId in roomIds) {
|
||||
final room = getRoomById(roomId);
|
||||
if (room == null) {
|
||||
await waitForRoomInSync(roomId, join: true);
|
||||
}
|
||||
}
|
||||
|
||||
final addIntroChatFuture = space.pangeaSetSpaceChild(
|
||||
roomIds[0],
|
||||
);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ class SpacesNavigationRail extends StatelessWidget {
|
|||
.uri
|
||||
.path
|
||||
.contains('homepage');
|
||||
final isColumnMode = FluffyThemes.isColumnMode(context);
|
||||
// Pangea#
|
||||
return StreamBuilder(
|
||||
key: ValueKey(
|
||||
|
|
@ -63,7 +64,7 @@ class SpacesNavigationRail extends StatelessWidget {
|
|||
return SizedBox(
|
||||
// #Pangea
|
||||
// width: FluffyThemes.navRailWidth,
|
||||
width: FluffyThemes.isColumnMode(context)
|
||||
width: isColumnMode
|
||||
? FluffyThemes.navRailWidth
|
||||
: FluffyThemes.navRailWidth * 0.75,
|
||||
// Pangea#
|
||||
|
|
@ -80,8 +81,12 @@ class SpacesNavigationRail extends StatelessWidget {
|
|||
// #Pangea
|
||||
if (i == 0) {
|
||||
return NaviRailItem(
|
||||
isSelected: isHomepage,
|
||||
onTap: () => context.go("/rooms/homepage"),
|
||||
isSelected: isColumnMode
|
||||
? activeSpaceId == null && !isSettings
|
||||
: isHomepage,
|
||||
onTap: () => isColumnMode
|
||||
? onGoToChats()
|
||||
: context.go("/rooms/homepage"),
|
||||
icon: const Padding(
|
||||
padding: EdgeInsets.all(10.0),
|
||||
child: Icon(Icons.home_outlined),
|
||||
|
|
@ -97,24 +102,27 @@ class SpacesNavigationRail extends StatelessWidget {
|
|||
i--;
|
||||
// Pangea#
|
||||
if (i == 0) {
|
||||
return NaviRailItem(
|
||||
// #Pangea
|
||||
// isSelected: activeSpaceId == null && !isSettings,
|
||||
isSelected:
|
||||
activeSpaceId == null && !isSettings && !isHomepage,
|
||||
// Pangea#
|
||||
onTap: onGoToChats,
|
||||
icon: const Padding(
|
||||
padding: EdgeInsets.all(10.0),
|
||||
child: Icon(Icons.forum_outlined),
|
||||
),
|
||||
selectedIcon: const Padding(
|
||||
padding: EdgeInsets.all(10.0),
|
||||
child: Icon(Icons.forum),
|
||||
),
|
||||
toolTip: L10n.of(context).chats,
|
||||
unreadBadgeFilter: (room) => true,
|
||||
);
|
||||
return isColumnMode
|
||||
? const SizedBox()
|
||||
: NaviRailItem(
|
||||
// #Pangea
|
||||
// isSelected: activeSpaceId == null && !isSettings,
|
||||
isSelected: activeSpaceId == null &&
|
||||
!isSettings &&
|
||||
!isHomepage,
|
||||
// Pangea#
|
||||
onTap: onGoToChats,
|
||||
icon: const Padding(
|
||||
padding: EdgeInsets.all(10.0),
|
||||
child: Icon(Icons.forum_outlined),
|
||||
),
|
||||
selectedIcon: const Padding(
|
||||
padding: EdgeInsets.all(10.0),
|
||||
child: Icon(Icons.forum),
|
||||
),
|
||||
toolTip: L10n.of(context).chats,
|
||||
unreadBadgeFilter: (room) => true,
|
||||
);
|
||||
}
|
||||
i--;
|
||||
if (i == rootSpaces.length) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue