Skip to content

Commit

Permalink
Merge pull request #630 from squidowl/remove-scroll-to-backlog-button
Browse files Browse the repository at this point in the history
  • Loading branch information
casperstorm authored Oct 26, 2024
2 parents c02ccd1 + f53a3b6 commit eb072f5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 52 deletions.
4 changes: 0 additions & 4 deletions src/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ pub fn scroll_to_bottom<'a>() -> Text<'a> {
to_text('\u{E814}')
}

pub fn scroll_to_unread<'a>() -> Text<'a> {
to_text('\u{F0E0}')
}

fn to_text<'a>(unicode: char) -> Text<'a> {
text(unicode.to_string())
.line_height(LineHeight::Relative(1.0))
Expand Down
17 changes: 0 additions & 17 deletions src/screen/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,23 +401,6 @@ impl Dashboard {
pane::Message::MaximizePane => self.maximize_pane(),
pane::Message::Popout => return (self.popout_pane(main_window), None),
pane::Message::Merge => return (self.merge_pane(config, main_window), None),
pane::Message::ScrollToBacklog => {
if let Some((window, pane)) = self.focus {
if let Some(state) = self.panes.get_mut(main_window.id, window, pane) {
return (
state.buffer.scroll_to_backlog(&self.history, config).map(
move |message| {
Message::Pane(
window,
pane::Message::Buffer(pane, message),
)
},
),
None,
);
}
}
}
pane::Message::ScrollToBottom => {
if let Some((window, pane)) = self.focus {
if let Some(state) = self.panes.get_mut(main_window.id, window, pane) {
Expand Down
48 changes: 17 additions & 31 deletions src/screen/dashboard/pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub enum Message {
ToggleShowTopic,
Popout,
Merge,
ScrollToBacklog,
ScrollToBottom,
}

Expand Down Expand Up @@ -161,36 +160,23 @@ impl TitleBar {
let mut controls = row![].spacing(2);

if let Buffer::Channel(state) = &buffer {
// Show scroll-to-bottom / scroll-to-backlog depending if scrollable is anchored to the end or not
let (icon, tooltip_text, message) =
if buffer.is_scrolled_to_bottom().unwrap_or_default() {
(
icon::scroll_to_unread(),
"Scroll to Backlog",
Message::ScrollToBacklog,
)
} else {
(
icon::scroll_to_bottom(),
"Scroll to Bottom",
Message::ScrollToBottom,
)
};

let scrollable_button = button(center(icon))
.padding(5)
.width(22)
.height(22)
.on_press(message)
.style(|theme, status| theme::button::secondary(theme, status, false));

let scrollable_button_with_tooltip = tooltip(
scrollable_button,
show_tooltips.then_some(tooltip_text),
tooltip::Position::Bottom,
);

controls = controls.push(scrollable_button_with_tooltip);
// Show scroll-to-bottom if scrollable isnt scrolled to bottom.
if !buffer.is_scrolled_to_bottom().unwrap_or_default() {
let scrollable_button = button(center(icon::scroll_to_bottom()))
.padding(5)
.width(22)
.height(22)
.on_press(Message::ScrollToBottom)
.style(|theme, status| theme::button::secondary(theme, status, false));

let scrollable_button_with_tooltip = tooltip(
scrollable_button,
show_tooltips.then_some("Scroll to Bottom"),
tooltip::Position::Bottom,
);

controls = controls.push(scrollable_button_with_tooltip);
}

// Show topic button only if there is a topic to show
if let Some(topic) = clients.get_channel_topic(&state.server, &state.channel) {
Expand Down

0 comments on commit eb072f5

Please sign in to comment.