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.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: update find memo api
Steven6f2ca6c87ad2
diff --git a/api/v1/memo.go b/api/v1/memo.goindex 5c402991d..9a0eb1f25 100644--- a/api/v1/memo.go+++ b/api/v1/memo.go@@ -471,8 +471,9 @@ func (s *APIV1Service) GetMemoStats(c echo.Context) error {normalStatus := store.NormalhasParentFlag := falsefindMemoMessage := &store.FindMemo{- RowStatus: &normalStatus,- HasParent: &hasParentFlag,+ RowStatus: &normalStatus,+ HasParent: &hasParentFlag,+ ExcludeContent: true,}if creatorID, err := util.ConvertStringToInt32(c.QueryParam("creatorId")); err == nil {findMemoMessage.CreatorID = &creatorIDdiff --git a/store/db/sqlite/memo.go b/store/db/sqlite/memo.goindex 1e315cbfe..cbf4fa61f 100644--- a/store/db/sqlite/memo.go+++ b/store/db/sqlite/memo.go@@ -104,17 +104,23 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo}orders = append(orders, "id DESC")+ fields := []string{+ `memo.id AS id`,+ `memo.creator_id AS creator_id`,+ `memo.created_ts AS created_ts`,+ `memo.updated_ts AS updated_ts`,+ `memo.row_status AS row_status`,+ `memo.visibility AS visibility`,+ }+ if !find.ExcludeContent {+ fields = append(fields, `memo.content AS content`)+ }+query := `SELECT- memo.id AS id,- memo.creator_id AS creator_id,- memo.created_ts AS created_ts,- memo.updated_ts AS updated_ts,- memo.row_status AS row_status,- memo.content AS content,- memo.visibility AS visibility,- CASE WHEN memo_organizer.pinned = 1 THEN 1 ELSE 0 END AS pinned,- (+ ` + strings.Join(fields, ", ") + `+ CASE WHEN mo.pinned = 1 THEN 1 ELSE 0 END AS pinned,+ (SELECTrelated_memo_idFROM@@ -122,26 +128,25 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.MemoWHEREmemo_relation.memo_id = memo.id AND memo_relation.type = 'COMMENT'LIMIT 1- ) AS parent_id,- GROUP_CONCAT(resource.id) AS resource_id_list,- (+ ) AS parent_id,+ GROUP_CONCAT(resource.id) AS resource_id_list,+ (SELECT- GROUP_CONCAT(memo_id || ':' || related_memo_id || ':' || type)+ GROUP_CONCAT(memo_relation.memo_id || ':' || memo_relation.related_memo_id || ':' || memo_relation.type)FROMmemo_relationWHEREmemo_relation.memo_id = memo.id OR memo_relation.related_memo_id = memo.id- ) AS relation_list- FROM- memo- LEFT JOIN- memo_organizer ON memo.id = memo_organizer.memo_id- LEFT JOIN- resource ON memo.id = resource.memo_id- WHERE ` + strings.Join(where, " AND ") + `- GROUP BY memo.id- ORDER BY ` + strings.Join(orders, ", ") + `- `+ ) AS relation_list+ FROM+ memo+ LEFT JOIN+ memo_organizer mo ON memo.id = mo.memo_id+ LEFT JOIN+ resource ON memo.id = resource.memo_id+ WHERE ` + strings.Join(where, " AND ") + `+ GROUP BY memo.id+ ORDER BY ` + strings.Join(orders, ", ")if find.Limit != nil {query = fmt.Sprintf("%s LIMIT %d", query, *find.Limit)if find.Offset != nil {@@ -160,19 +165,19 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memovar memo store.Memovar memoResourceIDList sql.NullStringvar memoRelationList sql.NullString- if err := rows.Scan(+ dests := []any{&memo.ID,&memo.CreatorID,&memo.CreatedTs,&memo.UpdatedTs,&memo.RowStatus,- &memo.Content,&memo.Visibility,- &memo.Pinned,- &memo.ParentID,- &memoResourceIDList,- &memoRelationList,- ); err != nil {+ }+ if !find.ExcludeContent {+ dests = append(dests, &memo.Content)+ }+ dests = append(dests, &memo.Pinned, &memo.ParentID, &memoResourceIDList, &memoRelationList)+ if err := rows.Scan(dests...); err != nil {return nil, err}diff --git a/store/memo.go b/store/memo.goindex e5afa05bb..35a6031be 100644--- a/store/memo.go+++ b/store/memo.go@@ -64,6 +64,7 @@ type FindMemo struct {VisibilityList []VisibilityPinned *boolHasParent *bool+ ExcludeContent bool// PaginationLimit *intdiff --git a/web/src/pages/MemoDetail.tsx b/web/src/pages/MemoDetail.tsxindex 04f401d09..cd7de15f7 100644--- a/web/src/pages/MemoDetail.tsx+++ b/web/src/pages/MemoDetail.tsx@@ -104,7 +104,7 @@ const MemoDetail = () => {<><section className="relative top-0 w-full min-h-full overflow-x-hidden bg-zinc-100 dark:bg-zinc-900"><div className="relative w-full h-auto mx-auto flex flex-col justify-start items-center bg-white dark:bg-zinc-700">- <div className="w-full flex flex-col justify-start items-center py-8">+ <div className="w-full flex flex-col justify-start items-center pt-16 pb-8"><UserAvatar className="!w-20 h-auto mb-2 drop-shadow" avatarUrl={systemStatus.customizedProfile.logoUrl} /><p className="text-3xl text-black opacity-80 dark:text-gray-200">{systemStatus.customizedProfile.name}</p></div>@@ -186,7 +186,7 @@ const MemoDetail = () => {</div></div></div>- <div className="py-6 w-full border-t dark:border-t-zinc-700">+ <div className="pt-8 pb-16 w-full border-t dark:border-t-zinc-700"><div className="relative mx-auto flex-grow max-w-2xl w-full min-h-full flex flex-col justify-start items-start px-4 gap-y-1">{comments.length === 0 ? (<div className="w-full flex flex-col justify-center items-center py-6 mb-2">