mirror of
https://github.com/usememos/memos.git
synced 2025-03-31 02:50:17 +02:00
chore: allow search comments
This commit is contained in:
parent
2cdcd17ba3
commit
339fecbfff
@ -667,6 +667,9 @@ func (s *APIV2Service) buildMemoFindWithFilter(ctx context.Context, find *store.
|
|||||||
if filter.Limit != nil {
|
if filter.Limit != nil {
|
||||||
find.Limit = filter.Limit
|
find.Limit = filter.Limit
|
||||||
}
|
}
|
||||||
|
if filter.IncludeComments {
|
||||||
|
find.ExcludeComments = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user is not authenticated, only public memos are visible.
|
// 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("row_status", cel.StringType),
|
||||||
cel.Variable("random", cel.BoolType),
|
cel.Variable("random", cel.BoolType),
|
||||||
cel.Variable("limit", cel.IntType),
|
cel.Variable("limit", cel.IntType),
|
||||||
|
cel.Variable("include_comments", cel.BoolType),
|
||||||
}
|
}
|
||||||
|
|
||||||
type SearchMemosFilter struct {
|
type SearchMemosFilter struct {
|
||||||
@ -716,6 +720,7 @@ type SearchMemosFilter struct {
|
|||||||
RowStatus *store.RowStatus
|
RowStatus *store.RowStatus
|
||||||
Random bool
|
Random bool
|
||||||
Limit *int
|
Limit *int
|
||||||
|
IncludeComments bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseSearchMemosFilter(expression string) (*SearchMemosFilter, error) {
|
func parseSearchMemosFilter(expression string) (*SearchMemosFilter, error) {
|
||||||
@ -779,6 +784,9 @@ func findSearchMemosField(callExpr *expr.Expr_Call, filter *SearchMemosFilter) {
|
|||||||
} else if idExpr.Name == "limit" {
|
} else if idExpr.Name == "limit" {
|
||||||
limit := int(callExpr.Args[1].GetConstExpr().GetInt64Value())
|
limit := int(callExpr.Args[1].GetConstExpr().GetInt64Value())
|
||||||
filter.Limit = &limit
|
filter.Limit = &limit
|
||||||
|
} else if idExpr.Name == "include_comments" {
|
||||||
|
value := callExpr.Args[1].GetConstExpr().GetBoolValue()
|
||||||
|
filter.IncludeComments = value
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ const CreateMemoRelationDialog: React.FC<Props> = (props: Props) => {
|
|||||||
async () => {
|
async () => {
|
||||||
setIsFetching(true);
|
setIsFetching(true);
|
||||||
try {
|
try {
|
||||||
const filters = [`creator == "${user.name}"`, `row_status == "NORMAL"`];
|
const filters = [`creator == "${user.name}"`, `row_status == "NORMAL"`, `include_comments == true`];
|
||||||
if (searchText) {
|
if (searchText) {
|
||||||
filters.push(`content_search == [${JSON.stringify(searchText)}]`);
|
filters.push(`content_search == [${JSON.stringify(searchText)}]`);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => {
|
|||||||
const resourceName = `memos/${resourceId}`;
|
const resourceName = `memos/${resourceId}`;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
memoStore.searchMemos(`uid == "${resourceId}"`).finally(() => loadingState.setFinish());
|
memoStore.searchMemos(`uid == "${resourceId}" && include_comments == true`).finally(() => loadingState.setFinish());
|
||||||
}, [resourceId]);
|
}, [resourceId]);
|
||||||
|
|
||||||
if (loadingState.isLoading) {
|
if (loadingState.isLoading) {
|
||||||
|
@ -17,7 +17,7 @@ const ReferencedMemo = ({ resourceId, params: paramsStr }: Props) => {
|
|||||||
const params = new URLSearchParams(paramsStr);
|
const params = new URLSearchParams(paramsStr);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
memoStore.searchMemos(`uid == "${resourceId}"`).finally(() => loadingState.setFinish());
|
memoStore.searchMemos(`uid == "${resourceId}" && include_comments == true`).finally(() => loadingState.setFinish());
|
||||||
}, [resourceId]);
|
}, [resourceId]);
|
||||||
|
|
||||||
if (loadingState.isLoading) {
|
if (loadingState.isLoading) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user