Indicate encryption state of room in messagebar (#522)
This commit is contained in:
@@ -7,7 +7,9 @@ use std::path::{Path, PathBuf};
|
||||
|
||||
use edit::edit_with_builder as external_edit;
|
||||
use edit::Builder;
|
||||
use matrix_sdk::EncryptionState;
|
||||
use modalkit::editing::store::RegisterError;
|
||||
use ratatui::style::{Color, Style};
|
||||
use std::process::Command;
|
||||
use tokio;
|
||||
use url::Url;
|
||||
@@ -975,7 +977,16 @@ impl StatefulWidget for Chat<'_> {
|
||||
Paragraph::new(desc_spans).render(descarea, buf);
|
||||
}
|
||||
|
||||
let prompt = if self.focused { "> " } else { " " };
|
||||
let prompt = match (self.focused, state.room().encryption_state()) {
|
||||
(false, _) => Span::raw(" "),
|
||||
(_, EncryptionState::Encrypted) => {
|
||||
Span::styled("\u{1F512}\u{FE0E} ", Style::new().fg(Color::LightGreen))
|
||||
},
|
||||
(_, EncryptionState::NotEncrypted) => {
|
||||
Span::styled("\u{1F513}\u{FE0E} ", Style::new().fg(Color::Red))
|
||||
},
|
||||
(_, EncryptionState::Unknown) => Span::styled("> ", Style::new().fg(Color::Red)),
|
||||
};
|
||||
|
||||
let tbox = TextBox::new().prompt(prompt);
|
||||
tbox.render(textarea, buf, &mut state.tbox);
|
||||
|
||||
@@ -283,6 +283,9 @@ async fn load_older_one(
|
||||
limit: u32,
|
||||
) -> MessageFetchResult {
|
||||
if let Some(room) = client.get_room(room_id) {
|
||||
// Update cached encryption state. This is a noop if the state is already cached.
|
||||
let _ = room.request_encryption_state().await;
|
||||
|
||||
let mut opts = match &fetch_id {
|
||||
Some(id) => MessagesOptions::backward().from(id.as_str()),
|
||||
None => MessagesOptions::backward(),
|
||||
|
||||
Reference in New Issue
Block a user