mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
fix: list memos with pinned
This commit is contained in:
@ -130,6 +130,8 @@ func (s *APIV2Service) ListMemos(ctx context.Context, request *apiv2pb.ListMemos
|
|||||||
if filter.RowStatus != nil {
|
if filter.RowStatus != nil {
|
||||||
memoFind.RowStatus = filter.RowStatus
|
memoFind.RowStatus = filter.RowStatus
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return nil, status.Errorf(codes.InvalidArgument, "filter is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
user, _ := getCurrentUser(ctx, s.Store)
|
user, _ := getCurrentUser(ctx, s.Store)
|
||||||
|
@ -90,7 +90,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
|||||||
"UNIX_TIMESTAMP(`memo`.`updated_ts`) AS `updated_ts`",
|
"UNIX_TIMESTAMP(`memo`.`updated_ts`) AS `updated_ts`",
|
||||||
"`memo`.`row_status` AS `row_status`",
|
"`memo`.`row_status` AS `row_status`",
|
||||||
"`memo`.`visibility` AS `visibility`",
|
"`memo`.`visibility` AS `visibility`",
|
||||||
"`memo_organizer`.`pinned` AS `pinned`",
|
"IFNULL(`memo_organizer`.`pinned`, 0) AS `pinned`",
|
||||||
"`memo_relation`.`related_memo_id` AS `parent_id`",
|
"`memo_relation`.`related_memo_id` AS `parent_id`",
|
||||||
}
|
}
|
||||||
if !find.ExcludeContent {
|
if !find.ExcludeContent {
|
||||||
@ -114,7 +114,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
|||||||
list := make([]*store.Memo, 0)
|
list := make([]*store.Memo, 0)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var memo store.Memo
|
var memo store.Memo
|
||||||
pinned := sql.NullBool{}
|
|
||||||
dests := []any{
|
dests := []any{
|
||||||
&memo.ID,
|
&memo.ID,
|
||||||
&memo.CreatorID,
|
&memo.CreatorID,
|
||||||
@ -122,7 +121,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
|||||||
&memo.UpdatedTs,
|
&memo.UpdatedTs,
|
||||||
&memo.RowStatus,
|
&memo.RowStatus,
|
||||||
&memo.Visibility,
|
&memo.Visibility,
|
||||||
&pinned,
|
&memo.Pinned,
|
||||||
&memo.ParentID,
|
&memo.ParentID,
|
||||||
}
|
}
|
||||||
if !find.ExcludeContent {
|
if !find.ExcludeContent {
|
||||||
@ -131,9 +130,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
|||||||
if err := rows.Scan(dests...); err != nil {
|
if err := rows.Scan(dests...); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if pinned.Valid {
|
|
||||||
memo.Pinned = pinned.Bool
|
|
||||||
}
|
|
||||||
list = append(list, &memo)
|
list = append(list, &memo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
|||||||
`memo.updated_ts AS updated_ts`,
|
`memo.updated_ts AS updated_ts`,
|
||||||
`memo.row_status AS row_status`,
|
`memo.row_status AS row_status`,
|
||||||
`memo.visibility AS visibility`,
|
`memo.visibility AS visibility`,
|
||||||
`memo_organizer.pinned AS pinned`,
|
`COALESCE(memo_organizer.pinned, 0) AS pinned`,
|
||||||
`memo_relation.related_memo_id AS parent_id`,
|
`memo_relation.related_memo_id AS parent_id`,
|
||||||
}
|
}
|
||||||
if !find.ExcludeContent {
|
if !find.ExcludeContent {
|
||||||
@ -110,7 +110,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
|||||||
list := make([]*store.Memo, 0)
|
list := make([]*store.Memo, 0)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var memo store.Memo
|
var memo store.Memo
|
||||||
pinned := sql.NullBool{}
|
|
||||||
dests := []any{
|
dests := []any{
|
||||||
&memo.ID,
|
&memo.ID,
|
||||||
&memo.CreatorID,
|
&memo.CreatorID,
|
||||||
@ -118,7 +117,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
|||||||
&memo.UpdatedTs,
|
&memo.UpdatedTs,
|
||||||
&memo.RowStatus,
|
&memo.RowStatus,
|
||||||
&memo.Visibility,
|
&memo.Visibility,
|
||||||
&pinned,
|
&memo.Pinned,
|
||||||
&memo.ParentID,
|
&memo.ParentID,
|
||||||
}
|
}
|
||||||
if !find.ExcludeContent {
|
if !find.ExcludeContent {
|
||||||
@ -127,9 +126,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
|||||||
if err := rows.Scan(dests...); err != nil {
|
if err := rows.Scan(dests...); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if pinned.Valid {
|
|
||||||
memo.Pinned = pinned.Bool
|
|
||||||
}
|
|
||||||
list = append(list, &memo)
|
list = append(list, &memo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
|||||||
`memo.updated_ts AS updated_ts`,
|
`memo.updated_ts AS updated_ts`,
|
||||||
`memo.row_status AS row_status`,
|
`memo.row_status AS row_status`,
|
||||||
`memo.visibility AS visibility`,
|
`memo.visibility AS visibility`,
|
||||||
`memo_organizer.pinned AS pinned`,
|
`IFNULL(memo_organizer.pinned, 0) AS pinned`,
|
||||||
`memo_relation.related_memo_id AS parent_id`,
|
`memo_relation.related_memo_id AS parent_id`,
|
||||||
}
|
}
|
||||||
if !find.ExcludeContent {
|
if !find.ExcludeContent {
|
||||||
@ -109,7 +109,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
|||||||
list := make([]*store.Memo, 0)
|
list := make([]*store.Memo, 0)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var memo store.Memo
|
var memo store.Memo
|
||||||
pinned := sql.NullBool{}
|
|
||||||
dests := []any{
|
dests := []any{
|
||||||
&memo.ID,
|
&memo.ID,
|
||||||
&memo.CreatorID,
|
&memo.CreatorID,
|
||||||
@ -117,7 +116,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
|||||||
&memo.UpdatedTs,
|
&memo.UpdatedTs,
|
||||||
&memo.RowStatus,
|
&memo.RowStatus,
|
||||||
&memo.Visibility,
|
&memo.Visibility,
|
||||||
&pinned,
|
&memo.Pinned,
|
||||||
&memo.ParentID,
|
&memo.ParentID,
|
||||||
}
|
}
|
||||||
if !find.ExcludeContent {
|
if !find.ExcludeContent {
|
||||||
@ -126,9 +125,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
|||||||
if err := rows.Scan(dests...); err != nil {
|
if err := rows.Scan(dests...); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if pinned.Valid {
|
|
||||||
memo.Pinned = pinned.Bool
|
|
||||||
}
|
|
||||||
list = append(list, &memo)
|
list = append(list, &memo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,9 +42,9 @@ const Explore = () => {
|
|||||||
}
|
}
|
||||||
setIsRequesting(true);
|
setIsRequesting(true);
|
||||||
const data = await memoStore.fetchMemos({
|
const data = await memoStore.fetchMemos({
|
||||||
|
filter: filters.join(" && "),
|
||||||
limit: DEFAULT_MEMO_LIMIT,
|
limit: DEFAULT_MEMO_LIMIT,
|
||||||
offset: memoList.size(),
|
offset: memoList.size(),
|
||||||
filter: filters.join(" && "),
|
|
||||||
});
|
});
|
||||||
setIsRequesting(false);
|
setIsRequesting(false);
|
||||||
setIsComplete(data.length < DEFAULT_MEMO_LIMIT);
|
setIsComplete(data.length < DEFAULT_MEMO_LIMIT);
|
||||||
|
@ -52,9 +52,9 @@ const Home = () => {
|
|||||||
}
|
}
|
||||||
setIsRequesting(true);
|
setIsRequesting(true);
|
||||||
const data = await memoStore.fetchMemos({
|
const data = await memoStore.fetchMemos({
|
||||||
|
filter: filters.join(" && "),
|
||||||
limit: DEFAULT_MEMO_LIMIT,
|
limit: DEFAULT_MEMO_LIMIT,
|
||||||
offset: memoList.size(),
|
offset: memoList.size(),
|
||||||
filter: filters.join(" && "),
|
|
||||||
});
|
});
|
||||||
setIsRequesting(false);
|
setIsRequesting(false);
|
||||||
setIsComplete(data.length < DEFAULT_MEMO_LIMIT);
|
setIsComplete(data.length < DEFAULT_MEMO_LIMIT);
|
||||||
|
Reference in New Issue
Block a user