android: hide new post button when navigating
Fixes: https://github.com/damus-io/notedeck/issues/898 Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -32,10 +32,15 @@ impl Default for DecksCache {
|
||||
impl DecksCache {
|
||||
/// Gets the first column in the currently active user's active deck
|
||||
pub fn selected_column_mut(&mut self, accounts: ¬edeck::Accounts) -> Option<&mut Column> {
|
||||
self.active_columns_mut(accounts).map(|ad| ad.selected())
|
||||
self.active_columns_mut(accounts)
|
||||
.map(|ad| ad.selected_mut())
|
||||
}
|
||||
|
||||
/// Gets the active columns
|
||||
pub fn selected_column(&self, accounts: ¬edeck::Accounts) -> Option<&Column> {
|
||||
self.active_columns(accounts).map(|ad| ad.selected())
|
||||
}
|
||||
|
||||
/// Gets a mutable reference to the active columns
|
||||
pub fn active_columns_mut(&mut self, accounts: ¬edeck::Accounts) -> Option<&mut Columns> {
|
||||
let account = accounts.get_selected_account();
|
||||
|
||||
@@ -44,6 +49,15 @@ impl DecksCache {
|
||||
.map(|ad| ad.columns_mut())
|
||||
}
|
||||
|
||||
/// Gets an immutable reference to the active columns
|
||||
pub fn active_columns(&self, accounts: ¬edeck::Accounts) -> Option<&Columns> {
|
||||
let account = accounts.get_selected_account();
|
||||
|
||||
self.decks(&account.key.pubkey)
|
||||
.active_deck()
|
||||
.map(|ad| ad.columns())
|
||||
}
|
||||
|
||||
pub fn new(mut account_to_decks: HashMap<Pubkey, Decks>) -> Self {
|
||||
let fallback_pubkey = FALLBACK_PUBKEY();
|
||||
account_to_decks.entry(fallback_pubkey).or_default();
|
||||
@@ -187,7 +201,7 @@ impl Decks {
|
||||
&self.decks
|
||||
}
|
||||
|
||||
pub fn active_deck_mut(&mut self) -> Option<&mut Deck> {
|
||||
fn active_deck_index(&self) -> Option<usize> {
|
||||
if self.decks.is_empty() {
|
||||
return None;
|
||||
}
|
||||
@@ -197,7 +211,15 @@ impl Decks {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(&mut self.decks[active])
|
||||
Some(active)
|
||||
}
|
||||
|
||||
pub fn active_deck(&self) -> Option<&Deck> {
|
||||
self.active_deck_index().map(|ind| &self.decks[ind])
|
||||
}
|
||||
|
||||
pub fn active_deck_mut(&mut self) -> Option<&mut Deck> {
|
||||
self.active_deck_index().map(|ind| &mut self.decks[ind])
|
||||
}
|
||||
|
||||
pub fn decks_mut(&mut self) -> &mut Vec<Deck> {
|
||||
|
||||
Reference in New Issue
Block a user