-
Notifications
You must be signed in to change notification settings - Fork 20
Added not wasm config for get_ancestors #386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
d0eedbc
4cb672d
d8dea97
669639d
65be635
3f9f4b2
e1bfcdc
43abdd4
cb3f5a4
be918f9
464f697
8161973
1507425
b029292
f480f89
789b822
c22741e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
use std::{collections::HashMap, sync::Arc}; | ||
use std::sync::Arc; | ||
|
||
use bitwarden_collections::{ | ||
collection::{Collection, CollectionView}, | ||
collection::{Collection, CollectionId, CollectionView}, | ||
tree::{NodeItem, Tree}, | ||
}; | ||
use uuid::Uuid; | ||
use bitwarden_vault::collection_client::AncestorMap; | ||
|
||
use crate::{error::Error, Result}; | ||
|
||
|
@@ -40,25 +40,34 @@ pub struct CollectionViewTree { | |
} | ||
|
||
#[derive(uniffi::Object)] | ||
#[allow(unused)] | ||
pub struct CollectionViewNodeItem { | ||
node_item: NodeItem<CollectionView>, | ||
} | ||
|
||
#[uniffi::export] | ||
impl CollectionViewTree { | ||
pub fn get_item_by_id(&self, collection_id: Uuid) -> Option<Arc<CollectionViewNodeItem>> { | ||
pub fn get_item_by_id( | ||
&self, | ||
collection_view: CollectionView, | ||
) -> Option<Arc<CollectionViewNodeItem>> { | ||
self.tree | ||
.get_item_by_id(collection_id) | ||
.get_item_by_id(collection_view.id.unwrap_or_default().into()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. โ Are we ok with swallowing an empty or invalid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Long term I think we would split I wouldn't be particularly concerned about ID being |
||
.map(|n| Arc::new(CollectionViewNodeItem { node_item: n })) | ||
} | ||
|
||
pub fn get_root_items(&self) -> Vec<Arc<CollectionViewNodeItem>> { | ||
self.tree | ||
.nodes | ||
.iter() | ||
.filter(|n| n.parent_idx.is_none()) | ||
.filter_map(|n| self.get_item_by_id(n.item_id)) | ||
.get_root_items() | ||
.into_iter() | ||
.map(|n| Arc::new(CollectionViewNodeItem { node_item: n })) | ||
.collect() | ||
} | ||
|
||
pub fn get_flat_items(&self) -> Vec<Arc<CollectionViewNodeItem>> { | ||
self.tree | ||
.get_flat_items() | ||
.into_iter() | ||
.map(|n| Arc::new(CollectionViewNodeItem { node_item: n })) | ||
.collect() | ||
} | ||
} | ||
|
@@ -77,7 +86,14 @@ impl CollectionViewNodeItem { | |
self.node_item.children.clone() | ||
} | ||
|
||
pub fn get_ancestors(&self) -> HashMap<Uuid, String> { | ||
self.node_item.ancestors.clone() | ||
pub fn get_ancestors(&self) -> AncestorMap { | ||
AncestorMap { | ||
ancestors: self | ||
.node_item | ||
.ancestors | ||
.iter() | ||
.map(|(&uuid, name)| (CollectionId::new(uuid), name.clone())) | ||
.collect(), | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.