Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: fix list memos order by pinned

Steven34af969785ef
diff --git a/api/v2/memo_service.go b/api/v2/memo_service.go
index 5f4b95681..6082e1c76 100644
--- a/api/v2/memo_service.go
+++ b/api/v2/memo_service.go
@@ -62,6 +62,9 @@ func (s *APIV2Service) ListMemos(ctx context.Context, request *apiv2pb.ListMemos
if len(filter.Visibilities) > 0 {
memoFind.VisibilityList = filter.Visibilities
}
+ if filter.OrderByPinned {
+ memoFind.OrderByPinned = filter.OrderByPinned
+ }
if filter.CreatedTsBefore != nil {
memoFind.CreatedTsBefore = filter.CreatedTsBefore
}
@@ -516,17 +519,19 @@ func convertVisibilityToStore(visibility apiv2pb.Visibility) store.Visibility {
// ListMemosFilterCELAttributes are the CEL attributes for ListMemosFilter.
var ListMemosFilterCELAttributes = []cel.EnvOption{
+ cel.Variable("content_search", 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_after", cel.IntType),
cel.Variable("creator", cel.StringType),
- cel.Variable("content_search", cel.ListType(cel.StringType)),
cel.Variable("row_status", cel.StringType),
}
type ListMemosFilter struct {
ContentSearch []string
Visibilities []store.Visibility
+ OrderByPinned bool
CreatedTsBefore *int64
CreatedTsAfter *int64
Creator *string
@@ -570,6 +575,9 @@ func findField(callExpr *expr.Expr_Call, filter *ListMemosFilter) {
visibilities = append(visibilities, store.Visibility(value))
}
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" {
createdTsBefore := callExpr.Args[1].GetConstExpr().GetInt64Value()
filter.CreatedTsBefore = &createdTsBefore
diff --git a/web/src/pages/Home.tsx b/web/src/pages/Home.tsx
index 9967fb313..6d33cf807 100644
--- a/web/src/pages/Home.tsx
+++ b/web/src/pages/Home.tsx
@@ -34,7 +34,7 @@ const Home = () => {
}, [tagQuery, textQuery]);
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[] = [];
if (tagQuery) {
contentSearch.push(`"#${tagQuery}"`);