pull/5091/merge
djh 3 days ago committed by GitHub
commit 96f5538f9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -301,6 +301,9 @@ message ListMemosRequest {
// Optional. If true, show deleted memos in the response. // Optional. If true, show deleted memos in the response.
bool show_deleted = 6 [(google.api.field_behavior) = OPTIONAL]; bool show_deleted = 6 [(google.api.field_behavior) = OPTIONAL];
// Optional. If true, include comment memos in the response.
bool show_comments = 7 [(google.api.field_behavior) = OPTIONAL];
} }
message ListMemosResponse { message ListMemosResponse {

@ -572,6 +572,8 @@ type ListMemosRequest struct {
Filter string `protobuf:"bytes,5,opt,name=filter,proto3" json:"filter,omitempty"` Filter string `protobuf:"bytes,5,opt,name=filter,proto3" json:"filter,omitempty"`
// Optional. If true, show deleted memos in the response. // Optional. If true, show deleted memos in the response.
ShowDeleted bool `protobuf:"varint,6,opt,name=show_deleted,json=showDeleted,proto3" json:"show_deleted,omitempty"` ShowDeleted bool `protobuf:"varint,6,opt,name=show_deleted,json=showDeleted,proto3" json:"show_deleted,omitempty"`
// Optional. If true, include comment memos in the response.
ShowComments bool `protobuf:"varint,7,opt,name=show_comments,json=showComments,proto3" json:"show_comments,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@ -648,6 +650,13 @@ func (x *ListMemosRequest) GetShowDeleted() bool {
return false return false
} }
func (x *ListMemosRequest) GetShowComments() bool {
if x != nil {
return x.ShowComments
}
return false
}
type ListMemosResponse struct { type ListMemosResponse struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// The list of memos. // The list of memos.
@ -2053,7 +2062,7 @@ const file_api_v1_memo_service_proto_rawDesc = "" +
"\amemo_id\x18\x02 \x01(\tB\x03\xe0A\x01R\x06memoId\x12(\n" + "\amemo_id\x18\x02 \x01(\tB\x03\xe0A\x01R\x06memoId\x12(\n" +
"\rvalidate_only\x18\x03 \x01(\bB\x03\xe0A\x01R\fvalidateOnly\x12\"\n" + "\rvalidate_only\x18\x03 \x01(\bB\x03\xe0A\x01R\fvalidateOnly\x12\"\n" +
"\n" + "\n" +
"request_id\x18\x04 \x01(\tB\x03\xe0A\x01R\trequestId\"\xed\x01\n" + "request_id\x18\x04 \x01(\tB\x03\xe0A\x01R\trequestId\"\x97\x02\n" +
"\x10ListMemosRequest\x12 \n" + "\x10ListMemosRequest\x12 \n" +
"\tpage_size\x18\x01 \x01(\x05B\x03\xe0A\x01R\bpageSize\x12\"\n" + "\tpage_size\x18\x01 \x01(\x05B\x03\xe0A\x01R\bpageSize\x12\"\n" +
"\n" + "\n" +
@ -2061,7 +2070,8 @@ const file_api_v1_memo_service_proto_rawDesc = "" +
"\x05state\x18\x03 \x01(\x0e2\x13.memos.api.v1.StateB\x03\xe0A\x01R\x05state\x12\x1e\n" + "\x05state\x18\x03 \x01(\x0e2\x13.memos.api.v1.StateB\x03\xe0A\x01R\x05state\x12\x1e\n" +
"\border_by\x18\x04 \x01(\tB\x03\xe0A\x01R\aorderBy\x12\x1b\n" + "\border_by\x18\x04 \x01(\tB\x03\xe0A\x01R\aorderBy\x12\x1b\n" +
"\x06filter\x18\x05 \x01(\tB\x03\xe0A\x01R\x06filter\x12&\n" + "\x06filter\x18\x05 \x01(\tB\x03\xe0A\x01R\x06filter\x12&\n" +
"\fshow_deleted\x18\x06 \x01(\bB\x03\xe0A\x01R\vshowDeleted\"\x84\x01\n" + "\fshow_deleted\x18\x06 \x01(\bB\x03\xe0A\x01R\vshowDeleted\x12(\n" +
"\rshow_comments\x18\a \x01(\bB\x03\xe0A\x01R\fshowComments\"\x84\x01\n" +
"\x11ListMemosResponse\x12(\n" + "\x11ListMemosResponse\x12(\n" +
"\x05memos\x18\x01 \x03(\v2\x12.memos.api.v1.MemoR\x05memos\x12&\n" + "\x05memos\x18\x01 \x03(\v2\x12.memos.api.v1.MemoR\x05memos\x12&\n" +
"\x0fnext_page_token\x18\x02 \x01(\tR\rnextPageToken\x12\x1d\n" + "\x0fnext_page_token\x18\x02 \x01(\tR\rnextPageToken\x12\x1d\n" +

@ -672,6 +672,11 @@ paths:
description: Optional. If true, show deleted memos in the response. description: Optional. If true, show deleted memos in the response.
schema: schema:
type: boolean type: boolean
- name: showComments
in: query
description: Optional. If true, include comment memos in the response.
schema:
type: boolean
responses: responses:
"200": "200":
description: OK description: OK

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
set -e set -e

@ -108,8 +108,7 @@ func (s *APIV1Service) CreateMemo(ctx context.Context, request *v1pb.CreateMemoR
func (s *APIV1Service) ListMemos(ctx context.Context, request *v1pb.ListMemosRequest) (*v1pb.ListMemosResponse, error) { func (s *APIV1Service) ListMemos(ctx context.Context, request *v1pb.ListMemosRequest) (*v1pb.ListMemosResponse, error) {
memoFind := &store.FindMemo{ memoFind := &store.FindMemo{
// Exclude comments by default. ExcludeComments: !request.ShowComments,
ExcludeComments: true,
} }
if request.State == v1pb.State_ARCHIVED { if request.State == v1pb.State_ARCHIVED {
state := store.Archived state := store.Archived
@ -705,7 +704,7 @@ func (s *APIV1Service) RenameMemoTag(ctx context.Context, request *v1pb.RenameMe
memoFind := &store.FindMemo{ memoFind := &store.FindMemo{
CreatorID: &user.ID, CreatorID: &user.ID,
Filters: []string{fmt.Sprintf("tag in [\"%s\"]", request.OldTag)}, Filters: []string{fmt.Sprintf("tag in [\"%s\"]", request.OldTag)},
ExcludeComments: true, ExcludeComments: false,
} }
if (request.Parent) != "memos/-" { if (request.Parent) != "memos/-" {
memoUID, err := ExtractMemoUIDFromName(request.Parent) memoUID, err := ExtractMemoUIDFromName(request.Parent)
@ -759,7 +758,7 @@ func (s *APIV1Service) DeleteMemoTag(ctx context.Context, request *v1pb.DeleteMe
CreatorID: &user.ID, CreatorID: &user.ID,
Filters: []string{fmt.Sprintf("tag in [\"%s\"]", request.Tag)}, Filters: []string{fmt.Sprintf("tag in [\"%s\"]", request.Tag)},
ExcludeContent: true, ExcludeContent: true,
ExcludeComments: true, ExcludeComments: false,
} }
if request.Parent != "memos/-" { if request.Parent != "memos/-" {
memoUID, err := ExtractMemoUIDFromName(request.Parent) memoUID, err := ExtractMemoUIDFromName(request.Parent)

@ -22,8 +22,7 @@ func (s *APIV1Service) ListAllUserStats(ctx context.Context, _ *v1pb.ListAllUser
normalStatus := store.Normal normalStatus := store.Normal
memoFind := &store.FindMemo{ memoFind := &store.FindMemo{
// Exclude comments by default. ExcludeComments: false,
ExcludeComments: true,
ExcludeContent: true, ExcludeContent: true,
RowStatus: &normalStatus, RowStatus: &normalStatus,
} }
@ -84,8 +83,7 @@ func (s *APIV1Service) GetUserStats(ctx context.Context, request *v1pb.GetUserSt
normalStatus := store.Normal normalStatus := store.Normal
memoFind := &store.FindMemo{ memoFind := &store.FindMemo{
CreatorID: &userID, CreatorID: &userID,
// Exclude comments by default. ExcludeComments: false,
ExcludeComments: true,
ExcludeContent: true, ExcludeContent: true,
RowStatus: &normalStatus, RowStatus: &normalStatus,
} }

@ -1,5 +1,6 @@
import { Settings2Icon } from "lucide-react"; import { Settings2Icon } from "lucide-react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { Checkbox } from "@/components/ui/checkbox";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { viewStore } from "@/store"; import { viewStore } from "@/store";
@ -59,6 +60,18 @@ const MemoDisplaySettingMenu = observer(({ className }: Props) => {
</SelectContent> </SelectContent>
</Select> </Select>
</div> </div>
<div className="w-full flex flex-row justify-between items-center">
<span className="text-sm shrink-0 mr-3 text-foreground">{t("common.show-comments")}</span>
<Checkbox
id="show-comments"
checked={viewStore.state.showComments}
onCheckedChange={(value) =>
viewStore.state.setPartial({
showComments: Boolean(value),
})
}
/>
</div>
</div> </div>
</PopoverContent> </PopoverContent>
</Popover> </Popover>

@ -20,6 +20,7 @@ interface Props {
listSort?: (list: Memo[]) => Memo[]; listSort?: (list: Memo[]) => Memo[];
state?: State; state?: State;
orderBy?: string; orderBy?: string;
showComments?: boolean;
filter?: string; filter?: string;
pageSize?: number; pageSize?: number;
} }
@ -49,6 +50,7 @@ const PagedMemoList = observer((props: Props) => {
const response = await memoStore.fetchMemos({ const response = await memoStore.fetchMemos({
state: props.state || State.NORMAL, state: props.state || State.NORMAL,
orderBy: props.orderBy || "display_time desc", orderBy: props.orderBy || "display_time desc",
showComments: props.showComments,
filter: props.filter, filter: props.filter,
pageSize: props.pageSize || DEFAULT_LIST_MEMOS_PAGE_SIZE, pageSize: props.pageSize || DEFAULT_LIST_MEMOS_PAGE_SIZE,
pageToken, pageToken,
@ -99,7 +101,7 @@ const PagedMemoList = observer((props: Props) => {
// Initial load and reload when props change // Initial load and reload when props change
useEffect(() => { useEffect(() => {
refreshList(); refreshList();
}, [props.state, props.orderBy, props.filter, props.pageSize]); }, [props.state, props.orderBy, props.filter, props.pageSize, props.showComments]);
// Auto-fetch more content when list changes and page isn't full // Auto-fetch more content when list changes and page isn't full
useEffect(() => { useEffect(() => {

@ -52,6 +52,7 @@
"language": "Language", "language": "Language",
"last-updated-at": "Last updated at", "last-updated-at": "Last updated at",
"layout": "Layout", "layout": "Layout",
"show-comments": "Show comments",
"learn-more": "Learn more", "learn-more": "Learn more",
"link": "Link", "link": "Link",
"mark": "Mark", "mark": "Mark",

@ -39,6 +39,8 @@ const Archived = observer(() => {
} }
state={State.ARCHIVED} state={State.ARCHIVED}
orderBy={viewStore.state.orderByTimeAsc ? "display_time asc" : "display_time desc"} orderBy={viewStore.state.orderByTimeAsc ? "display_time asc" : "display_time desc"}
// It does not support show comments now
// showComments={viewStore.state.showComments}
filter={memoFitler} filter={memoFitler}
/> />
); );

@ -27,6 +27,7 @@ const Explore = observer(() => {
) )
} }
orderBy={viewStore.state.orderByTimeAsc ? "display_time asc" : "display_time desc"} orderBy={viewStore.state.orderByTimeAsc ? "display_time asc" : "display_time desc"}
showComments={viewStore.state.showComments}
/> />
</div> </div>
</section> </section>

@ -67,6 +67,7 @@ const Home = observer(() => {
) )
} }
orderBy={viewStore.state.orderByTimeAsc ? "display_time asc" : "display_time desc"} orderBy={viewStore.state.orderByTimeAsc ? "display_time asc" : "display_time desc"}
showComments={viewStore.state.showComments}
filter={memoFilter} filter={memoFilter}
/> />
</div> </div>

@ -102,6 +102,7 @@ const UserProfile = observer(() => {
) )
} }
orderBy={viewStore.state.orderByTimeAsc ? "display_time asc" : "display_time desc"} orderBy={viewStore.state.orderByTimeAsc ? "display_time asc" : "display_time desc"}
showComments={viewStore.state.showComments}
filter={memoFilter} filter={memoFilter}
/> />
</> </>

@ -5,6 +5,7 @@ const LOCAL_STORAGE_KEY = "memos-view-setting";
class LocalState { class LocalState {
orderByTimeAsc: boolean = false; orderByTimeAsc: boolean = false;
layout: "LIST" | "MASONRY" = "LIST"; layout: "LIST" | "MASONRY" = "LIST";
showComments: boolean = false;
constructor() { constructor() {
makeAutoObservable(this); makeAutoObservable(this);
@ -41,6 +42,9 @@ const viewStore = (() => {
viewStore.state.setPartial({ layout: cache.layout }); viewStore.state.setPartial({ layout: cache.layout });
} }
} }
if (Object.hasOwn(cache, "showComments")) {
viewStore.state.setPartial({ showComments: Boolean(cache.showComments) });
}
} catch { } catch {
// Do nothing // Do nothing
} }

@ -206,6 +206,8 @@ export interface ListMemosRequest {
filter: string; filter: string;
/** Optional. If true, show deleted memos in the response. */ /** Optional. If true, show deleted memos in the response. */
showDeleted: boolean; showDeleted: boolean;
/** Optional. If true, include comment memos in the response. */
showComments: boolean;
} }
export interface ListMemosResponse { export interface ListMemosResponse {
@ -1084,7 +1086,15 @@ export const CreateMemoRequest: MessageFns<CreateMemoRequest> = {
}; };
function createBaseListMemosRequest(): ListMemosRequest { function createBaseListMemosRequest(): ListMemosRequest {
return { pageSize: 0, pageToken: "", state: State.STATE_UNSPECIFIED, orderBy: "", filter: "", showDeleted: false }; return {
pageSize: 0,
pageToken: "",
state: State.STATE_UNSPECIFIED,
orderBy: "",
filter: "",
showDeleted: false,
showComments: false,
};
} }
export const ListMemosRequest: MessageFns<ListMemosRequest> = { export const ListMemosRequest: MessageFns<ListMemosRequest> = {
@ -1107,6 +1117,9 @@ export const ListMemosRequest: MessageFns<ListMemosRequest> = {
if (message.showDeleted !== false) { if (message.showDeleted !== false) {
writer.uint32(48).bool(message.showDeleted); writer.uint32(48).bool(message.showDeleted);
} }
if (message.showComments !== false) {
writer.uint32(56).bool(message.showComments);
}
return writer; return writer;
}, },
@ -1165,6 +1178,14 @@ export const ListMemosRequest: MessageFns<ListMemosRequest> = {
message.showDeleted = reader.bool(); message.showDeleted = reader.bool();
continue; continue;
} }
case 7: {
if (tag !== 56) {
break;
}
message.showComments = reader.bool();
continue;
}
} }
if ((tag & 7) === 4 || tag === 0) { if ((tag & 7) === 4 || tag === 0) {
break; break;
@ -1185,6 +1206,7 @@ export const ListMemosRequest: MessageFns<ListMemosRequest> = {
message.orderBy = object.orderBy ?? ""; message.orderBy = object.orderBy ?? "";
message.filter = object.filter ?? ""; message.filter = object.filter ?? "";
message.showDeleted = object.showDeleted ?? false; message.showDeleted = object.showDeleted ?? false;
message.showComments = object.showComments ?? false;
return message; return message;
}, },
}; };

Loading…
Cancel
Save