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
67dc9a3f
Unverified
Commit
67dc9a3f
authored
Oct 19, 2024
by
d0zingcat
Committed by
GitHub
Oct 19, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: allow quick unpin (#4031)
Signed-off-by:
d0zingcat
<
leewtang@gmail.com
>
parent
19098940
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
MemoView.tsx
web/src/components/MemoView.tsx
+22
-3
No files found.
web/src/components/MemoView.tsx
View file @
67dc9a3f
...
...
@@ -5,7 +5,7 @@ import { memo, useCallback, useEffect, useRef, useState } from "react";
import
{
Link
,
useLocation
}
from
"react-router-dom"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
useNavigateTo
from
"@/hooks/useNavigateTo"
;
import
{
useUserStore
,
useWorkspaceSettingStore
}
from
"@/store/v1"
;
import
{
useUserStore
,
useWorkspaceSettingStore
,
useMemoStore
}
from
"@/store/v1"
;
import
{
MemoRelation_Type
}
from
"@/types/proto/api/v1/memo_relation_service"
;
import
{
Memo
,
Visibility
}
from
"@/types/proto/api/v1/memo_service"
;
import
{
WorkspaceMemoRelatedSetting
}
from
"@/types/proto/api/v1/workspace_setting_service"
;
...
...
@@ -57,6 +57,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
const
relativeTimeFormat
=
Date
.
now
()
-
memo
.
displayTime
!
.
getTime
()
>
1000
*
60
*
60
*
24
?
"datetime"
:
"auto"
;
const
readonly
=
memo
.
creator
!==
user
?.
name
&&
!
isSuperUser
(
user
);
const
isInMemoDetailPage
=
location
.
pathname
.
startsWith
(
`/m/
${
memo
.
uid
}
`
);
const
memoStore
=
useMemoStore
();
// Initial related data: creator.
useEffect
(()
=>
{
...
...
@@ -92,6 +93,22 @@ const MemoView: React.FC<Props> = (props: Props) => {
}
},
[]);
const
handlePinnedBookmarkClick
=
async
()
=>
{
try
{
if
(
memo
.
pinned
)
{
await
memoStore
.
updateMemo
(
{
name
:
memo
.
name
,
pinned
:
false
,
},
[
"pinned"
],
);
}
}
catch
(
error
)
{
// do nth
}
};
const
displayTime
=
props
.
displayTimeFormat
===
"time"
?
(
memo
.
displayTime
?.
toLocaleTimeString
()
...
...
@@ -176,8 +193,10 @@ const MemoView: React.FC<Props> = (props: Props) => {
</
Link
>
)
}
{
props
.
showPinned
&&
memo
.
pinned
&&
(
<
Tooltip
title=
{
t
(
"common.pinned"
)
}
placement=
"top"
>
<
BookmarkIcon
className=
"w-4 h-auto text-amber-500"
/>
<
Tooltip
title=
{
t
(
"common.unpin"
)
}
placement=
"top"
>
<
span
className=
"cursor-pointer"
>
<
BookmarkIcon
className=
"w-4 h-auto text-amber-500"
onClick=
{
handlePinnedBookmarkClick
}
/>
</
span
>
</
Tooltip
>
)
}
{
!
readonly
&&
(
...
...
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