Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiverse: add support for sending messages and {en|dis}abling the sending queue #3496

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 42 additions & 4 deletions labs/multiverse/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ use matrix_sdk::{
encryption::{BackupDownloadStrategy, EncryptionSettings},
matrix_auth::MatrixSession,
ruma::{
api::client::receipt::create_receipt::v3::ReceiptType, events::room::message::MessageType,
OwnedRoomId, RoomId,
api::client::receipt::create_receipt::v3::ReceiptType,
events::room::message::{MessageType, RoomMessageEventContent},
MilliSecondsSinceUnixEpoch, OwnedRoomId, RoomId,
},
AuthSession, Client, RoomListEntry, ServerName, SqliteCryptoStore, SqliteStateStore,
};
Expand Down Expand Up @@ -433,6 +434,43 @@ impl App {

Char('s') => self.sync_service.start().await,
Char('S') => self.sync_service.stop().await?,

Char('Q') => {
let q = self.client.sending_queue();
let enabled = q.is_enabled();
if enabled {
q.disable();
} else {
q.enable();
}
}

Char('M') => {
if let Some(sdk_timeline) =
self.get_selected_room_id(None).and_then(|room_id| {
self.timelines
.lock()
.unwrap()
.get(&room_id)
.map(|timeline| timeline.timeline.clone())
})
{
sdk_timeline
.send(
RoomMessageEventContent::text_plain(format!(
"hey {}",
MilliSecondsSinceUnixEpoch::now().get()
))
.into(),
)
.await;

self.set_status_message("message sent!".to_owned());
} else {
self.set_status_message("missing timeline for room".to_owned());
};
}

Char('r') => self.details_mode = DetailsMode::ReadReceipts,
Char('t') => self.details_mode = DetailsMode::TimelineItems,

Expand Down Expand Up @@ -769,10 +807,10 @@ impl App {
} else {
match self.details_mode {
DetailsMode::ReadReceipts => {
"\nUse ↓↑ to move, s/S to start/stop the sync service, m to mark as read, t to show the timeline.".to_owned()
"\nUse j/k to move, s/S to start/stop the sync service, m to mark as read, t to show the timeline.".to_owned()
}
DetailsMode::TimelineItems => {
"\nUse ↓↑ to move, s/S to start/stop the sync service, r to show read receipts.".to_owned()
"\nUse j/k to move, s/S to start/stop the sync service, r to show read receipts, Q to enable/disable the sending queue, M to send a message.".to_owned()
}
}
};
Expand Down
Loading