mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
narrow: Extract common methods around setting current list.
This will help us combine activate and deactivate.
This commit is contained in:
@@ -86,6 +86,20 @@ export function save_narrow(terms) {
|
|||||||
changehash(new_hash);
|
changehash(new_hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function update_current_message_list(msg_list) {
|
||||||
|
if (msg_list !== message_lists.home) {
|
||||||
|
message_lists.home?.view.$list.removeClass("focused-message-list");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message_lists.current !== message_lists.home) {
|
||||||
|
// Remove old msg list from DOM.
|
||||||
|
message_lists.current?.view.$list.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
message_lists.set_current(msg_list);
|
||||||
|
message_lists.current.view.$list.addClass("focused-message-list");
|
||||||
|
}
|
||||||
|
|
||||||
export function activate(raw_terms, opts) {
|
export function activate(raw_terms, opts) {
|
||||||
/* Main entry point for switching to a new view / message list.
|
/* Main entry point for switching to a new view / message list.
|
||||||
Note that for historical reasons related to the current
|
Note that for historical reasons related to the current
|
||||||
@@ -425,14 +439,7 @@ export function activate(raw_terms, opts) {
|
|||||||
// Show the new set of messages. It is important to set message_lists.current to
|
// Show the new set of messages. It is important to set message_lists.current to
|
||||||
// the view right as it's being shown, because we rely on message_lists.current
|
// the view right as it's being shown, because we rely on message_lists.current
|
||||||
// being shown for deciding when to condense messages.
|
// being shown for deciding when to condense messages.
|
||||||
msg_list.view.$list.addClass("focused-message-list");
|
update_current_message_list(msg_list);
|
||||||
message_lists.home.view.$list.removeClass("focused-message-list");
|
|
||||||
|
|
||||||
// Remove old message list from DOM.
|
|
||||||
if (message_lists.current !== message_lists.home) {
|
|
||||||
message_lists.current?.view.$list.remove();
|
|
||||||
}
|
|
||||||
message_lists.set_current(msg_list);
|
|
||||||
|
|
||||||
let then_select_offset;
|
let then_select_offset;
|
||||||
if (id_info.target_id === id_info.final_select_id) {
|
if (id_info.target_id === id_info.final_select_id) {
|
||||||
@@ -1077,12 +1084,7 @@ export function deactivate() {
|
|||||||
narrow_state.reset_current_filter();
|
narrow_state.reset_current_filter();
|
||||||
narrow_state.set_has_shown_message_list_view();
|
narrow_state.set_has_shown_message_list_view();
|
||||||
|
|
||||||
message_lists.home.view.$list.addClass("focused-message-list");
|
update_current_message_list(message_lists.home);
|
||||||
// Remove old message list from DOM.
|
|
||||||
if (message_lists.current !== message_lists.home) {
|
|
||||||
message_lists.current?.view.$list.remove();
|
|
||||||
}
|
|
||||||
message_lists.set_current(message_lists.home);
|
|
||||||
message_lists.current.resume_reading();
|
message_lists.current.resume_reading();
|
||||||
condense.condense_and_collapse(message_lists.home.view.$list.find(".message_row"));
|
condense.condense_and_collapse(message_lists.home.view.$list.find(".message_row"));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user