Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
b938c8d7
Commit
b938c8d7
authored
Oct 07, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: only show comments in memo detail page
parent
553de3cc
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
67 additions
and
46 deletions
+67
-46
memo.go
api/v1/memo.go
+10
-2
memo.go
store/db/sqlite/memo.go
+21
-7
memo.go
store/memo.go
+2
-1
Memo.tsx
web/src/components/Memo.tsx
+16
-14
MemoList.tsx
web/src/components/MemoList.tsx
+1
-1
MemoResource.tsx
web/src/components/MemoResource.tsx
+12
-16
Explore.tsx
web/src/pages/Explore.tsx
+1
-1
MemoDetail.tsx
web/src/pages/MemoDetail.tsx
+4
-4
No files found.
api/v1/memo.go
View file @
b938c8d7
...
@@ -144,7 +144,10 @@ func (s *APIV1Service) registerMemoRoutes(g *echo.Group) {
...
@@ -144,7 +144,10 @@ func (s *APIV1Service) registerMemoRoutes(g *echo.Group) {
// @Router /api/v1/memo [GET]
// @Router /api/v1/memo [GET]
func
(
s
*
APIV1Service
)
GetMemoList
(
c
echo
.
Context
)
error
{
func
(
s
*
APIV1Service
)
GetMemoList
(
c
echo
.
Context
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
ctx
:=
c
.
Request
()
.
Context
()
findMemoMessage
:=
&
store
.
FindMemo
{}
hasParentFlag
:=
false
findMemoMessage
:=
&
store
.
FindMemo
{
HasParent
:
&
hasParentFlag
,
}
if
userID
,
err
:=
util
.
ConvertStringToInt32
(
c
.
QueryParam
(
"creatorId"
));
err
==
nil
{
if
userID
,
err
:=
util
.
ConvertStringToInt32
(
c
.
QueryParam
(
"creatorId"
));
err
==
nil
{
findMemoMessage
.
CreatorID
=
&
userID
findMemoMessage
.
CreatorID
=
&
userID
}
}
...
@@ -404,7 +407,10 @@ func (s *APIV1Service) CreateMemo(c echo.Context) error {
...
@@ -404,7 +407,10 @@ func (s *APIV1Service) CreateMemo(c echo.Context) error {
// - creatorUsername is listed at ./web/src/helpers/api.ts:82, but it's not present here
// - creatorUsername is listed at ./web/src/helpers/api.ts:82, but it's not present here
func
(
s
*
APIV1Service
)
GetAllMemos
(
c
echo
.
Context
)
error
{
func
(
s
*
APIV1Service
)
GetAllMemos
(
c
echo
.
Context
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
ctx
:=
c
.
Request
()
.
Context
()
findMemoMessage
:=
&
store
.
FindMemo
{}
hasParentFlag
:=
false
findMemoMessage
:=
&
store
.
FindMemo
{
HasParent
:
&
hasParentFlag
,
}
_
,
ok
:=
c
.
Get
(
userIDContextKey
)
.
(
int32
)
_
,
ok
:=
c
.
Get
(
userIDContextKey
)
.
(
int32
)
if
!
ok
{
if
!
ok
{
findMemoMessage
.
VisibilityList
=
[]
store
.
Visibility
{
store
.
Public
}
findMemoMessage
.
VisibilityList
=
[]
store
.
Visibility
{
store
.
Public
}
...
@@ -461,8 +467,10 @@ func (s *APIV1Service) GetAllMemos(c echo.Context) error {
...
@@ -461,8 +467,10 @@ func (s *APIV1Service) GetAllMemos(c echo.Context) error {
func
(
s
*
APIV1Service
)
GetMemoStats
(
c
echo
.
Context
)
error
{
func
(
s
*
APIV1Service
)
GetMemoStats
(
c
echo
.
Context
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
ctx
:=
c
.
Request
()
.
Context
()
normalStatus
:=
store
.
Normal
normalStatus
:=
store
.
Normal
hasParentFlag
:=
false
findMemoMessage
:=
&
store
.
FindMemo
{
findMemoMessage
:=
&
store
.
FindMemo
{
RowStatus
:
&
normalStatus
,
RowStatus
:
&
normalStatus
,
HasParent
:
&
hasParentFlag
,
}
}
if
creatorID
,
err
:=
util
.
ConvertStringToInt32
(
c
.
QueryParam
(
"creatorId"
));
err
==
nil
{
if
creatorID
,
err
:=
util
.
ConvertStringToInt32
(
c
.
QueryParam
(
"creatorId"
));
err
==
nil
{
findMemoMessage
.
CreatorID
=
&
creatorID
findMemoMessage
.
CreatorID
=
&
creatorID
...
...
store/db/sqlite/memo.go
View file @
b938c8d7
...
@@ -65,9 +65,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -65,9 +65,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if
v
:=
find
.
CreatedTsAfter
;
v
!=
nil
{
if
v
:=
find
.
CreatedTsAfter
;
v
!=
nil
{
where
,
args
=
append
(
where
,
"memo.created_ts > ?"
),
append
(
args
,
*
v
)
where
,
args
=
append
(
where
,
"memo.created_ts > ?"
),
append
(
args
,
*
v
)
}
}
if
v
:=
find
.
Pinned
;
v
!=
nil
{
where
=
append
(
where
,
"memo_organizer.pinned = 1"
)
}
if
v
:=
find
.
ContentSearch
;
len
(
v
)
!=
0
{
if
v
:=
find
.
ContentSearch
;
len
(
v
)
!=
0
{
for
_
,
s
:=
range
v
{
for
_
,
s
:=
range
v
{
where
,
args
=
append
(
where
,
"memo.content LIKE ?"
),
append
(
args
,
"%"
+
s
+
"%"
)
where
,
args
=
append
(
where
,
"memo.content LIKE ?"
),
append
(
args
,
"%"
+
s
+
"%"
)
...
@@ -81,6 +78,17 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -81,6 +78,17 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
}
}
where
=
append
(
where
,
fmt
.
Sprintf
(
"memo.visibility in (%s)"
,
strings
.
Join
(
list
,
","
)))
where
=
append
(
where
,
fmt
.
Sprintf
(
"memo.visibility in (%s)"
,
strings
.
Join
(
list
,
","
)))
}
}
if
v
:=
find
.
Pinned
;
v
!=
nil
{
where
=
append
(
where
,
"memo_organizer.pinned = 1"
)
}
if
v
:=
find
.
HasParent
;
v
!=
nil
{
if
*
v
{
where
=
append
(
where
,
"parent_id IS NOT NULL"
)
}
else
{
where
=
append
(
where
,
"parent_id IS NULL"
)
}
}
orders
:=
[]
string
{
"pinned DESC"
}
orders
:=
[]
string
{
"pinned DESC"
}
if
find
.
OrderByUpdatedTs
{
if
find
.
OrderByUpdatedTs
{
orders
=
append
(
orders
,
"updated_ts DESC"
)
orders
=
append
(
orders
,
"updated_ts DESC"
)
...
@@ -99,6 +107,15 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -99,6 +107,15 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
memo.content AS content,
memo.content AS content,
memo.visibility AS visibility,
memo.visibility AS visibility,
CASE WHEN memo_organizer.pinned = 1 THEN 1 ELSE 0 END AS pinned,
CASE WHEN memo_organizer.pinned = 1 THEN 1 ELSE 0 END AS pinned,
(
SELECT
related_memo_id
FROM
memo_relation
WHERE
memo_relation.memo_id = memo.id AND memo_relation.type = 'COMMENT'
LIMIT 1
) AS parent_id,
GROUP_CONCAT(resource.id) AS resource_id_list,
GROUP_CONCAT(resource.id) AS resource_id_list,
(
(
SELECT
SELECT
...
@@ -145,6 +162,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -145,6 +162,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
&
memo
.
Content
,
&
memo
.
Content
,
&
memo
.
Visibility
,
&
memo
.
Visibility
,
&
memo
.
Pinned
,
&
memo
.
Pinned
,
&
memo
.
ParentID
,
&
memoResourceIDList
,
&
memoResourceIDList
,
&
memoRelationList
,
&
memoRelationList
,
);
err
!=
nil
{
);
err
!=
nil
{
...
@@ -184,10 +202,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -184,10 +202,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
RelatedMemoID
:
relatedMemoID
,
RelatedMemoID
:
relatedMemoID
,
Type
:
relationType
,
Type
:
relationType
,
})
})
// Set the first parent ID if relation type is comment.
if
memo
.
ParentID
==
nil
&&
memoID
==
memo
.
ID
&&
relationType
==
store
.
MemoRelationComment
{
memo
.
ParentID
=
&
relatedMemoID
}
}
}
}
}
list
=
append
(
list
,
&
memo
)
list
=
append
(
list
,
&
memo
)
...
...
store/memo.go
View file @
b938c8d7
...
@@ -60,9 +60,10 @@ type FindMemo struct {
...
@@ -60,9 +60,10 @@ type FindMemo struct {
CreatedTsBefore
*
int64
CreatedTsBefore
*
int64
// Domain specific fields
// Domain specific fields
Pinned
*
bool
ContentSearch
[]
string
ContentSearch
[]
string
VisibilityList
[]
Visibility
VisibilityList
[]
Visibility
Pinned
*
bool
HasParent
*
bool
// Pagination
// Pagination
Limit
*
int
Limit
*
int
...
...
web/src/components/Memo.tsx
View file @
b938c8d7
...
@@ -245,18 +245,26 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -245,18 +245,26 @@ const Memo: React.FC<Props> = (props: Props) => {
</
span
>
</
span
>
<
div
className=
"more-action-btns-wrapper"
>
<
div
className=
"more-action-btns-wrapper"
>
<
div
className=
"more-action-btns-container min-w-[6em]"
>
<
div
className=
"more-action-btns-container min-w-[6em]"
>
<
span
className=
"btn"
onClick=
{
handleTogglePinMemoBtnClick
}
>
{
!
memo
.
parent
&&
(
{
memo
.
pinned
?
<
Icon
.
BookmarkMinus
className=
"w-4 h-auto mr-2"
/>
:
<
Icon
.
BookmarkPlus
className=
"w-4 h-auto mr-2"
/>
}
<
span
className=
"btn"
onClick=
{
handleTogglePinMemoBtnClick
}
>
{
memo
.
pinned
?
t
(
"common.unpin"
)
:
t
(
"common.pin"
)
}
{
memo
.
pinned
?
(
</
span
>
<
Icon
.
BookmarkMinus
className=
"w-4 h-auto mr-2"
/>
)
:
(
<
Icon
.
BookmarkPlus
className=
"w-4 h-auto mr-2"
/>
)
}
{
memo
.
pinned
?
t
(
"common.unpin"
)
:
t
(
"common.pin"
)
}
</
span
>
)
}
<
span
className=
"btn"
onClick=
{
handleEditMemoClick
}
>
<
span
className=
"btn"
onClick=
{
handleEditMemoClick
}
>
<
Icon
.
Edit3
className=
"w-4 h-auto mr-2"
/>
<
Icon
.
Edit3
className=
"w-4 h-auto mr-2"
/>
{
t
(
"common.edit"
)
}
{
t
(
"common.edit"
)
}
</
span
>
</
span
>
<
span
className=
"btn"
onClick=
{
handleMarkMemoClick
}
>
{
!
memo
.
parent
&&
(
<
Icon
.
Link
className=
"w-4 h-auto mr-2"
/>
<
span
className=
"btn"
onClick=
{
handleMarkMemoClick
}
>
{
t
(
"common.mark"
)
}
<
Icon
.
Link
className=
"w-4 h-auto mr-2"
/>
</
span
>
{
t
(
"common.mark"
)
}
</
span
>
)
}
<
Divider
className=
"!my-1"
/>
<
Divider
className=
"!my-1"
/>
<
span
className=
"btn text-orange-500"
onClick=
{
handleArchiveMemoClick
}
>
<
span
className=
"btn text-orange-500"
onClick=
{
handleArchiveMemoClick
}
>
<
Icon
.
Archive
className=
"w-4 h-auto mr-2"
/>
<
Icon
.
Archive
className=
"w-4 h-auto mr-2"
/>
...
@@ -290,12 +298,6 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -290,12 +298,6 @@ const Memo: React.FC<Props> = (props: Props) => {
<
div
className=
"flex flex-row justify-start items-center"
>
<
div
className=
"flex flex-row justify-start items-center"
>
{
creator
&&
(
{
creator
&&
(
<>
<>
<
Link
className=
"flex flex-row justify-start items-center"
to=
{
`/m/${memo.id}`
}
>
<
Tooltip
title=
{
"Identifier"
}
placement=
"top"
>
<
span
className=
"text-sm text-gray-500 dark:text-gray-400"
>
#
{
memo
.
id
}
</
span
>
</
Tooltip
>
</
Link
>
<
Icon
.
Dot
className=
"w-4 h-auto text-gray-400 dark:text-zinc-400"
/>
<
Link
to=
{
`/u/${encodeURIComponent(memo.creatorUsername)}`
}
>
<
Link
to=
{
`/u/${encodeURIComponent(memo.creatorUsername)}`
}
>
<
Tooltip
title=
{
"Creator"
}
placement=
"top"
>
<
Tooltip
title=
{
"Creator"
}
placement=
"top"
>
<
span
className=
"flex flex-row justify-start items-center"
>
<
span
className=
"flex flex-row justify-start items-center"
>
...
...
web/src/components/MemoList.tsx
View file @
b938c8d7
...
@@ -63,7 +63,7 @@ const MemoList: React.FC = () => {
...
@@ -63,7 +63,7 @@ const MemoList: React.FC = () => {
return shouldShow;
return shouldShow;
}
)
}
)
: memos
: memos
).filter((memo) =
>
memo.creatorUsername === username
&&
memo.rowStatus === "NORMAL");
).filter((memo) =
>
memo.creatorUsername === username
&&
memo.rowStatus === "NORMAL"
&&
!memo.parent
);
const pinnedMemos = shownMemos.filter((m) =
>
m.pinned);
const pinnedMemos = shownMemos.filter((m) =
>
m.pinned);
const unpinnedMemos = shownMemos.filter((m) =
>
!m.pinned);
const unpinnedMemos = shownMemos.filter((m) =
>
!m.pinned);
...
...
web/src/components/MemoResource.tsx
View file @
b938c8d7
...
@@ -16,22 +16,18 @@ const MemoResource: React.FC<Props> = (props: Props) => {
...
@@ -16,22 +16,18 @@ const MemoResource: React.FC<Props> = (props: Props) => {
};
};
return
(
return
(
<>
<
div
className=
{
`w-auto flex flex-row justify-start items-center text-gray-500 dark:text-gray-400 hover:opacity-80 ${className}`
}
>
<
div
className=
{
`w-auto flex flex-row justify-start items-center text-gray-500 dark:text-gray-400 hover:opacity-80 ${className}`
}
>
{
resource
.
type
.
startsWith
(
"audio"
)
?
(
{
resource
.
type
.
startsWith
(
"audio"
)
?
(
<
audio
src=
{
resourceUrl
}
controls
></
audio
>
<>
)
:
(
<
audio
src=
{
resourceUrl
}
controls
></
audio
>
<>
</>
<
ResourceIcon
className=
"!w-4 !h-4 mr-1"
resource=
{
resource
}
/>
)
:
(
<
span
className=
"text-sm max-w-[256px] truncate cursor-pointer"
onClick=
{
handlePreviewBtnClick
}
>
<>
{
resource
.
filename
}
<
ResourceIcon
className=
"!w-4 !h-4 mr-1"
resource=
{
resource
}
/>
</
span
>
<
span
className=
"text-sm max-w-[256px] truncate cursor-pointer"
onClick=
{
handlePreviewBtnClick
}
>
</>
{
resource
.
filename
}
)
}
</
span
>
</
div
>
</>
)
}
</
div
>
</>
);
);
};
};
...
...
web/src/pages/Explore.tsx
View file @
b938c8d7
...
@@ -54,7 +54,7 @@ const Explore = () => {
...
@@ -54,7 +54,7 @@ const Explore = () => {
:
memos
;
:
memos
;
const
sortedMemos
=
fetchedMemos
const
sortedMemos
=
fetchedMemos
.
filter
((
m
)
=>
m
.
rowStatus
===
"NORMAL"
&&
m
.
visibility
!==
"PRIVATE"
)
.
filter
((
m
)
=>
m
.
rowStatus
===
"NORMAL"
&&
m
.
visibility
!==
"PRIVATE"
&&
!
m
.
parent
)
.
sort
((
mi
,
mj
)
=>
mj
.
displayTs
-
mi
.
displayTs
);
.
sort
((
mi
,
mj
)
=>
mj
.
displayTs
-
mi
.
displayTs
);
useEffect
(()
=>
{
useEffect
(()
=>
{
...
...
web/src/pages/MemoDetail.tsx
View file @
b938c8d7
...
@@ -114,6 +114,10 @@ const MemoDetail = () => {
...
@@ -114,6 +114,10 @@ const MemoDetail = () => {
<
div
className=
"relative flex-grow max-w-2xl w-full min-h-full flex flex-col justify-start items-start px-4 pb-6"
>
<
div
className=
"relative flex-grow max-w-2xl w-full min-h-full flex flex-col justify-start items-start px-4 pb-6"
>
<
div
className=
"w-full mb-4 flex flex-row justify-start items-center mr-1"
>
<
div
className=
"w-full mb-4 flex flex-row justify-start items-center mr-1"
>
<
span
className=
"text-gray-400 select-none"
>
{
getDateTimeString
(
memo
.
displayTs
)
}
</
span
>
<
span
className=
"text-gray-400 select-none"
>
{
getDateTimeString
(
memo
.
displayTs
)
}
</
span
>
<
Icon
.
Dot
className=
"w-4 h-auto text-gray-400 dark:text-zinc-400"
/>
<
Tooltip
title=
{
"Identifier"
}
placement=
"top"
>
<
span
className=
"text-gray-400 dark:text-gray-400"
>
#
{
memo
.
id
}
</
span
>
</
Tooltip
>
</
div
>
</
div
>
{
memo
.
parent
&&
(
{
memo
.
parent
&&
(
<
div
className=
"mb-2"
>
<
div
className=
"mb-2"
>
...
@@ -127,10 +131,6 @@ const MemoDetail = () => {
...
@@ -127,10 +131,6 @@ const MemoDetail = () => {
<
MemoRelationListView
relationList=
{
referenceRelations
}
/>
<
MemoRelationListView
relationList=
{
referenceRelations
}
/>
<
div
className=
"w-full mt-4 flex flex-col sm:flex-row justify-start sm:justify-between sm:items-center gap-2"
>
<
div
className=
"w-full mt-4 flex flex-col sm:flex-row justify-start sm:justify-between sm:items-center gap-2"
>
<
div
className=
"flex flex-row justify-start items-center"
>
<
div
className=
"flex flex-row justify-start items-center"
>
<
Tooltip
title=
{
"Identifier"
}
placement=
"top"
>
<
span
className=
"text-sm text-gray-500 dark:text-gray-400"
>
#
{
memo
.
id
}
</
span
>
</
Tooltip
>
<
Icon
.
Dot
className=
"w-4 h-auto text-gray-400 dark:text-zinc-400"
/>
<
Link
to=
{
`/u/${encodeURIComponent(memo.creatorUsername)}`
}
>
<
Link
to=
{
`/u/${encodeURIComponent(memo.creatorUsername)}`
}
>
<
Tooltip
title=
{
"Creator"
}
placement=
"top"
>
<
Tooltip
title=
{
"Creator"
}
placement=
"top"
>
<
span
className=
"flex flex-row justify-start items-center"
>
<
span
className=
"flex flex-row justify-start items-center"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment