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
8b65d248
Commit
8b65d248
authored
Jan 13, 2025
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: memo filter
parent
ee96465b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
19 deletions
+15
-19
HomeSidebar.tsx
web/src/components/HomeSidebar/HomeSidebar.tsx
+1
-1
StatisticsView.tsx
web/src/components/StatisticsView.tsx
+2
-18
Explore.tsx
web/src/pages/Explore.tsx
+12
-0
No files found.
web/src/components/HomeSidebar/HomeSidebar.tsx
View file @
8b65d248
...
...
@@ -17,7 +17,7 @@ const HomeSidebar = (props: Props) => {
useDebounce
(
async
()
=>
{
const
filters
=
[
`state == "NORMAL"`
];
const
filters
=
[
`state == "NORMAL"`
,
`creator == "
${
currentUser
.
name
}
"`
];
await
userStatsStore
.
listUserStats
(
currentUser
.
name
,
filters
.
join
(
" && "
));
},
300
,
...
...
web/src/components/StatisticsView.tsx
View file @
8b65d248
import
{
Divider
,
Tooltip
}
from
"@mui/joy"
;
import
{
Tooltip
}
from
"@mui/joy"
;
import
clsx
from
"clsx"
;
import
dayjs
from
"dayjs"
;
import
{
countBy
}
from
"lodash-es"
;
import
{
CalendarDaysIcon
,
CheckCircleIcon
,
ChevronLeftIcon
,
ChevronRightIcon
,
Code2Icon
,
LinkIcon
,
ListTodoIcon
}
from
"lucide-react"
;
import
{
useState
}
from
"react"
;
import
useAsyncEffect
from
"@/hooks/useAsyncEffect"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
i18n
from
"@/i18n"
;
import
{
useMemoFilterStore
,
useUserStatsStore
}
from
"@/store/v1"
;
import
{
UserStats_MemoTypeStats
}
from
"@/types/proto/api/v1/user_service"
;
...
...
@@ -14,18 +13,12 @@ import ActivityCalendar from "./ActivityCalendar";
const
StatisticsView
=
()
=>
{
const
t
=
useTranslate
();
const
currentUser
=
useCurrentUser
();
const
memoFilterStore
=
useMemoFilterStore
();
const
userStatsStore
=
useUserStatsStore
();
const
[
memoAmount
,
setMemoAmount
]
=
useState
(
0
);
const
[
memoTypeStats
,
setMemoTypeStats
]
=
useState
<
UserStats_MemoTypeStats
>
(
UserStats_MemoTypeStats
.
fromPartial
({}));
const
[
activityStats
,
setActivityStats
]
=
useState
<
Record
<
string
,
number
>>
({});
const
[
selectedDate
]
=
useState
(
new
Date
());
const
[
visibleMonthString
,
setVisibleMonthString
]
=
useState
(
dayjs
(
selectedDate
.
toDateString
()).
format
(
"YYYY-MM"
));
const
days
=
Math
.
ceil
((
Date
.
now
()
-
currentUser
.
createTime
!
.
getTime
())
/
86400000
);
const
singularOrPluralMemo
=
(
memoAmount
>
0
?
t
(
"common.memos"
)
:
t
(
"common.memo"
)).
toLowerCase
();
const
singularOrPluralDay
=
(
days
>
0
?
t
(
"common.days"
)
:
t
(
"common.day"
)).
toLowerCase
();
useAsyncEffect
(
async
()
=>
{
const
memoTypeStats
=
UserStats_MemoTypeStats
.
fromPartial
({});
...
...
@@ -40,7 +33,6 @@ const StatisticsView = () => {
}
}
setMemoTypeStats
(
memoTypeStats
);
setMemoAmount
(
displayTimeList
.
length
);
setActivityStats
(
countBy
(
displayTimeList
.
map
((
date
)
=>
dayjs
(
date
).
format
(
"YYYY-MM-DD"
))));
},
[
userStatsStore
.
stateId
]);
...
...
@@ -80,16 +72,8 @@ const StatisticsView = () => {
data=
{
activityStats
}
onClick=
{
onCalendarClick
}
/>
{
memoAmount
===
0
?
(
<
p
className=
"mt-1 w-full text-xs italic opacity-80"
>
{
t
(
"memo.no-memos"
)
}
</
p
>
)
:
(
<
p
className=
"mt-1 w-full text-xs italic opacity-80"
>
<
span
>
{
memoAmount
}
</
span
>
{
singularOrPluralMemo
}
{
t
(
"common.in"
).
toLowerCase
()
}
<
span
>
{
days
}
</
span
>
{
singularOrPluralDay
}
</
p
>
)
}
</
div
>
<
Divider
className=
"!my-2 opacity-50"
/>
<
div
className=
"w-full flex flex-row justify-start items-center gap-x-2 gap-y-1 flex-wrap"
>
<
div
className=
"pt-1 w-full flex flex-row justify-start items-center gap-x-2 gap-y-1 flex-wrap"
>
<
div
className=
{
clsx
(
"w-auto border dark:border-zinc-800 pl-1 pr-1.5 rounded-md flex justify-between items-center"
)
}
onClick=
{
()
=>
memoFilterStore
.
addFilter
({
factor
:
"property.hasLink"
,
value
:
""
})
}
...
...
web/src/pages/Explore.tsx
View file @
8b65d248
...
...
@@ -26,6 +26,18 @@ const Explore = () => {
contentSearch
.
push
(
`"
${
filter
.
value
}
"`
);
}
else
if
(
filter
.
factor
===
"tagSearch"
)
{
tagSearch
.
push
(
`"
${
filter
.
value
}
"`
);
}
else
if
(
filter
.
factor
===
"property.hasLink"
)
{
filters
.
push
(
`has_link == true`
);
}
else
if
(
filter
.
factor
===
"property.hasTaskList"
)
{
filters
.
push
(
`has_task_list == true`
);
}
else
if
(
filter
.
factor
===
"property.hasCode"
)
{
filters
.
push
(
`has_code == true`
);
}
else
if
(
filter
.
factor
===
"displayTime"
)
{
const
filterDate
=
new
Date
(
filter
.
value
);
const
filterUtcTimestamp
=
filterDate
.
getTime
()
+
filterDate
.
getTimezoneOffset
()
*
60
*
1000
;
const
timestampAfter
=
filterUtcTimestamp
/
1000
;
filters
.
push
(
`display_time_after ==
${
timestampAfter
}
`
);
filters
.
push
(
`display_time_before ==
${
timestampAfter
+
60
*
60
*
24
}
`
);
}
}
if
(
memoFilterStore
.
orderByTimeAsc
)
{
...
...
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