Skip to content

Commit

Permalink
Merge pull request #405 from squidowl/feat/hide_buffer_indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
casperstorm authored Jun 24, 2024
2 parents fb52571 + 0dfe3de commit 8f2bd61
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
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

0 comments on commit 8f2bd61

Please sign in to comment.