1
//! The Transactions tab's server pages: a reply, a page turn and the continuation at an edge.
2

            
3
use crate::app::App;
4
use crate::tabs::fetch::Fetch;
5
use crate::tabs::list::ListTab;
6
use crate::view::Tab;
7
use crate::window::WindowId;
8

            
9
impl App {
10
84
    pub(super) fn deliver_transactions_reply(&mut self, window: WindowId, wire: &str) {
11
84
        let Some(list) = self.win_mut::<ListTab>(window) else {
12
            return;
13
        };
14
84
        list.on_reply(wire);
15
84
        let idle = list.state == Fetch::Idle;
16
84
        if idle {
17
2
            self.ensure_list_loaded(window);
18
82
        }
19
84
    }
20

            
21
    /// Fetch the next or previous page of the Transactions tab.
22
19
    pub fn page_transactions(&mut self, forward: bool) {
23
19
        if let Some(window) = self.front_or_say(Tab::Transactions) {
24
18
            self.load_page(window, forward, false);
25
1
        }
26
19
    }
27

            
28
    /// Continue window `window` into the next (`forward`) or previous page when its selection
29
    /// is on the loaded page's edge row; `false` when the move stays on the page.
30
62
    pub fn continue_transactions_page(&mut self, window: WindowId, forward: bool) -> bool {
31
62
        self.load_page(window, forward, true)
32
62
    }
33

            
34
80
    fn load_page(&mut self, window: WindowId, forward: bool, from_edge: bool) -> bool {
35
80
        let Some(list) = self.win_mut::<ListTab>(window) else {
36
            return false;
37
        };
38
80
        let turned = if from_edge {
39
62
            list.turn_page_at_edge(forward)
40
        } else {
41
18
            list.turn_page(forward)
42
        };
43
80
        if turned {
44
34
            self.load_window(window);
45
46
        }
46
80
        turned
47
80
    }
48
}