Support displaying and editing room tags (#15)

This commit is contained in:
Ulyssa 2023-01-25 17:54:16 -08:00
parent 4f2261e66f
commit a6888bbc93
No known key found for this signature in database
GPG key ID: 1B3965A3D18B9B64
8 changed files with 443 additions and 109 deletions

View file

@ -8,6 +8,7 @@ use tracing::warn;
use matrix_sdk::{
encryption::verification::SasVerification,
room::Joined,
ruma::{
events::room::message::{
OriginalRoomMessageEvent,
@ -16,6 +17,7 @@ use matrix_sdk::{
RoomMessageEvent,
RoomMessageEventContent,
},
events::tag::{TagName, Tags},
EventId,
OwnedEventId,
OwnedRoomId,
@ -94,9 +96,10 @@ pub enum MessageAction {
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum SetRoomField {
Name(String),
Topic(String),
pub enum RoomField {
Name,
Tag(TagName),
Topic,
}
#[derive(Clone, Debug, Eq, PartialEq)]
@ -105,13 +108,8 @@ pub enum RoomAction {
InviteReject,
InviteSend(OwnedUserId),
Members(Box<CommandContext<ProgramContext>>),
Set(SetRoomField),
}
impl From<SetRoomField> for RoomAction {
fn from(act: SetRoomField) -> Self {
RoomAction::Set(act)
}
Set(RoomField, String),
Unset(RoomField),
}
#[derive(Clone, Debug, Eq, PartialEq)]
@ -194,6 +192,12 @@ impl ApplicationAction for IambAction {
}
}
impl From<RoomAction> for ProgramAction {
fn from(act: RoomAction) -> Self {
IambAction::from(act).into()
}
}
impl From<IambAction> for ProgramAction {
fn from(act: IambAction) -> Self {
Action::Application(act)
@ -277,6 +281,7 @@ pub enum RoomFetchStatus {
#[derive(Default)]
pub struct RoomInfo {
pub name: Option<String>,
pub tags: Option<Tags>,
pub keys: HashMap<OwnedEventId, MessageKey>,
pub messages: Messages,
@ -437,6 +442,10 @@ impl ChatStore {
}
}
pub fn get_joined_room(&self, room_id: &RoomId) -> Option<Joined> {
self.worker.client.get_joined_room(room_id)
}
pub fn get_room_title(&self, room_id: &RoomId) -> String {
self.rooms
.get(room_id)