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: ability to hide unread indicators #405

Merged
merged 1 commit into from
Jun 24, 2024
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Added:
- Ability to open `irc://` and `ircs://` URL schemes
- Ability to overwrite nickname colors by providing a hex string (see [buffer configuration](https://halloy.squidowl.org/configuration/buffer.html#buffernicknamecolor-section)).
- Ability to overwrite server & internal message colors by providing a hex string (see [buffer configuration](https://halloy.squidowl.org/configuration/buffer.html#bufferserver_messages-section)).
- Configurable shortcuts for "Leave Buffer" and "Toggle Sidebar" actions (see [keyboard shortcuts configuration](https://github.com/squidowl/halloy/wiki/Keyboard-shortcuts)).
- Configurable shortcuts for "Leave Buffer" and "Toggle Sidebar" actions (see [keyboard shortcuts configuration](https://halloy.squidowl.org/configuration/keyboard.html)).
- Ability to remember window position and size when reopened.
- Ability to hide unread indicators in sidebar (see [sidemenu configuration](https://halloy.squidowl.org/configuration/sidebar.html))

Fixed:

Expand Down
10 changes: 6 additions & 4 deletions book/src/configuration/sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
[sidebar]
default_action = "new-pane" | "replace-pane"
width = <integer>
show_unread_indicators = true | false
```

| Key | Description | Default |
| ---------------- | -------------------------------------------------------------------------------------- | ------------ |
| `default_action` | Action when selecting buffers in the sidebar. Can be `"new-pane"` or `"replace-pane"`. | `"new-pane"` |
| `width` | Specify sidebar width in pixels. | `120` |
| Key | Description | Default |
| ------------------------ | -------------------------------------------------------------------------------------- | ------------ |
| `default_action` | Action when selecting buffers in the sidebar. Can be `"new-pane"` or `"replace-pane"`. | `"new-pane"` |
| `width` | Specify sidebar width in pixels. | `120` |
| `show_unread_indicators` | Unread buffer indicators | `true` |

## `[sidebar.buttons]` Section

Expand Down
17 changes: 8 additions & 9 deletions data/src/config/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub struct Sidebar {
pub width: u16,
#[serde(default)]
pub buttons: Buttons,
#[serde(default = "default_bool_true")]
pub show_unread_indicators: bool,
}

impl Default for Sidebar {
Expand All @@ -18,23 +20,24 @@ impl Default for Sidebar {
default_action: Default::default(),
width: default_sidebar_width(),
buttons: Default::default(),
show_unread_indicators: default_bool_true(),
}
}
}

#[derive(Debug, Copy, Clone, Deserialize)]
pub struct Buttons {
#[serde(default = "default_file_transfer")]
#[serde(default = "default_bool_true")]
pub file_transfer: bool,
#[serde(default = "default_command_bar")]
#[serde(default = "default_bool_true")]
pub command_bar: bool,
}

impl Default for Buttons {
fn default() -> Self {
Buttons {
file_transfer: default_file_transfer(),
command_bar: default_command_bar(),
file_transfer: default_bool_true(),
command_bar: default_bool_true(),
}
}
}
Expand All @@ -43,10 +46,6 @@ fn default_sidebar_width() -> u16 {
120
}

fn default_file_transfer() -> bool {
true
}

fn default_command_bar() -> bool {
fn default_bool_true() -> bool {
true
}
17 changes: 15 additions & 2 deletions src/screen/dashboard/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ impl Sidebar {
focus,
Buffer::Channel(server.clone(), channel.clone()),
true,
history.has_unread(server, &history::Kind::Channel(channel.clone())),
config
.show_unread_indicators
.then(|| {
history.has_unread(
server,
&history::Kind::Channel(channel.clone()),
)
})
.unwrap_or(false),
config.default_action,
));
}
Expand All @@ -114,7 +122,12 @@ impl Sidebar {
focus,
Buffer::Query(server.clone(), user.clone()),
true,
history.has_unread(server, &history::Kind::Query(user.clone())),
config
.show_unread_indicators
.then(|| {
history.has_unread(server, &history::Kind::Query(user.clone()))
})
.unwrap_or(false),
config.default_action,
));
}
Expand Down
Loading