Rename some methods for consistency
This commit is contained in:
parent
ee216d407e
commit
282609916a
6 changed files with 71 additions and 57 deletions
|
|
@ -85,7 +85,7 @@ impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
|
|||
} else if tree.parent(id).is_none() {
|
||||
// We're at the root of our tree, so we need to move to the root of
|
||||
// the previous tree.
|
||||
if let Some(prev_tree_id) = store.prev_tree(tree.root()).await {
|
||||
if let Some(prev_tree_id) = store.prev_tree_id(tree.root()).await {
|
||||
*tree = store.tree(&prev_tree_id).await;
|
||||
*id = prev_tree_id;
|
||||
true
|
||||
|
|
@ -107,7 +107,7 @@ impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
|
|||
} else if tree.parent(id).is_none() {
|
||||
// We're at the root of our tree, so we need to move to the root of
|
||||
// the next tree.
|
||||
if let Some(next_tree_id) = store.next_tree(tree.root()).await {
|
||||
if let Some(next_tree_id) = store.next_tree_id(tree.root()).await {
|
||||
*tree = store.tree(&next_tree_id).await;
|
||||
*id = next_tree_id;
|
||||
true
|
||||
|
|
@ -157,7 +157,7 @@ impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
|
|||
pub async fn move_cursor_up(&mut self) {
|
||||
match &mut self.cursor {
|
||||
Cursor::Bottom => {
|
||||
if let Some(last_tree_id) = self.store.last_tree().await {
|
||||
if let Some(last_tree_id) = self.store.last_tree_id().await {
|
||||
let tree = self.store.tree(&last_tree_id).await;
|
||||
let mut id = last_tree_id;
|
||||
while Self::find_last_child(&tree, &mut id) {}
|
||||
|
|
@ -186,8 +186,8 @@ impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
|
|||
}
|
||||
|
||||
pub async fn move_cursor_to_top(&mut self) {
|
||||
if let Some(tree_id) = self.store.first_tree().await {
|
||||
self.cursor = Cursor::Msg(tree_id);
|
||||
if let Some(first_tree_id) = self.store.first_tree_id().await {
|
||||
self.cursor = Cursor::Msg(first_tree_id);
|
||||
self.make_cursor_visible = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use super::{util, InnerTreeViewState};
|
|||
impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
|
||||
async fn cursor_path(&self, cursor: &Cursor<M::Id>) -> Path<M::Id> {
|
||||
match cursor {
|
||||
Cursor::Bottom => match self.store.last_tree().await {
|
||||
Cursor::Bottom => match self.store.last_tree_id().await {
|
||||
Some(id) => Path::new(vec![id]),
|
||||
None => Path::new(vec![M::last_possible_id()]),
|
||||
},
|
||||
|
|
@ -217,9 +217,9 @@ impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
|
|||
async fn expand_blocks_up(&self, frame: &mut Frame, blocks: &mut Blocks<M::Id>) {
|
||||
while blocks.top_line > 0 {
|
||||
let tree_id = if let Some((root_top, _)) = &blocks.roots {
|
||||
self.store.prev_tree(root_top).await
|
||||
self.store.prev_tree_id(root_top).await
|
||||
} else {
|
||||
self.store.last_tree().await
|
||||
self.store.last_tree_id().await
|
||||
};
|
||||
|
||||
if let Some(tree_id) = tree_id {
|
||||
|
|
@ -234,7 +234,7 @@ impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
|
|||
async fn expand_blocks_down(&self, frame: &mut Frame, blocks: &mut Blocks<M::Id>) {
|
||||
while blocks.bottom_line < frame.size().height as i32 {
|
||||
let tree_id = if let Some((_, root_bot)) = &blocks.roots {
|
||||
self.store.next_tree(root_bot).await
|
||||
self.store.next_tree_id(root_bot).await
|
||||
} else {
|
||||
// We assume that a Blocks without roots is at the bottom of the
|
||||
// room's history. Therefore, there are no more messages below.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue