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

feat: Add urgent bell support 🔔 #233

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
emoji,
remove,
false,
false,
);

self.reset_unread_messages();
Expand Down Expand Up @@ -681,6 +682,7 @@
emoji,
remove.unwrap_or(false),
true,
true,
);
read.into_iter().for_each(|r| {
self.handle_receipt(
Expand Down Expand Up @@ -734,6 +736,7 @@
emoji,
remove.unwrap_or(false),
true,
true,
);
return Ok(());
}
Expand Down Expand Up @@ -807,6 +810,7 @@
if !notification.is_empty() {
self.notify(from, &notification);
}
self.bell();
}

pub fn step_receipts(&mut self) {
Expand Down Expand Up @@ -921,7 +925,7 @@
}
}

fn handle_reaction(

Check warning on line 928 in src/app.rs

View workflow job for this annotation

GitHub Actions / clippy

this function has too many arguments (8/7)
&mut self,
channel_id: ChannelId,
target_sent_timestamp: u64,
Expand All @@ -929,6 +933,7 @@
emoji: String,
remove: bool,
notify: bool,
bell: bool,
) -> Option<()> {
let mut message = self
.storage
Expand Down Expand Up @@ -976,6 +981,10 @@
self.notify(&summary, &format!("{summary} {notification}"));
}

if bell {
self.bell();
}

let channel_idx = self
.channels
.items
Expand Down Expand Up @@ -1224,6 +1233,12 @@
}
}

fn bell(&self) {
if self.config.bell {
print!("\x07");
}
}

fn extract_attachments(&mut self, input: &str) -> (String, Vec<(AttachmentSpec, Vec<u8>)>) {
let mut offset = 0;
let mut clean_input = String::new();
Expand Down
3 changes: 3 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub struct Config {
/// Whether to show system notifications on incoming messages
#[serde(default = "default_true")]
pub notifications: bool,
#[serde(default = "default_true")]
pub bell: bool,
/// User configuration
pub user: User,
#[cfg(feature = "dev")]
Expand Down Expand Up @@ -62,6 +64,7 @@ impl Config {
first_name_only: false,
show_receipts: true,
notifications: true,
bell: true,
#[cfg(feature = "dev")]
developer: Default::default(),
sqlite: Default::default(),
Expand Down
Loading