Skip to content

Commit

Permalink
Stay on the last selected tab when available
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonbaeten committed Aug 22, 2023
1 parent 1501be5 commit 2a558e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/src/overview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Component for Overview {
.iter_mut()
.find(|m| m.id == self.selected && !m.opened);

if let Some(mut unopened_message) = unopened {
if let Some(unopened_message) = unopened {
if self.sender.try_send(Action::Open(id)).is_err() {
error!("Error registering email as opened");
}
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ pub fn view(props: &ViewMessageProps) -> Html {
let id = props.message.id.clone();
let set_tab = props.set_tab.clone();
let inner_message = message.clone();
let current_tab = props.active_tab.clone();
use_effect_with_deps(
|message_id| {
let message_id = message_id.clone();
spawn_local(async move {
let message = fetch_message(&message_id).await;
if message.html.is_empty() {
if message.html.is_empty() && current_tab == Tab::Formatted {
set_tab.emit(Tab::Text)
} else {
set_tab.emit(Tab::Formatted)
}
if message.text.is_empty() && current_tab == Tab::Text {
set_tab.emit(Tab::Formatted);
}
inner_message.set(message);
});
Expand Down

0 comments on commit 2a558e1

Please sign in to comment.