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
005305cd
Commit
005305cd
authored
Mar 22, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update relative time display
parent
8fd1dff4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
MemoView.tsx
web/src/components/MemoView.tsx
+5
-9
UserBanner.tsx
web/src/components/UserBanner.tsx
+8
-1
No files found.
web/src/components/MemoView.tsx
View file @
005305cd
...
@@ -43,6 +43,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
...
@@ -43,6 +43,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
const
commentAmount
=
memo
.
relations
.
filter
(
const
commentAmount
=
memo
.
relations
.
filter
(
(
relation
)
=>
relation
.
type
===
MemoRelation_Type
.
COMMENT
&&
relation
.
relatedMemo
===
memo
.
name
,
(
relation
)
=>
relation
.
type
===
MemoRelation_Type
.
COMMENT
&&
relation
.
relatedMemo
===
memo
.
name
,
).
length
;
).
length
;
const
relativeTimeFormat
=
Date
.
now
()
-
memo
.
displayTime
!
.
getTime
()
>
1000
*
60
*
60
*
24
?
"datetime"
:
"auto"
;
const
readonly
=
memo
.
creator
!==
user
?.
name
;
const
readonly
=
memo
.
creator
!==
user
?.
name
;
const
isInMemoDetailPage
=
location
.
pathname
.
startsWith
(
`/m/
${
memo
.
name
}
`
);
const
isInMemoDetailPage
=
location
.
pathname
.
startsWith
(
`/m/
${
memo
.
name
}
`
);
...
@@ -77,7 +78,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
...
@@ -77,7 +78,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
<
div
<
div
className=
{
classNames
(
className=
{
classNames
(
"group relative flex flex-col justify-start items-start w-full px-4 py-3 mb-2 gap-2 bg-white dark:bg-zinc-800 rounded-lg border border-white dark:border-zinc-800 hover:border-gray-200 dark:hover:border-zinc-700"
,
"group relative flex flex-col justify-start items-start w-full px-4 py-3 mb-2 gap-2 bg-white dark:bg-zinc-800 rounded-lg border border-white dark:border-zinc-800 hover:border-gray-200 dark:hover:border-zinc-700"
,
memo
.
pinned
&&
props
.
showP
inned
&&
"border-gray-200 border dark:border-zinc-700"
,
props
.
showPinned
&&
memo
.
p
inned
&&
"border-gray-200 border dark:border-zinc-700"
,
className
,
className
,
)
}
)
}
ref=
{
memoContainerRef
}
ref=
{
memoContainerRef
}
...
@@ -95,9 +96,9 @@ const MemoView: React.FC<Props> = (props: Props) => {
...
@@ -95,9 +96,9 @@ const MemoView: React.FC<Props> = (props: Props) => {
{
creator
.
nickname
||
creator
.
username
}
{
creator
.
nickname
||
creator
.
username
}
</
span
>
</
span
>
</
Link
>
</
Link
>
<
span
className=
"-mt-1 text-gray-400 text-sm leading-tight max-w-[80%] truncate dark:text-gray-500"
>
<
div
className=
"w-auto -mt-0.5 text-xs leading-none text-gray-400 select-none"
onClick=
{
handleGotoMemoDetailPage
}
>
{
creator
.
description
}
<
relative
-
time
datetime=
{
memo
.
displayTime
?.
toISOString
()
}
format=
{
relativeTimeFormat
}
tense=
"past"
></
relative
-
time
>
</
span
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
)
}
)
}
...
@@ -143,11 +144,6 @@ const MemoView: React.FC<Props> = (props: Props) => {
...
@@ -143,11 +144,6 @@ const MemoView: React.FC<Props> = (props: Props) => {
compact=
{
props
.
compact
??
true
}
compact=
{
props
.
compact
??
true
}
/>
/>
<
MemoResourceListView
resources=
{
memo
.
resources
}
/>
<
MemoResourceListView
resources=
{
memo
.
resources
}
/>
<
div
className=
"w-full flex flex-row justify-between items-center"
>
<
div
className=
"text-sm leading-tight text-gray-400 select-none"
>
<
relative
-
time
datetime=
{
memo
.
displayTime
?.
toISOString
()
}
tense=
"past"
onClick=
{
handleGotoMemoDetailPage
}
></
relative
-
time
>
</
div
>
</
div
>
<
MemoRelationListView
memo=
{
memo
}
relations=
{
referencedMemos
}
/>
<
MemoRelationListView
memo=
{
memo
}
relations=
{
referencedMemos
}
/>
<
MemoReactionistView
memo=
{
memo
}
reactions=
{
memo
.
reactions
}
/>
<
MemoReactionistView
memo=
{
memo
}
reactions=
{
memo
.
reactions
}
/>
</
div
>
</
div
>
...
...
web/src/components/UserBanner.tsx
View file @
005305cd
...
@@ -2,6 +2,8 @@ import { Dropdown, Menu, MenuButton, MenuItem } from "@mui/joy";
...
@@ -2,6 +2,8 @@ import { Dropdown, Menu, MenuButton, MenuItem } from "@mui/joy";
import
classNames
from
"classnames"
;
import
classNames
from
"classnames"
;
import
{
authServiceClient
}
from
"@/grpcweb"
;
import
{
authServiceClient
}
from
"@/grpcweb"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
useNavigateTo
from
"@/hooks/useNavigateTo"
;
import
{
Routes
}
from
"@/router"
;
import
{
useGlobalStore
}
from
"@/store/module"
;
import
{
useGlobalStore
}
from
"@/store/module"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
Icon
from
"./Icon"
;
import
Icon
from
"./Icon"
;
...
@@ -14,6 +16,7 @@ interface Props {
...
@@ -14,6 +16,7 @@ interface Props {
const
UserBanner
=
(
props
:
Props
)
=>
{
const
UserBanner
=
(
props
:
Props
)
=>
{
const
{
collapsed
}
=
props
;
const
{
collapsed
}
=
props
;
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
navigateTo
=
useNavigateTo
();
const
globalStore
=
useGlobalStore
();
const
globalStore
=
useGlobalStore
();
const
{
systemStatus
}
=
globalStore
.
state
;
const
{
systemStatus
}
=
globalStore
.
state
;
const
user
=
useCurrentUser
();
const
user
=
useCurrentUser
();
...
@@ -41,9 +44,13 @@ const UserBanner = (props: Props) => {
...
@@ -41,9 +44,13 @@ const UserBanner = (props: Props) => {
</
MenuButton
>
</
MenuButton
>
<
Menu
placement=
"bottom-start"
style=
{
{
zIndex
:
"9999"
}
}
>
<
Menu
placement=
"bottom-start"
style=
{
{
zIndex
:
"9999"
}
}
>
<
MenuItem
onClick=
{
handleSignOut
}
>
<
MenuItem
onClick=
{
handleSignOut
}
>
<
Icon
.
LogOut
className=
"w-4 h-auto opacity-60
shrink-0
"
/>
<
Icon
.
LogOut
className=
"w-4 h-auto opacity-60"
/>
<
span
className=
"truncate"
>
{
t
(
"common.sign-out"
)
}
</
span
>
<
span
className=
"truncate"
>
{
t
(
"common.sign-out"
)
}
</
span
>
</
MenuItem
>
</
MenuItem
>
<
MenuItem
onClick=
{
()
=>
navigateTo
(
Routes
.
ABOUT
)
}
>
<
Icon
.
Smile
className=
"w-4 h-auto opacity-60"
/>
<
span
className=
"truncate"
>
{
t
(
"common.about"
)
}
</
span
>
</
MenuItem
>
</
Menu
>
</
Menu
>
</
Dropdown
>
</
Dropdown
>
</
div
>
</
div
>
...
...
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