From c04a8140a3e2e2785fa32fea9324789974f36a4a Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 18 May 2021 11:07:46 +0200 Subject: [PATCH] offer to rejoin archived room from menu --- src/domain/session/room/RoomViewModel.js | 8 ++++++++ src/matrix/room/ArchivedRoom.js | 6 ++++++ src/platform/web/ui/session/room/RoomView.js | 3 +++ 3 files changed, 17 insertions(+) diff --git a/src/domain/session/room/RoomViewModel.js b/src/domain/session/room/RoomViewModel.js index 1d2f3725..5d08f903 100644 --- a/src/domain/session/room/RoomViewModel.js +++ b/src/domain/session/room/RoomViewModel.js @@ -147,6 +147,14 @@ export class RoomViewModel extends ViewModel { forgetRoom() { this._room.forget(); } + + get canRejoin() { + return this._room.isArchived; + } + + rejoinRoom() { + this._room.join(); + } async _sendMessage(message) { if (!this._room.isArchived && message) { diff --git a/src/matrix/room/ArchivedRoom.js b/src/matrix/room/ArchivedRoom.js index a87bd774..f975191e 100644 --- a/src/matrix/room/ArchivedRoom.js +++ b/src/matrix/room/ArchivedRoom.js @@ -162,6 +162,12 @@ export class ArchivedRoom extends BaseRoom { this._forgetCallback(this.id); }); } + + join(log = null) { + return this._platform.logger.wrapOrRun(log, "rejoin archived room", async log => { + await this._hsApi.join(this.id, {log}).response(); + }); + } } function findKickDetails(roomResponse, ownUserId) { diff --git a/src/platform/web/ui/session/room/RoomView.js b/src/platform/web/ui/session/room/RoomView.js index e2ef0de7..3d8c58a5 100644 --- a/src/platform/web/ui/session/room/RoomView.js +++ b/src/platform/web/ui/session/room/RoomView.js @@ -73,6 +73,9 @@ export class RoomView extends TemplateView { if (vm.canForget) { options.push(Menu.option(vm.i18n`Forget room`, () => vm.forgetRoom())); } + if (vm.canRejoin) { + options.push(Menu.option(vm.i18n`Rejoin room`, () => vm.rejoinRoom())); + } if (!options.length) { return; }