mirror of
https://github.com/usememos/memos.git
synced 2024-09-11 12:05:29 +03: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 {
|
||||
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
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ const CreateMemoRelationDialog: React.FC<Props> = (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)}]`);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user