mirror of
				https://gitlab.com/famedly/fluffychat.git
				synced 2025-11-04 06:17:26 +01:00 
			
		
		
		
	fix: Room upgrade
This commit is contained in:
		
							parent
							
								
									ef7ccef62b
								
							
						
					
					
						commit
						dac26dd754
					
				@ -81,6 +81,16 @@
 | 
			
		||||
    "type": "text",
 | 
			
		||||
    "placeholders": {}
 | 
			
		||||
  },
 | 
			
		||||
  "roomVersion": "Room version",
 | 
			
		||||
  "@roomVersion": {
 | 
			
		||||
    "type": "text",
 | 
			
		||||
    "placeholders": {}
 | 
			
		||||
  },
 | 
			
		||||
  "goToTheNewRoom": "Go to the new room",
 | 
			
		||||
  "@goToTheNewRoom": {
 | 
			
		||||
    "type": "text",
 | 
			
		||||
    "placeholders": {}
 | 
			
		||||
  },
 | 
			
		||||
  "alreadyHaveAnAccount": "Already have an account?",
 | 
			
		||||
  "@alreadyHaveAnAccount": {
 | 
			
		||||
    "type": "text",
 | 
			
		||||
 | 
			
		||||
@ -701,32 +701,56 @@ class _ChatState extends State<Chat> {
 | 
			
		||||
                ConnectionStatusHeader(),
 | 
			
		||||
                if (room.getState(EventTypes.RoomTombstone) != null)
 | 
			
		||||
                  Container(
 | 
			
		||||
                    height: 56,
 | 
			
		||||
                    color: Theme.of(context).secondaryHeaderColor,
 | 
			
		||||
                    child: ListTile(
 | 
			
		||||
                      leading: Icon(Icons.upgrade_outlined),
 | 
			
		||||
                      title: Text(room
 | 
			
		||||
                          .getState(EventTypes.RoomTombstone)
 | 
			
		||||
                          .parsedTombstoneContent
 | 
			
		||||
                          .body),
 | 
			
		||||
                      onTap: () async {
 | 
			
		||||
                        final result = await showFutureLoadingDialog(
 | 
			
		||||
                          context: context,
 | 
			
		||||
                          future: () => room.client.joinRoom(room
 | 
			
		||||
                    height: 72,
 | 
			
		||||
                    child: Material(
 | 
			
		||||
                      color: Theme.of(context).secondaryHeaderColor,
 | 
			
		||||
                      child: ListTile(
 | 
			
		||||
                        leading: CircleAvatar(
 | 
			
		||||
                          foregroundColor: Theme.of(context).accentColor,
 | 
			
		||||
                          backgroundColor: Theme.of(context).backgroundColor,
 | 
			
		||||
                          child: Icon(Icons.upgrade_outlined),
 | 
			
		||||
                        ),
 | 
			
		||||
                        title: Text(
 | 
			
		||||
                          room
 | 
			
		||||
                              .getState(EventTypes.RoomTombstone)
 | 
			
		||||
                              .parsedTombstoneContent
 | 
			
		||||
                              .replacementRoom),
 | 
			
		||||
                        );
 | 
			
		||||
                        await showFutureLoadingDialog(
 | 
			
		||||
                          context: context,
 | 
			
		||||
                          future: () => room.leave(),
 | 
			
		||||
                        );
 | 
			
		||||
                        if (result.error == null) {
 | 
			
		||||
                          await AdaptivePageLayout.of(context)
 | 
			
		||||
                              .pushNamedAndRemoveUntilIsFirst(
 | 
			
		||||
                                  '/rooms/${result.result}');
 | 
			
		||||
                        }
 | 
			
		||||
                      },
 | 
			
		||||
                              .body,
 | 
			
		||||
                          maxLines: 1,
 | 
			
		||||
                          overflow: TextOverflow.ellipsis,
 | 
			
		||||
                        ),
 | 
			
		||||
                        subtitle: Text(L10n.of(context).goToTheNewRoom),
 | 
			
		||||
                        onTap: () async {
 | 
			
		||||
                          if (OkCancelResult.ok !=
 | 
			
		||||
                              await showOkCancelAlertDialog(
 | 
			
		||||
                                context: context,
 | 
			
		||||
                                title: L10n.of(context).goToTheNewRoom,
 | 
			
		||||
                                message: room
 | 
			
		||||
                                    .getState(EventTypes.RoomTombstone)
 | 
			
		||||
                                    .parsedTombstoneContent
 | 
			
		||||
                                    .body,
 | 
			
		||||
                                okLabel: L10n.of(context).ok,
 | 
			
		||||
                                cancelLabel: L10n.of(context).cancel,
 | 
			
		||||
                              )) {
 | 
			
		||||
                            return;
 | 
			
		||||
                          }
 | 
			
		||||
                          final result = await showFutureLoadingDialog(
 | 
			
		||||
                            context: context,
 | 
			
		||||
                            future: () => room.client.joinRoom(room
 | 
			
		||||
                                .getState(EventTypes.RoomTombstone)
 | 
			
		||||
                                .parsedTombstoneContent
 | 
			
		||||
                                .replacementRoom),
 | 
			
		||||
                          );
 | 
			
		||||
                          await showFutureLoadingDialog(
 | 
			
		||||
                            context: context,
 | 
			
		||||
                            future: () => room.leave(),
 | 
			
		||||
                          );
 | 
			
		||||
                          if (result.error == null) {
 | 
			
		||||
                            await AdaptivePageLayout.of(context)
 | 
			
		||||
                                .pushNamedAndRemoveUntilIsFirst(
 | 
			
		||||
                                    '/rooms/${result.result}');
 | 
			
		||||
                          }
 | 
			
		||||
                        },
 | 
			
		||||
                      ),
 | 
			
		||||
                    ),
 | 
			
		||||
                  ),
 | 
			
		||||
                Expanded(
 | 
			
		||||
 | 
			
		||||
@ -141,32 +141,35 @@ class ChatPermissionsSettings extends StatelessWidget {
 | 
			
		||||
                                  .getState(EventTypes.RoomCreate)
 | 
			
		||||
                                  .content['room_version'] ??
 | 
			
		||||
                              '1';
 | 
			
		||||
                          final shouldHaveVersion =
 | 
			
		||||
                              snapshot.data.mRoomVersions.defaultVersion;
 | 
			
		||||
 | 
			
		||||
                          return ListTile(
 | 
			
		||||
                            title: Text('Current room version: $roomVersion'),
 | 
			
		||||
                            subtitle: roomVersion == shouldHaveVersion
 | 
			
		||||
                                ? null
 | 
			
		||||
                                : Text(
 | 
			
		||||
                                    'Upgrade to $shouldHaveVersion available!',
 | 
			
		||||
                                    style: TextStyle(
 | 
			
		||||
                                        fontWeight: FontWeight.bold,
 | 
			
		||||
                                        color: Theme.of(context).accentColor),
 | 
			
		||||
                                  ),
 | 
			
		||||
                            title: Text(
 | 
			
		||||
                                '${L10n.of(context).roomVersion}: $roomVersion'),
 | 
			
		||||
                            onTap: () async {
 | 
			
		||||
                              final newVersion =
 | 
			
		||||
                                  await showConfirmationDialog<String>(
 | 
			
		||||
                                context: context,
 | 
			
		||||
                                title: 'Choose Room Version',
 | 
			
		||||
                                title: L10n.of(context)
 | 
			
		||||
                                    .replaceRoomWithNewerVersion,
 | 
			
		||||
                                actions: snapshot
 | 
			
		||||
                                    .data.mRoomVersions.available.entries
 | 
			
		||||
                                    .where((r) => r.key != roomVersion)
 | 
			
		||||
                                    .map((version) => AlertDialogAction(
 | 
			
		||||
                                        key: version.key,
 | 
			
		||||
                                        label:
 | 
			
		||||
                                            '${version.key} (${version.value.toString().split('.').last})')),
 | 
			
		||||
                                            '${version.key} (${version.value.toString().split('.').last})'))
 | 
			
		||||
                                    .toList(),
 | 
			
		||||
                              );
 | 
			
		||||
                              if (newVersion == null ||
 | 
			
		||||
                                  OkCancelResult.cancel ==
 | 
			
		||||
                                      await showOkCancelAlertDialog(
 | 
			
		||||
                                        context: context,
 | 
			
		||||
                                        okLabel: L10n.of(context).yes,
 | 
			
		||||
                                        cancelLabel: L10n.of(context).cancel,
 | 
			
		||||
                                        title: L10n.of(context).areYouSure,
 | 
			
		||||
                                      )) {
 | 
			
		||||
                                return;
 | 
			
		||||
                              }
 | 
			
		||||
                              await showFutureLoadingDialog(
 | 
			
		||||
                                context: context,
 | 
			
		||||
                                future: () =>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user