mirror of
https://github.com/usememos/memos.git
synced 2024-12-28 08:03:01 +08:00
chore: fix list memos order by pinned
This commit is contained in:
parent
fd9c3ccbae
commit
34af969785
2 changed files with 10 additions and 2 deletions
|
@ -62,6 +62,9 @@ func (s *APIV2Service) ListMemos(ctx context.Context, request *apiv2pb.ListMemos
|
||||||
if len(filter.Visibilities) > 0 {
|
if len(filter.Visibilities) > 0 {
|
||||||
memoFind.VisibilityList = filter.Visibilities
|
memoFind.VisibilityList = filter.Visibilities
|
||||||
}
|
}
|
||||||
|
if filter.OrderByPinned {
|
||||||
|
memoFind.OrderByPinned = filter.OrderByPinned
|
||||||
|
}
|
||||||
if filter.CreatedTsBefore != nil {
|
if filter.CreatedTsBefore != nil {
|
||||||
memoFind.CreatedTsBefore = filter.CreatedTsBefore
|
memoFind.CreatedTsBefore = filter.CreatedTsBefore
|
||||||
}
|
}
|
||||||
|
@ -516,17 +519,19 @@ func convertVisibilityToStore(visibility apiv2pb.Visibility) store.Visibility {
|
||||||
|
|
||||||
// ListMemosFilterCELAttributes are the CEL attributes for ListMemosFilter.
|
// ListMemosFilterCELAttributes are the CEL attributes for ListMemosFilter.
|
||||||
var ListMemosFilterCELAttributes = []cel.EnvOption{
|
var ListMemosFilterCELAttributes = []cel.EnvOption{
|
||||||
|
cel.Variable("content_search", cel.ListType(cel.StringType)),
|
||||||
cel.Variable("visibilities", cel.ListType(cel.StringType)),
|
cel.Variable("visibilities", cel.ListType(cel.StringType)),
|
||||||
|
cel.Variable("order_by_pinned", cel.BoolType),
|
||||||
cel.Variable("created_ts_before", cel.IntType),
|
cel.Variable("created_ts_before", cel.IntType),
|
||||||
cel.Variable("created_ts_after", cel.IntType),
|
cel.Variable("created_ts_after", cel.IntType),
|
||||||
cel.Variable("creator", cel.StringType),
|
cel.Variable("creator", cel.StringType),
|
||||||
cel.Variable("content_search", cel.ListType(cel.StringType)),
|
|
||||||
cel.Variable("row_status", cel.StringType),
|
cel.Variable("row_status", cel.StringType),
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListMemosFilter struct {
|
type ListMemosFilter struct {
|
||||||
ContentSearch []string
|
ContentSearch []string
|
||||||
Visibilities []store.Visibility
|
Visibilities []store.Visibility
|
||||||
|
OrderByPinned bool
|
||||||
CreatedTsBefore *int64
|
CreatedTsBefore *int64
|
||||||
CreatedTsAfter *int64
|
CreatedTsAfter *int64
|
||||||
Creator *string
|
Creator *string
|
||||||
|
@ -570,6 +575,9 @@ func findField(callExpr *expr.Expr_Call, filter *ListMemosFilter) {
|
||||||
visibilities = append(visibilities, store.Visibility(value))
|
visibilities = append(visibilities, store.Visibility(value))
|
||||||
}
|
}
|
||||||
filter.Visibilities = visibilities
|
filter.Visibilities = visibilities
|
||||||
|
} else if idExpr.Name == "order_by_pinned" {
|
||||||
|
value := callExpr.Args[1].GetConstExpr().GetBoolValue()
|
||||||
|
filter.OrderByPinned = value
|
||||||
} else if idExpr.Name == "created_ts_before" {
|
} else if idExpr.Name == "created_ts_before" {
|
||||||
createdTsBefore := callExpr.Args[1].GetConstExpr().GetInt64Value()
|
createdTsBefore := callExpr.Args[1].GetConstExpr().GetInt64Value()
|
||||||
filter.CreatedTsBefore = &createdTsBefore
|
filter.CreatedTsBefore = &createdTsBefore
|
||||||
|
|
|
@ -34,7 +34,7 @@ const Home = () => {
|
||||||
}, [tagQuery, textQuery]);
|
}, [tagQuery, textQuery]);
|
||||||
|
|
||||||
const fetchMemos = async () => {
|
const fetchMemos = async () => {
|
||||||
const filters = [`creator == "${user.name}"`, `row_status == "NORMAL"`];
|
const filters = [`creator == "${user.name}"`, `row_status == "NORMAL"`, `order_by_pinned == true`];
|
||||||
const contentSearch: string[] = [];
|
const contentSearch: string[] = [];
|
||||||
if (tagQuery) {
|
if (tagQuery) {
|
||||||
contentSearch.push(`"#${tagQuery}"`);
|
contentSearch.push(`"#${tagQuery}"`);
|
||||||
|
|
Loading…
Reference in a new issue