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
c3cb3770
Commit
c3cb3770
authored
Oct 19, 2024
by
johnnyjoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: tweak function names
parent
c2e82040
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
14 deletions
+18
-14
MemoView.tsx
web/src/components/MemoView.tsx
+13
-14
SignIn.tsx
web/src/pages/SignIn.tsx
+5
-0
No files found.
web/src/components/MemoView.tsx
View file @
c3cb3770
import
{
Tooltip
}
from
"@mui/joy"
;
import
{
Tooltip
}
from
"@mui/joy"
;
import
clsx
from
"clsx"
;
import
clsx
from
"clsx"
;
import
{
BookmarkIcon
,
MessageCircleMoreIcon
}
from
"lucide-react"
;
import
{
BookmarkIcon
,
MessageCircleMoreIcon
}
from
"lucide-react"
;
import
{
memo
,
useCallback
,
use
Effect
,
use
Ref
,
useState
}
from
"react"
;
import
{
memo
,
useCallback
,
useRef
,
useState
}
from
"react"
;
import
{
Link
,
useLocation
}
from
"react-router-dom"
;
import
{
Link
,
useLocation
}
from
"react-router-dom"
;
import
useAsyncEffect
from
"@/hooks/useAsyncEffect"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
useNavigateTo
from
"@/hooks/useNavigateTo"
;
import
useNavigateTo
from
"@/hooks/useNavigateTo"
;
import
{
useUserStore
,
useWorkspaceSettingStore
,
useMemoStore
}
from
"@/store/v1"
;
import
{
useUserStore
,
useWorkspaceSettingStore
,
useMemoStore
}
from
"@/store/v1"
;
...
@@ -43,13 +44,14 @@ const MemoView: React.FC<Props> = (props: Props) => {
...
@@ -43,13 +44,14 @@ const MemoView: React.FC<Props> = (props: Props) => {
const
currentUser
=
useCurrentUser
();
const
currentUser
=
useCurrentUser
();
const
userStore
=
useUserStore
();
const
userStore
=
useUserStore
();
const
user
=
useCurrentUser
();
const
user
=
useCurrentUser
();
const
memoStore
=
useMemoStore
();
const
workspaceSettingStore
=
useWorkspaceSettingStore
();
const
workspaceSettingStore
=
useWorkspaceSettingStore
();
const
workspaceMemoRelatedSetting
=
workspaceSettingStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
MEMO_RELATED
).
memoRelatedSetting
||
WorkspaceMemoRelatedSetting
.
fromPartial
({});
const
[
showEditor
,
setShowEditor
]
=
useState
<
boolean
>
(
false
);
const
[
showEditor
,
setShowEditor
]
=
useState
<
boolean
>
(
false
);
const
[
creator
,
setCreator
]
=
useState
(
userStore
.
getUserByName
(
memo
.
creator
));
const
[
creator
,
setCreator
]
=
useState
(
userStore
.
getUserByName
(
memo
.
creator
));
const
memoContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
memoContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
workspaceMemoRelatedSetting
=
workspaceSettingStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
MEMO_RELATED
).
memoRelatedSetting
||
WorkspaceMemoRelatedSetting
.
fromPartial
({});
const
referencedMemos
=
memo
.
relations
.
filter
((
relation
)
=>
relation
.
type
===
MemoRelation_Type
.
REFERENCE
);
const
referencedMemos
=
memo
.
relations
.
filter
((
relation
)
=>
relation
.
type
===
MemoRelation_Type
.
REFERENCE
);
const
commentAmount
=
memo
.
relations
.
filter
(
const
commentAmount
=
memo
.
relations
.
filter
(
(
relation
)
=>
relation
.
type
===
MemoRelation_Type
.
COMMENT
&&
relation
.
relatedMemo
?.
name
===
memo
.
name
,
(
relation
)
=>
relation
.
type
===
MemoRelation_Type
.
COMMENT
&&
relation
.
relatedMemo
?.
name
===
memo
.
name
,
...
@@ -57,19 +59,16 @@ const MemoView: React.FC<Props> = (props: Props) => {
...
@@ -57,19 +59,16 @@ const MemoView: React.FC<Props> = (props: Props) => {
const
relativeTimeFormat
=
Date
.
now
()
-
memo
.
displayTime
!
.
getTime
()
>
1000
*
60
*
60
*
24
?
"datetime"
:
"auto"
;
const
relativeTimeFormat
=
Date
.
now
()
-
memo
.
displayTime
!
.
getTime
()
>
1000
*
60
*
60
*
24
?
"datetime"
:
"auto"
;
const
readonly
=
memo
.
creator
!==
user
?.
name
&&
!
isSuperUser
(
user
);
const
readonly
=
memo
.
creator
!==
user
?.
name
&&
!
isSuperUser
(
user
);
const
isInMemoDetailPage
=
location
.
pathname
.
startsWith
(
`/m/
${
memo
.
uid
}
`
);
const
isInMemoDetailPage
=
location
.
pathname
.
startsWith
(
`/m/
${
memo
.
uid
}
`
);
const
memoStore
=
useMemoStore
();
// Initial related data: creator.
// Initial related data: creator.
useEffect
(()
=>
{
useAsyncEffect
(
async
()
=>
{
(
async
()
=>
{
const
user
=
await
userStore
.
getOrFetchUserByName
(
memo
.
creator
);
const
user
=
await
userStore
.
getOrFetchUserByName
(
memo
.
creator
);
setCreator
(
user
);
setCreator
(
user
);
})();
},
[]);
},
[]);
const
handleGotoMemoDetailPage
=
()
=>
{
const
handleGotoMemoDetailPage
=
useCallback
(
()
=>
{
navigateTo
(
`/m/
${
memo
.
uid
}
`
);
navigateTo
(
`/m/
${
memo
.
uid
}
`
);
};
}
,
[
memo
.
uid
])
;
const
handleMemoContentClick
=
useCallback
(
async
(
e
:
React
.
MouseEvent
)
=>
{
const
handleMemoContentClick
=
useCallback
(
async
(
e
:
React
.
MouseEvent
)
=>
{
const
targetEl
=
e
.
target
as
HTMLElement
;
const
targetEl
=
e
.
target
as
HTMLElement
;
...
@@ -93,7 +92,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
...
@@ -93,7 +92,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
}
}
},
[]);
},
[]);
const
handlePinnedBookmark
Click
=
async
()
=>
{
const
onPinIcon
Click
=
async
()
=>
{
try
{
try
{
if
(
memo
.
pinned
)
{
if
(
memo
.
pinned
)
{
await
memoStore
.
updateMemo
(
await
memoStore
.
updateMemo
(
...
@@ -195,7 +194,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
...
@@ -195,7 +194,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
{
props
.
showPinned
&&
memo
.
pinned
&&
(
{
props
.
showPinned
&&
memo
.
pinned
&&
(
<
Tooltip
title=
{
t
(
"common.unpin"
)
}
placement=
"top"
>
<
Tooltip
title=
{
t
(
"common.unpin"
)
}
placement=
"top"
>
<
span
className=
"cursor-pointer"
>
<
span
className=
"cursor-pointer"
>
<
BookmarkIcon
className=
"w-4 h-auto text-amber-500"
onClick=
{
handlePinnedBookmark
Click
}
/>
<
BookmarkIcon
className=
"w-4 h-auto text-amber-500"
onClick=
{
onPinIcon
Click
}
/>
</
span
>
</
span
>
</
Tooltip
>
</
Tooltip
>
)
}
)
}
...
...
web/src/pages/SignIn.tsx
View file @
c3cb3770
...
@@ -25,10 +25,15 @@ const SignIn = () => {
...
@@ -25,10 +25,15 @@ const SignIn = () => {
const
workspaceGeneralSetting
=
const
workspaceGeneralSetting
=
workspaceSettingStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
GENERAL
).
generalSetting
||
WorkspaceGeneralSetting
.
fromPartial
({});
workspaceSettingStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
GENERAL
).
generalSetting
||
WorkspaceGeneralSetting
.
fromPartial
({});
// Redirect to root page if already signed in.
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
currentUser
)
{
if
(
currentUser
)
{
window
.
location
.
href
=
Routes
.
ROOT
;
window
.
location
.
href
=
Routes
.
ROOT
;
}
}
},
[]);
// Prepare identity provider list.
useEffect
(()
=>
{
const
fetchIdentityProviderList
=
async
()
=>
{
const
fetchIdentityProviderList
=
async
()
=>
{
const
{
identityProviders
}
=
await
identityProviderServiceClient
.
listIdentityProviders
({});
const
{
identityProviders
}
=
await
identityProviderServiceClient
.
listIdentityProviders
({});
setIdentityProviderList
(
identityProviders
);
setIdentityProviderList
(
identityProviders
);
...
...
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