mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-23 20:49:26 +01:00
feat: Experimental support for room upgrades
This commit is contained in:
parent
c0a8079e5d
commit
a3af5a9f14
@ -698,6 +698,36 @@ class _ChatState extends State<Chat> {
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
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
|
||||
.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(
|
||||
child: FutureBuilder<bool>(
|
||||
future: getTimeline(context),
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/dialogs/permission_slider_dialog.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
@ -123,6 +124,43 @@ class ChatPermissionsSettings extends StatelessWidget {
|
||||
context, entry.key, entry.value,
|
||||
category: 'events'),
|
||||
),
|
||||
if (room.ownPowerLevel >= 100) ...{
|
||||
Divider(thickness: 1),
|
||||
FutureBuilder<ServerCapabilities>(
|
||||
future: room.client.requestServerCapabilities(),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
}
|
||||
final String roomVersion = room
|
||||
.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),
|
||||
),
|
||||
onTap: roomVersion == shouldHaveVersion
|
||||
? null
|
||||
: () => showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.client
|
||||
.upgradeRoom(roomId, shouldHaveVersion),
|
||||
).then((_) =>
|
||||
AdaptivePageLayout.of(context).pop()),
|
||||
);
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user