Skip to content
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

chore: include parent view id in initial chat settings #7030

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: include parent view id in initial chat settings
  • Loading branch information
richardshiue committed Dec 21, 2024
commit f75a4cec77ee3fd5a4ae9f90ccb6fbcce9542563
2 changes: 1 addition & 1 deletion frontend/rust-lib/flowy-core/src/deps_resolve/chat_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl AIExternalService for ChatQueryServiceImpl {
) -> Result<Vec<String>, FlowyError> {
let mut ids = self
.folder_service
.get_sibling_ids_with_view_layout(parent_view_id, ViewLayout::Document)
.get_surrounding_view_ids_with_view_layout(parent_view_id, ViewLayout::Document)
.await;

if !ids.is_empty() {
Expand Down
52 changes: 29 additions & 23 deletions frontend/rust-lib/flowy-core/src/deps_resolve/folder_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,35 +686,41 @@ impl FolderViewEdit for FolderServiceImpl {

#[async_trait]
impl FolderQueryService for FolderServiceImpl {
async fn get_sibling_ids_with_view_layout(
async fn get_surrounding_view_ids_with_view_layout(
&self,
parent_view_id: &str,
view_layout: ViewLayout,
) -> Vec<String> {
match self.folder_manager.upgrade() {
None => vec![],
Some(folder_manager) => {
if let Ok(parent_view) = folder_manager.get_view(parent_view_id).await {
if parent_view.space_info().is_none() {
if let Ok(views) = folder_manager
.get_untrashed_views_belong_to(parent_view_id)
.await
{
return views
.into_iter()
.filter_map(|child| {
if child.layout == view_layout {
Some(child.id.clone())
} else {
None
}
})
.collect::<Vec<String>>();
let folder_manager = match self.folder_manager.upgrade() {
Some(folder_manager) => folder_manager,
None => return vec![],
};

if let Ok(view) = folder_manager.get_view(parent_view_id).await {
if view.space_info().is_some() {
return vec![];
}
}

match folder_manager
.get_untrashed_views_belong_to(parent_view_id)
.await
{
Ok(views) => {
let mut children = views
.into_iter()
.filter_map(|child| {
if child.layout == view_layout {
Some(child.id.clone())
} else {
None
}
}
}
vec![]
})
.collect::<Vec<_>>();
children.push(parent_view_id.to_string());
children
},
_ => vec![],
}
}

Expand Down
4 changes: 3 additions & 1 deletion frontend/rust-lib/flowy-folder-pub/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ pub trait FolderService: FolderQueryService + FolderViewEdit {}

#[async_trait]
pub trait FolderQueryService: Send + Sync + 'static {
async fn get_sibling_ids_with_view_layout(
/// gets the parent view and all of the ids of its children views matching
/// the provided view layout, given that the parent view is not a space
async fn get_surrounding_view_ids_with_view_layout(
&self,
parent_view_id: &str,
view_layout: ViewLayout,
Expand Down
Loading