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