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
5bdf7654
Commit
5bdf7654
authored
Aug 27, 2022
by
steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update detail styles
parent
62657f7f
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
75 additions
and
33 deletions
+75
-33
App.tsx
web/src/App.tsx
+8
-1
Memo.tsx
web/src/components/Memo.tsx
+12
-6
MemoList.tsx
web/src/components/MemoList.tsx
+19
-10
MemosHeader.tsx
web/src/components/MemosHeader.tsx
+1
-1
PreferencesSection.tsx
web/src/components/Settings/PreferencesSection.tsx
+7
-6
auth.less
web/src/less/auth.less
+1
-1
beta-badge.less
web/src/less/beta-badge.less
+1
-1
selector.less
web/src/less/common/selector.less
+1
-1
memo-list.less
web/src/less/memo-list.less
+2
-2
setting-dialog.less
web/src/less/setting-dialog.less
+2
-2
en.json
web/src/locales/en.json
+3
-0
zh.json
web/src/locales/zh.json
+3
-0
memoService.ts
web/src/services/memoService.ts
+6
-1
memo.ts
web/src/store/modules/memo.ts
+9
-1
No files found.
web/src/App.tsx
View file @
5bdf7654
...
@@ -7,6 +7,7 @@ import * as storage from "./helpers/storage";
...
@@ -7,6 +7,7 @@ import * as storage from "./helpers/storage";
function
App
()
{
function
App
()
{
const
{
setLocale
}
=
useI18n
();
const
{
setLocale
}
=
useI18n
();
const
user
=
useAppSelector
((
state
)
=>
state
.
user
.
user
);
const
global
=
useAppSelector
((
state
)
=>
state
.
global
);
const
global
=
useAppSelector
((
state
)
=>
state
.
global
);
const
pathname
=
useAppSelector
((
state
)
=>
state
.
location
.
pathname
);
const
pathname
=
useAppSelector
((
state
)
=>
state
.
location
.
pathname
);
const
[
isLoading
,
setLoading
]
=
useState
(
true
);
const
[
isLoading
,
setLoading
]
=
useState
(
true
);
...
@@ -21,12 +22,18 @@ function App() {
...
@@ -21,12 +22,18 @@ function App() {
});
});
},
[]);
},
[]);
useEffect
(()
=>
{
if
(
user
?.
setting
.
locale
)
{
globalService
.
setLocale
(
user
.
setting
.
locale
);
}
},
[
user
?.
setting
.
locale
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
setLocale
(
global
.
locale
);
setLocale
(
global
.
locale
);
storage
.
set
({
storage
.
set
({
locale
:
global
.
locale
,
locale
:
global
.
locale
,
});
});
},
[
global
]);
},
[
global
.
locale
]);
return
<>
{
isLoading
?
null
:
appRouterSwitch
(
pathname
)
}
</>;
return
<>
{
isLoading
?
null
:
appRouterSwitch
(
pathname
)
}
</>;
}
}
...
...
web/src/components/Memo.tsx
View file @
5bdf7654
...
@@ -45,15 +45,16 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -45,15 +45,16 @@ const Memo: React.FC<Props> = (props: Props) => {
});
});
const
[
createdAtStr
,
setCreatedAtStr
]
=
useState
<
string
>
(
getFormatedMemoCreatedAtStr
(
memo
.
createdTs
,
locale
));
const
[
createdAtStr
,
setCreatedAtStr
]
=
useState
<
string
>
(
getFormatedMemoCreatedAtStr
(
memo
.
createdTs
,
locale
));
const
memoContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
memoContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
memoContentContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
imageUrls
=
Array
.
from
(
memo
.
content
.
match
(
IMAGE_URL_REG
)
??
[]).
map
((
s
)
=>
s
.
replace
(
IMAGE_URL_REG
,
"$1"
));
const
imageUrls
=
Array
.
from
(
memo
.
content
.
match
(
IMAGE_URL_REG
)
??
[]).
map
((
s
)
=>
s
.
replace
(
IMAGE_URL_REG
,
"$1"
));
const
isVisitorMode
=
userService
.
isVisitorMode
();
const
isVisitorMode
=
userService
.
isVisitorMode
();
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
memoContainerRef
)
{
if
(
!
memoCont
entCont
ainerRef
)
{
return
;
return
;
}
}
if
(
Number
(
memoContainerRef
.
current
?.
clientHeight
)
>
MAX_MEMO_CONTAINER_HEIGHT
)
{
if
(
Number
(
memoCont
entCont
ainerRef
.
current
?.
clientHeight
)
>
MAX_MEMO_CONTAINER_HEIGHT
)
{
setState
({
setState
({
...
state
,
...
state
,
expandButtonStatus
:
0
,
expandButtonStatus
:
0
,
...
@@ -143,7 +144,7 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -143,7 +144,7 @@ const Memo: React.FC<Props> = (props: Props) => {
}
}
const
status
=
targetEl
.
dataset
?.
value
;
const
status
=
targetEl
.
dataset
?.
value
;
const
todoElementList
=
[...(
memoContainerRef
.
current
?.
querySelectorAll
(
`span.todo-block[data-value=
${
status
}
]`
)
??
[])];
const
todoElementList
=
[...(
memoCont
entCont
ainerRef
.
current
?.
querySelectorAll
(
`span.todo-block[data-value=
${
status
}
]`
)
??
[])];
for
(
const
element
of
todoElementList
)
{
for
(
const
element
of
todoElementList
)
{
if
(
element
===
targetEl
)
{
if
(
element
===
targetEl
)
{
const
index
=
indexOf
(
todoElementList
,
element
);
const
index
=
indexOf
(
todoElementList
,
element
);
...
@@ -172,13 +173,18 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -172,13 +173,18 @@ const Memo: React.FC<Props> = (props: Props) => {
};
};
const
handleExpandBtnClick
=
()
=>
{
const
handleExpandBtnClick
=
()
=>
{
const
expandButtonStatus
=
Boolean
(
!
state
.
expandButtonStatus
);
if
(
!
expandButtonStatus
)
{
memoContainerRef
.
current
?.
scrollIntoView
();
}
setState
({
setState
({
expandButtonStatus
:
Number
(
Boolean
(
!
state
.
expandButtonStatus
)
)
as
ExpandButtonStatus
,
expandButtonStatus
:
Number
(
expandButtonStatus
)
as
ExpandButtonStatus
,
});
});
};
};
return
(
return
(
<
div
className=
{
`memo-wrapper ${"memos-" + memo.id} ${memo.pinned ? "pinned" : ""}`
}
>
<
div
className=
{
`memo-wrapper ${"memos-" + memo.id} ${memo.pinned ? "pinned" : ""}`
}
ref=
{
memoContainerRef
}
>
<
div
className=
"memo-top-wrapper"
>
<
div
className=
"memo-top-wrapper"
>
<
div
className=
"status-text-container"
onClick=
{
handleShowMemoStoryDialog
}
>
<
div
className=
"status-text-container"
onClick=
{
handleShowMemoStoryDialog
}
>
<
span
className=
"time-text"
>
{
createdAtStr
}
</
span
>
<
span
className=
"time-text"
>
{
createdAtStr
}
</
span
>
...
@@ -220,7 +226,7 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -220,7 +226,7 @@ const Memo: React.FC<Props> = (props: Props) => {
</
div
>
</
div
>
</
div
>
</
div
>
<
div
<
div
ref=
{
memoContainerRef
}
ref=
{
memoCont
entCont
ainerRef
}
className=
{
`memo-content-text ${state.expandButtonStatus === 0 ? "expanded" : ""}`
}
className=
{
`memo-content-text ${state.expandButtonStatus === 0 ? "expanded" : ""}`
}
onClick=
{
handleMemoContentClick
}
onClick=
{
handleMemoContentClick
}
dangerouslySetInnerHTML=
{
{
__html
:
formatMemoContent
(
memo
.
content
)
}
}
dangerouslySetInnerHTML=
{
{
__html
:
formatMemoContent
(
memo
.
content
)
}
}
...
...
web/src/components/MemoList.tsx
View file @
5bdf7654
import
{
useEffect
,
useRef
,
useState
}
from
"react"
;
import
{
useEffect
,
useRef
}
from
"react"
;
import
{
memoService
,
shortcutService
}
from
"../services"
;
import
{
memoService
,
shortcutService
}
from
"../services"
;
import
useI18n
from
"../hooks/useI18n"
;
import
{
useAppSelector
}
from
"../store"
;
import
{
useAppSelector
}
from
"../store"
;
import
{
IMAGE_URL_REG
,
LINK_URL_REG
,
MEMO_LINK_REG
,
TAG_REG
}
from
"../helpers/consts"
;
import
{
IMAGE_URL_REG
,
LINK_URL_REG
,
MEMO_LINK_REG
,
TAG_REG
}
from
"../helpers/consts"
;
import
*
as
utils
from
"../helpers/utils"
;
import
*
as
utils
from
"../helpers/utils"
;
import
{
checkShouldShowMemoWithFilters
}
from
"../helpers/filter"
;
import
{
checkShouldShowMemoWithFilters
}
from
"../helpers/filter"
;
import
toastHelper
from
"./Toast"
;
import
toastHelper
from
"./Toast"
;
import
Only
from
"./common/OnlyWhen"
;
import
Memo
from
"./Memo"
;
import
Memo
from
"./Memo"
;
import
"../less/memo-list.less"
;
import
"../less/memo-list.less"
;
interface
Props
{}
interface
Props
{}
const
MemoList
:
React
.
FC
<
Props
>
=
()
=>
{
const
MemoList
:
React
.
FC
<
Props
>
=
()
=>
{
const
{
t
}
=
useI18n
();
const
query
=
useAppSelector
((
state
)
=>
state
.
location
.
query
);
const
query
=
useAppSelector
((
state
)
=>
state
.
location
.
query
);
const
memos
=
useAppSelector
((
state
)
=>
state
.
memo
.
memos
);
const
{
memos
,
isFetching
}
=
useAppSelector
((
state
)
=>
state
.
memo
);
const
[
isFetching
,
setFetchStatus
]
=
useState
(
true
);
const
wrapperElement
=
useRef
<
HTMLDivElement
>
(
null
);
const
wrapperElement
=
useRef
<
HTMLDivElement
>
(
null
);
const
{
tag
:
tagQuery
,
duration
,
type
:
memoType
,
text
:
textQuery
,
shortcutId
}
=
query
??
{};
const
{
tag
:
tagQuery
,
duration
,
type
:
memoType
,
text
:
textQuery
,
shortcutId
}
=
query
??
{};
...
@@ -82,7 +84,7 @@ const MemoList: React.FC<Props> = () => {
...
@@ -82,7 +84,7 @@ const MemoList: React.FC<Props> = () => {
memoService
memoService
.
fetchAllMemos
()
.
fetchAllMemos
()
.
then
(()
=>
{
.
then
(()
=>
{
setFetchStatus
(
false
);
// do nth
})
})
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
console
.
error
(
error
);
console
.
error
(
error
);
...
@@ -91,19 +93,26 @@ const MemoList: React.FC<Props> = () => {
...
@@ -91,19 +93,26 @@ const MemoList: React.FC<Props> = () => {
}
, []);
}
, []);
useEffect(() =
>
{
useEffect(() =
>
{
wrapperElement
.
current
?.
scrollTo
({
top
:
0
});
wrapperElement
.
current
?.
scrollTo
({
top
:
0
,
});
}
, [query]);
}
, [query]);
return (
return (
<
div
className=
{
`memo-list-container ${isFetching ? "" : "completed"}`
}
ref=
{
wrapperElement
}
>
<
div
className=
{
`memo-list-container ${isFetching ? "" : "completed"}`
}
ref=
{
wrapperElement
}
>
<
Only
when=
{
isFetching
}
>
<
div
className=
"status-text-container fetching-tip"
>
<
p
className=
"status-text"
>
{
t
(
"memo-list.fetching-data"
)
}
</
p
>
</
div
>
</
Only
>
{
sortedMemos
.
map
((
memo
)
=>
(
{
sortedMemos
.
map
((
memo
)
=>
(
<
Memo
key=
{
`${memo.id}-${memo.createdTs}-${memo.updatedTs}`
}
memo=
{
memo
}
/>
<
Memo
key=
{
`${memo.id}-${memo.createdTs}-${memo.updatedTs}`
}
memo=
{
memo
}
/>
))
}
))
}
<
div
className=
"status-text-container"
>
<
Only
when=
{
!
isFetching
}
>
<
p
className=
"status-text
"
>
<
div
className=
"status-text-container
"
>
{
isFetching
?
"Fetching data..."
:
sortedMemos
.
length
===
0
?
"No memos 🌃"
:
showMemoFilter
?
""
:
"All memos are ready 🎉"
}
<
p
className=
"status-text"
>
{
sortedMemos
.
length
===
0
?
"no memos 🌃"
:
showMemoFilter
?
""
:
"all memos are ready 🎉"
}
</
p
>
</
p
>
</
div
>
</
div
>
</
Only
>
</
div
>
</
div
>
);
);
};
};
...
...
web/src/components/MemosHeader.tsx
View file @
5bdf7654
...
@@ -29,7 +29,7 @@ const MemosHeader: React.FC<Props> = () => {
...
@@ -29,7 +29,7 @@ const MemosHeader: React.FC<Props> = () => {
const
handleTitleTextClick
=
useCallback
(()
=>
{
const
handleTitleTextClick
=
useCallback
(()
=>
{
const
now
=
Date
.
now
();
const
now
=
Date
.
now
();
if
(
now
-
prevRequestTimestamp
>
1
0
*
1000
)
{
if
(
now
-
prevRequestTimestamp
>
1
*
1000
)
{
prevRequestTimestamp
=
now
;
prevRequestTimestamp
=
now
;
memoService
.
fetchAllMemos
().
catch
(()
=>
{
memoService
.
fetchAllMemos
().
catch
(()
=>
{
// do nth
// do nth
...
...
web/src/components/Settings/PreferencesSection.tsx
View file @
5bdf7654
...
@@ -35,8 +35,8 @@ const PreferencesSection: React.FC<Props> = () => {
...
@@ -35,8 +35,8 @@ const PreferencesSection: React.FC<Props> = () => {
const
{
setting
}
=
useAppSelector
((
state
)
=>
state
.
user
.
user
as
User
);
const
{
setting
}
=
useAppSelector
((
state
)
=>
state
.
user
.
user
as
User
);
const
handleLocaleChanged
=
async
(
value
:
string
)
=>
{
const
handleLocaleChanged
=
async
(
value
:
string
)
=>
{
globalService
.
setLocale
(
value
as
Locale
);
await
userService
.
upsertUserSetting
(
"locale"
,
value
);
await
userService
.
upsertUserSetting
(
"locale"
,
value
);
globalService
.
setLocale
(
value
as
Locale
);
};
};
const
handleDefaultMemoVisibilityChanged
=
async
(
value
:
string
)
=>
{
const
handleDefaultMemoVisibilityChanged
=
async
(
value
:
string
)
=>
{
...
@@ -49,16 +49,17 @@ const PreferencesSection: React.FC<Props> = () => {
...
@@ -49,16 +49,17 @@ const PreferencesSection: React.FC<Props> = () => {
return
(
return
(
<
div
className=
"section-container preferences-section-container"
>
<
div
className=
"section-container preferences-section-container"
>
<
p
className=
"title-text"
>
{
t
(
"common.
language
"
)
}
</
p
>
<
p
className=
"title-text"
>
{
t
(
"common.
basic
"
)
}
</
p
>
<
label
className=
"form-label selector"
>
<
label
className=
"form-label selector"
>
<
span
className=
"normal-text"
>
<
span
className=
"normal-text"
>
{
t
(
"common.language"
)
}
:
<
BetaBadge
className=
"ml-2"
/>
{
t
(
"common.language"
)
}
<
BetaBadge
className=
"ml-2"
/>
</
span
>
</
span
>
<
Selector
className=
"ml-2 w-
28
"
value=
{
setting
.
locale
}
dataSource=
{
localeSelectorItems
}
handleValueChanged=
{
handleLocaleChanged
}
/>
<
Selector
className=
"ml-2 w-
32
"
value=
{
setting
.
locale
}
dataSource=
{
localeSelectorItems
}
handleValueChanged=
{
handleLocaleChanged
}
/>
</
label
>
</
label
>
<
p
className=
"title-text"
>
{
t
(
"setting.preference"
)
}
</
p
>
<
p
className=
"title-text"
>
{
t
(
"setting.preference"
)
}
</
p
>
<
label
className=
"form-label selector"
>
<
label
className=
"form-label selector"
>
<
span
className=
"normal-text"
>
{
t
(
"setting.preference-section.default-memo-visibility"
)
}
:
</
span
>
<
span
className=
"normal-text"
>
{
t
(
"setting.preference-section.default-memo-visibility"
)
}
</
span
>
<
Selector
<
Selector
className=
"ml-2 w-32"
className=
"ml-2 w-32"
value=
{
setting
.
memoVisibility
}
value=
{
setting
.
memoVisibility
}
...
@@ -67,7 +68,7 @@ const PreferencesSection: React.FC<Props> = () => {
...
@@ -67,7 +68,7 @@ const PreferencesSection: React.FC<Props> = () => {
/>
/>
</
label
>
</
label
>
<
label
className=
"form-label selector"
>
<
label
className=
"form-label selector"
>
<
span
className=
"normal-text"
>
{
t
(
"setting.preference-section.editor-font-style"
)
}
:
</
span
>
<
span
className=
"normal-text"
>
{
t
(
"setting.preference-section.editor-font-style"
)
}
</
span
>
<
Selector
<
Selector
className=
"ml-2 w-32"
className=
"ml-2 w-32"
value=
{
setting
.
editorFontStyle
}
value=
{
setting
.
editorFontStyle
}
...
...
web/src/less/auth.less
View file @
5bdf7654
...
@@ -77,7 +77,7 @@
...
@@ -77,7 +77,7 @@
@apply w-full inline-block float-right text-sm mt-4 text-gray-500 text-right whitespace-pre-wrap;
@apply w-full inline-block float-right text-sm mt-4 text-gray-500 text-right whitespace-pre-wrap;
&.host-tip {
&.host-tip {
@apply
bg-blue-500 text-white px-2 py-1 rounded
;
@apply
text-blue-600
;
}
}
}
}
}
}
...
...
web/src/less/beta-badge.less
View file @
5bdf7654
.beta-badge {
.beta-badge {
@apply px-2
text-xs border rounded-lg text-gray-4
00;
@apply px-2
py-1 text-xs border rounded-full text-gray-5
00;
}
}
web/src/less/common/selector.less
View file @
5bdf7654
@import "../mixin.less";
@import "../mixin.less";
.selector-wrapper {
.selector-wrapper {
@apply flex flex-col justify-start items-start relative h-
7
;
@apply flex flex-col justify-start items-start relative h-
8
;
> .current-value-container {
> .current-value-container {
@apply flex flex-row justify-between items-center w-full h-full rounded px-2 pr-1 bg-white border cursor-pointer select-none;
@apply flex flex-row justify-between items-center w-full h-full rounded px-2 pr-1 bg-white border cursor-pointer select-none;
...
...
web/src/less/memo-list.less
View file @
5bdf7654
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
> .status-text-container {
> .status-text-container {
@apply flex flex-col justify-start items-center w-full my-6;
@apply flex flex-col justify-start items-center w-full my-6;
&.
completed
{
&.
fetching-tip
{
@apply m
b-16
;
@apply m
t-2 mb-1
;
}
}
> .status-text {
> .status-text {
...
...
web/src/less/setting-dialog.less
View file @
5bdf7654
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
@apply w-full sm:w-44 h-auto sm:h-full shrink-0 rounded-t-lg sm:rounded-none sm:rounded-l-lg p-4 border-r bg-gray-100 flex flex-col justify-start items-start;
@apply w-full sm:w-44 h-auto sm:h-full shrink-0 rounded-t-lg sm:rounded-none sm:rounded-l-lg p-4 border-r bg-gray-100 flex flex-col justify-start items-start;
> .section-title {
> .section-title {
@apply text-sm mt-2 sm:mt-4 first:mt-
3
mb-1 font-mono text-gray-400;
@apply text-sm mt-2 sm:mt-4 first:mt-
4
mb-1 font-mono text-gray-400;
}
}
> .section-items-container {
> .section-items-container {
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
@apply flex flex-col justify-start items-start w-full my-2;
@apply flex flex-col justify-start items-start w-full my-2;
> .title-text {
> .title-text {
@apply text-sm mb-3 font-mono text-gray-500;
@apply text-sm m
t-4 first:mt-2 m
b-3 font-mono text-gray-500;
}
}
> .form-label {
> .form-label {
...
...
web/src/locales/en.json
View file @
5bdf7654
...
@@ -46,6 +46,9 @@
...
@@ -46,6 +46,9 @@
"memo"
:
{
"memo"
:
{
"view-story"
:
"View Story"
"view-story"
:
"View Story"
},
},
"memo-list"
:
{
"fetching-data"
:
"fetching data..."
},
"tag-list"
:
{
"tag-list"
:
{
"tip-text"
:
"Enter `#tag ` to create"
"tip-text"
:
"Enter `#tag ` to create"
},
},
...
...
web/src/locales/zh.json
View file @
5bdf7654
...
@@ -46,6 +46,9 @@
...
@@ -46,6 +46,9 @@
"memo"
:
{
"memo"
:
{
"view-story"
:
"查看详情"
"view-story"
:
"查看详情"
},
},
"memo-list"
:
{
"fetching-data"
:
"请求数据中..."
},
"tag-list"
:
{
"tag-list"
:
{
"tip-text"
:
"输入`#tag `来创建标签"
"tip-text"
:
"输入`#tag `来创建标签"
},
},
...
...
web/src/services/memoService.ts
View file @
5bdf7654
import
*
as
api
from
"../helpers/api"
;
import
*
as
api
from
"../helpers/api"
;
import
{
createMemo
,
patchMemo
,
setMemos
,
setTags
}
from
"../store/modules/memo"
;
import
{
createMemo
,
patchMemo
,
set
IsFetching
,
set
Memos
,
setTags
}
from
"../store/modules/memo"
;
import
store
from
"../store"
;
import
store
from
"../store"
;
import
userService
from
"./userService"
;
import
userService
from
"./userService"
;
...
@@ -17,6 +17,9 @@ const memoService = {
...
@@ -17,6 +17,9 @@ const memoService = {
},
},
fetchAllMemos
:
async
()
=>
{
fetchAllMemos
:
async
()
=>
{
const
timeoutIndex
=
setTimeout
(()
=>
{
store
.
dispatch
(
setIsFetching
(
true
));
},
1000
);
const
memoFind
:
MemoFind
=
{};
const
memoFind
:
MemoFind
=
{};
if
(
userService
.
isVisitorMode
())
{
if
(
userService
.
isVisitorMode
())
{
memoFind
.
creatorId
=
userService
.
getUserIdFromPath
();
memoFind
.
creatorId
=
userService
.
getUserIdFromPath
();
...
@@ -24,6 +27,8 @@ const memoService = {
...
@@ -24,6 +27,8 @@ const memoService = {
const
{
data
}
=
(
await
api
.
getMemoList
(
memoFind
)).
data
;
const
{
data
}
=
(
await
api
.
getMemoList
(
memoFind
)).
data
;
const
memos
=
data
.
filter
((
m
)
=>
m
.
rowStatus
!==
"ARCHIVED"
).
map
((
m
)
=>
convertResponseModelMemo
(
m
));
const
memos
=
data
.
filter
((
m
)
=>
m
.
rowStatus
!==
"ARCHIVED"
).
map
((
m
)
=>
convertResponseModelMemo
(
m
));
store
.
dispatch
(
setMemos
(
memos
));
store
.
dispatch
(
setMemos
(
memos
));
clearTimeout
(
timeoutIndex
);
store
.
dispatch
(
setIsFetching
(
false
));
return
memos
;
return
memos
;
},
},
...
...
web/src/store/modules/memo.ts
View file @
5bdf7654
...
@@ -3,6 +3,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
...
@@ -3,6 +3,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
interface
State
{
interface
State
{
memos
:
Memo
[];
memos
:
Memo
[];
tags
:
string
[];
tags
:
string
[];
isFetching
:
boolean
;
}
}
const
memoSlice
=
createSlice
({
const
memoSlice
=
createSlice
({
...
@@ -10,6 +11,7 @@ const memoSlice = createSlice({
...
@@ -10,6 +11,7 @@ const memoSlice = createSlice({
initialState
:
{
initialState
:
{
memos
:
[],
memos
:
[],
tags
:
[],
tags
:
[],
isFetching
:
false
,
}
as
State
,
}
as
State
,
reducers
:
{
reducers
:
{
setMemos
:
(
state
,
action
:
PayloadAction
<
Memo
[]
>
)
=>
{
setMemos
:
(
state
,
action
:
PayloadAction
<
Memo
[]
>
)
=>
{
...
@@ -47,9 +49,15 @@ const memoSlice = createSlice({
...
@@ -47,9 +49,15 @@ const memoSlice = createSlice({
tags
:
action
.
payload
,
tags
:
action
.
payload
,
};
};
},
},
setIsFetching
:
(
state
,
action
:
PayloadAction
<
boolean
>
)
=>
{
return
{
...
state
,
isFetching
:
action
.
payload
,
};
},
},
},
});
});
export
const
{
setMemos
,
setTags
,
createMemo
,
patchMemo
}
=
memoSlice
.
actions
;
export
const
{
setMemos
,
createMemo
,
patchMemo
,
setTags
,
setIsFetching
}
=
memoSlice
.
actions
;
export
default
memoSlice
.
reducer
;
export
default
memoSlice
.
reducer
;
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