diff --git a/server/route/api/v2/memo_service.go b/server/route/api/v2/memo_service.go index ab29ab73f..cba72bfd4 100644 --- a/server/route/api/v2/memo_service.go +++ b/server/route/api/v2/memo_service.go @@ -667,6 +667,9 @@ func (s *APIV2Service) buildMemoFindWithFilter(ctx context.Context, find *store. if filter.Limit != nil { find.Limit = filter.Limit } + if filter.IncludeComments { + find.ExcludeComments = false + } } // If the user is not authenticated, only public memos are visible. @@ -703,6 +706,7 @@ var SearchMemosFilterCELAttributes = []cel.EnvOption{ cel.Variable("row_status", cel.StringType), cel.Variable("random", cel.BoolType), cel.Variable("limit", cel.IntType), + cel.Variable("include_comments", cel.BoolType), } type SearchMemosFilter struct { @@ -716,6 +720,7 @@ type SearchMemosFilter struct { RowStatus *store.RowStatus Random bool Limit *int + IncludeComments bool } func parseSearchMemosFilter(expression string) (*SearchMemosFilter, error) { @@ -779,6 +784,9 @@ func findSearchMemosField(callExpr *expr.Expr_Call, filter *SearchMemosFilter) { } else if idExpr.Name == "limit" { limit := int(callExpr.Args[1].GetConstExpr().GetInt64Value()) filter.Limit = &limit + } else if idExpr.Name == "include_comments" { + value := callExpr.Args[1].GetConstExpr().GetBoolValue() + filter.IncludeComments = value } return } diff --git a/web/src/components/CreateMemoRelationDialog.tsx b/web/src/components/CreateMemoRelationDialog.tsx index 0fb68b6ef..6da3848ff 100644 --- a/web/src/components/CreateMemoRelationDialog.tsx +++ b/web/src/components/CreateMemoRelationDialog.tsx @@ -30,7 +30,7 @@ const CreateMemoRelationDialog: React.FC = (props: Props) => { async () => { setIsFetching(true); try { - const filters = [`creator == "${user.name}"`, `row_status == "NORMAL"`]; + const filters = [`creator == "${user.name}"`, `row_status == "NORMAL"`, `include_comments == true`]; if (searchText) { filters.push(`content_search == [${JSON.stringify(searchText)}]`); } diff --git a/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx b/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx index 0f1ea0a18..2a3d12705 100644 --- a/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx +++ b/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx @@ -21,7 +21,7 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => { const resourceName = `memos/${resourceId}`; useEffect(() => { - memoStore.searchMemos(`uid == "${resourceId}"`).finally(() => loadingState.setFinish()); + memoStore.searchMemos(`uid == "${resourceId}" && include_comments == true`).finally(() => loadingState.setFinish()); }, [resourceId]); if (loadingState.isLoading) { diff --git a/web/src/components/MemoContent/ReferencedContent/ReferencedMemo.tsx b/web/src/components/MemoContent/ReferencedContent/ReferencedMemo.tsx index e9dd66683..d6ec55ebd 100644 --- a/web/src/components/MemoContent/ReferencedContent/ReferencedMemo.tsx +++ b/web/src/components/MemoContent/ReferencedContent/ReferencedMemo.tsx @@ -17,7 +17,7 @@ const ReferencedMemo = ({ resourceId, params: paramsStr }: Props) => { const params = new URLSearchParams(paramsStr); useEffect(() => { - memoStore.searchMemos(`uid == "${resourceId}"`).finally(() => loadingState.setFinish()); + memoStore.searchMemos(`uid == "${resourceId}" && include_comments == true`).finally(() => loadingState.setFinish()); }, [resourceId]); if (loadingState.isLoading) {