refactor: Remove old aliases workaround
This commit is contained in:
parent
05a099e60f
commit
1324ce517d
1 changed files with 10 additions and 26 deletions
|
|
@ -72,34 +72,19 @@ class ChatDetailsController extends State<ChatDetails> {
|
||||||
void editAliases() async {
|
void editAliases() async {
|
||||||
final room = Matrix.of(context).client.getRoomById(roomId!);
|
final room = Matrix.of(context).client.getRoomById(roomId!);
|
||||||
|
|
||||||
// The current endpoint doesnt seem to be implemented in Synapse. This may
|
final aliasesResult = await showFutureLoadingDialog(
|
||||||
// change in the future and then we just need to switch to this api call:
|
|
||||||
//
|
|
||||||
// final aliases = await showFutureLoadingDialog(
|
|
||||||
// context: context,
|
|
||||||
// future: () => room.client.requestRoomAliases(room.id),
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// While this is not working we use the unstable api:
|
|
||||||
final aliases = await showFutureLoadingDialog(
|
|
||||||
context: context,
|
context: context,
|
||||||
future: () => room!.client
|
future: () => room!.client.getLocalAliases(room.id),
|
||||||
.request(
|
|
||||||
RequestType.GET,
|
|
||||||
'/client/unstable/org.matrix.msc2432/rooms/${Uri.encodeComponent(room.id)}/aliases',
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
(response) => List<String>.from(response['aliases'] as Iterable),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
// Switch to the stable api once it is implemented.
|
|
||||||
|
|
||||||
if (aliases.error != null) return;
|
final aliases = aliasesResult.result;
|
||||||
final adminMode = room!.canSendEvent('m.room.canonical_alias');
|
|
||||||
if (aliases.result!.isEmpty && (room.canonicalAlias.isNotEmpty)) {
|
if (aliases == null) return;
|
||||||
aliases.result!.add(room.canonicalAlias);
|
final adminMode = room!.canSendEvent(EventTypes.RoomCanonicalAlias);
|
||||||
|
if (aliases.isEmpty && (room.canonicalAlias.isNotEmpty)) {
|
||||||
|
aliases.add(room.canonicalAlias);
|
||||||
}
|
}
|
||||||
if (aliases.result!.isEmpty && adminMode) {
|
if (aliases.isEmpty && adminMode) {
|
||||||
return setAliasAction();
|
return setAliasAction();
|
||||||
}
|
}
|
||||||
final select = await showConfirmationDialog(
|
final select = await showConfirmationDialog(
|
||||||
|
|
@ -108,8 +93,7 @@ class ChatDetailsController extends State<ChatDetails> {
|
||||||
actions: [
|
actions: [
|
||||||
if (adminMode)
|
if (adminMode)
|
||||||
AlertDialogAction(label: L10n.of(context)!.create, key: 'new'),
|
AlertDialogAction(label: L10n.of(context)!.create, key: 'new'),
|
||||||
...aliases.result!
|
...aliases.map((alias) => AlertDialogAction(key: alias, label: alias)),
|
||||||
.map((alias) => AlertDialogAction(key: alias, label: alias)),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
if (select == null) return;
|
if (select == null) return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue