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
a580df5c
Commit
a580df5c
authored
May 22, 2022
by
boojack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update redux store and service
parent
c3c2882d
Changes
27
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
196 additions
and
304 deletions
+196
-304
ChangePasswordDialog.tsx
web/src/components/ChangePasswordDialog.tsx
+3
-1
ConfirmResetOpenIdDialog.tsx
web/src/components/ConfirmResetOpenIdDialog.tsx
+3
-1
CreateShortcutDialog.tsx
web/src/components/CreateShortcutDialog.tsx
+9
-2
DeletedMemo.tsx
web/src/components/DeletedMemo.tsx
+4
-1
Memo.tsx
web/src/components/Memo.tsx
+7
-12
MemoCardDialog.tsx
web/src/components/MemoCardDialog.tsx
+1
-1
MemoEditor.tsx
web/src/components/MemoEditor.tsx
+10
-8
MemoFilter.tsx
web/src/components/MemoFilter.tsx
+2
-2
MemoTrashDialog.tsx
web/src/components/MemoTrashDialog.tsx
+1
-3
MenuBtnsPopup.tsx
web/src/components/MenuBtnsPopup.tsx
+3
-1
MyAccountSection.tsx
web/src/components/Settings/MyAccountSection.tsx
+3
-2
PreferencesSection.tsx
web/src/components/Settings/PreferencesSection.tsx
+5
-1
ShortcutList.tsx
web/src/components/ShortcutList.tsx
+5
-13
UsageHeatMap.tsx
web/src/components/UsageHeatMap.tsx
+1
-1
api.ts
web/src/helpers/api.ts
+5
-51
search-bar.less
web/src/less/search-bar.less
+1
-1
editorStateService.ts
web/src/services/editorStateService.ts
+10
-2
locationService.ts
web/src/services/locationService.ts
+24
-34
memoService.ts
web/src/services/memoService.ts
+28
-68
shortcutService.ts
web/src/services/shortcutService.ts
+10
-35
userService.ts
web/src/services/userService.ts
+8
-23
editor.ts
web/src/store/modules/editor.ts
+8
-2
location.ts
web/src/store/modules/location.ts
+30
-7
memo.ts
web/src/store/modules/memo.ts
+1
-4
user.ts
web/src/store/modules/user.ts
+2
-8
location.d.ts
web/src/types/location.d.ts
+0
-20
shortcut.d.ts
web/src/types/modules/shortcut.d.ts
+12
-0
No files found.
web/src/components/ChangePasswordDialog.tsx
View file @
a580df5c
...
@@ -55,7 +55,9 @@ const ChangePasswordDialog: React.FC<Props> = ({ destroy }: Props) => {
...
@@ -55,7 +55,9 @@ const ChangePasswordDialog: React.FC<Props> = ({ destroy }: Props) => {
}
}
try
{
try
{
await
userService
.
updatePassword
(
newPassword
);
await
userService
.
patchUser
({
password
:
newPassword
,
});
toastHelper
.
info
(
"Password changed."
);
toastHelper
.
info
(
"Password changed."
);
handleCloseBtnClick
();
handleCloseBtnClick
();
}
catch
(
error
:
any
)
{
}
catch
(
error
:
any
)
{
...
...
web/src/components/ConfirmResetOpenIdDialog.tsx
View file @
a580df5c
...
@@ -25,7 +25,9 @@ const ConfirmResetOpenIdDialog: React.FC<Props> = ({ destroy }: Props) => {
...
@@ -25,7 +25,9 @@ const ConfirmResetOpenIdDialog: React.FC<Props> = ({ destroy }: Props) => {
resetBtnClickLoadingState
.
setLoading
();
resetBtnClickLoadingState
.
setLoading
();
try
{
try
{
await
userService
.
resetOpenId
();
await
userService
.
patchUser
({
resetOpenId
:
true
,
});
}
catch
(
error
)
{
}
catch
(
error
)
{
toastHelper
.
error
(
"Request reset open API failed."
);
toastHelper
.
error
(
"Request reset open API failed."
);
return
;
return
;
...
...
web/src/components/CreateShortcutDialog.tsx
View file @
a580df5c
...
@@ -48,9 +48,16 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
...
@@ -48,9 +48,16 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
try
{
try
{
if
(
shortcutId
)
{
if
(
shortcutId
)
{
await
shortcutService
.
updateShortcut
(
shortcutId
,
title
,
JSON
.
stringify
(
filters
));
await
shortcutService
.
patchShortcut
({
id
:
shortcutId
,
title
,
payload
:
JSON
.
stringify
(
filters
),
});
}
else
{
}
else
{
await
shortcutService
.
createShortcut
(
title
,
JSON
.
stringify
(
filters
));
await
shortcutService
.
createShortcut
({
title
,
payload
:
JSON
.
stringify
(
filters
),
});
}
}
}
catch
(
error
:
any
)
{
}
catch
(
error
:
any
)
{
toastHelper
.
error
(
error
.
message
);
toastHelper
.
error
(
error
.
message
);
...
...
web/src/components/DeletedMemo.tsx
View file @
a580df5c
...
@@ -38,7 +38,10 @@ const DeletedMemo: React.FC<Props> = (props: Props) => {
...
@@ -38,7 +38,10 @@ const DeletedMemo: React.FC<Props> = (props: Props) => {
const
handleRestoreMemoClick
=
async
()
=>
{
const
handleRestoreMemoClick
=
async
()
=>
{
try
{
try
{
await
memoService
.
restoreMemoById
(
memo
.
id
);
await
memoService
.
patchMemo
({
id
:
memo
.
id
,
rowStatus
:
"NORMAL"
,
});
handleDeletedMemoAction
(
memo
.
id
);
handleDeletedMemoAction
(
memo
.
id
);
toastHelper
.
info
(
"Restored successfully"
);
toastHelper
.
info
(
"Restored successfully"
);
}
catch
(
error
:
any
)
{
}
catch
(
error
:
any
)
{
...
...
web/src/components/Memo.tsx
View file @
a580df5c
...
@@ -33,16 +33,8 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -33,16 +33,8 @@ const Memo: React.FC<Props> = (props: Props) => {
try
{
try
{
if
(
memo
.
pinned
)
{
if
(
memo
.
pinned
)
{
await
memoService
.
unpinMemo
(
memo
.
id
);
await
memoService
.
unpinMemo
(
memo
.
id
);
memoService
.
editMemo
({
...
memo
,
pinned
:
false
,
});
}
else
{
}
else
{
await
memoService
.
pinMemo
(
memo
.
id
);
await
memoService
.
pinMemo
(
memo
.
id
);
memoService
.
editMemo
({
...
memo
,
pinned
:
true
,
});
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
// do nth
// do nth
...
@@ -50,23 +42,26 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -50,23 +42,26 @@ const Memo: React.FC<Props> = (props: Props) => {
};
};
const
handleMarkMemoClick
=
()
=>
{
const
handleMarkMemoClick
=
()
=>
{
editorStateService
.
setMarkMemo
(
memo
.
id
);
editorStateService
.
setMarkMemo
WithId
(
memo
.
id
);
};
};
const
handleEditMemoClick
=
()
=>
{
const
handleEditMemoClick
=
()
=>
{
editorStateService
.
setEditMemo
(
memo
.
id
);
editorStateService
.
setEditMemo
WithId
(
memo
.
id
);
};
};
const
handleDeleteMemoClick
=
async
()
=>
{
const
handleDeleteMemoClick
=
async
()
=>
{
if
(
showConfirmDeleteBtn
)
{
if
(
showConfirmDeleteBtn
)
{
try
{
try
{
await
memoService
.
archiveMemoById
(
memo
.
id
);
await
memoService
.
patchMemo
({
id
:
memo
.
id
,
rowStatus
:
"ARCHIVED"
,
});
}
catch
(
error
:
any
)
{
}
catch
(
error
:
any
)
{
toastHelper
.
error
(
error
.
message
);
toastHelper
.
error
(
error
.
message
);
}
}
if
(
editorStateService
.
getState
().
editMemoId
===
memo
.
id
)
{
if
(
editorStateService
.
getState
().
editMemoId
===
memo
.
id
)
{
editorStateService
.
setEditMemo
(
UNKNOWN_ID
);
editorStateService
.
clearEditMemo
(
);
}
}
}
else
{
}
else
{
toggleConfirmDeleteBtn
();
toggleConfirmDeleteBtn
();
...
...
web/src/components/MemoCardDialog.tsx
View file @
a580df5c
...
@@ -96,7 +96,7 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
...
@@ -96,7 +96,7 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
const
handleEditMemoBtnClick
=
useCallback
(()
=>
{
const
handleEditMemoBtnClick
=
useCallback
(()
=>
{
props
.
destroy
();
props
.
destroy
();
editorStateService
.
setEditMemo
(
memo
.
id
);
editorStateService
.
setEditMemo
WithId
(
memo
.
id
);
},
[
memo
.
id
]);
},
[
memo
.
id
]);
return
(
return
(
...
...
web/src/components/MemoEditor.tsx
View file @
a580df5c
...
@@ -57,7 +57,7 @@ const MemoEditor: React.FC<Props> = () => {
...
@@ -57,7 +57,7 @@ const MemoEditor: React.FC<Props> = () => {
const
editorCurrentValue
=
editorRef
.
current
?.
getContent
();
const
editorCurrentValue
=
editorRef
.
current
?.
getContent
();
const
memoLinkText
=
`
${
editorCurrentValue
?
"
\n
"
:
""
}
Mark: [@MEMO](
${
editorState
.
markMemoId
}
)`
;
const
memoLinkText
=
`
${
editorCurrentValue
?
"
\n
"
:
""
}
Mark: [@MEMO](
${
editorState
.
markMemoId
}
)`
;
editorRef
.
current
?.
insertText
(
memoLinkText
);
editorRef
.
current
?.
insertText
(
memoLinkText
);
editorStateService
.
setMarkMemo
(
UNKNOWN_ID
);
editorStateService
.
clearMarkMemo
(
);
}
}
if
(
if
(
...
@@ -155,14 +155,16 @@ const MemoEditor: React.FC<Props> = () => {
...
@@ -155,14 +155,16 @@ const MemoEditor: React.FC<Props> = () => {
const
prevMemo
=
memoService
.
getMemoById
(
editMemoId
??
UNKNOWN_ID
);
const
prevMemo
=
memoService
.
getMemoById
(
editMemoId
??
UNKNOWN_ID
);
if
(
prevMemo
&&
prevMemo
.
content
!==
content
)
{
if
(
prevMemo
&&
prevMemo
.
content
!==
content
)
{
const
editedMemo
=
await
memoService
.
updateMemo
(
prevMemo
.
id
,
content
);
await
memoService
.
patchMemo
({
editedMemo
.
createdTs
=
Date
.
now
();
id
:
prevMemo
.
id
,
memoService
.
editMemo
(
editedMemo
);
content
,
});
}
}
editorStateService
.
setEditMemo
(
UNKNOWN_ID
);
editorStateService
.
clearEditMemo
(
);
}
else
{
}
else
{
const
newMemo
=
await
memoService
.
createMemo
(
content
);
await
memoService
.
createMemo
({
memoService
.
pushMemo
(
newMemo
);
content
,
});
locationService
.
clearQuery
();
locationService
.
clearQuery
();
}
}
}
catch
(
error
:
any
)
{
}
catch
(
error
:
any
)
{
...
@@ -173,7 +175,7 @@ const MemoEditor: React.FC<Props> = () => {
...
@@ -173,7 +175,7 @@ const MemoEditor: React.FC<Props> = () => {
},
[]);
},
[]);
const
handleCancelBtnClick
=
useCallback
(()
=>
{
const
handleCancelBtnClick
=
useCallback
(()
=>
{
editorStateService
.
setEditMemo
(
UNKNOWN_ID
);
editorStateService
.
clearEditMemo
(
);
editorRef
.
current
?.
setContent
(
""
);
editorRef
.
current
?.
setContent
(
""
);
setEditorContentCache
(
""
);
setEditorContentCache
(
""
);
},
[]);
},
[]);
...
...
web/src/components/MemoFilter.tsx
View file @
a580df5c
...
@@ -28,7 +28,7 @@ const MemoFilter: React.FC<FilterProps> = () => {
...
@@ -28,7 +28,7 @@ const MemoFilter: React.FC<FilterProps> = () => {
<
div
<
div
className=
{
"filter-item-container "
+
(
tagQuery
?
""
:
"hidden"
)
}
className=
{
"filter-item-container "
+
(
tagQuery
?
""
:
"hidden"
)
}
onClick=
{
()
=>
{
onClick=
{
()
=>
{
locationService
.
setTagQuery
(
""
);
locationService
.
setTagQuery
(
undefined
);
}
}
}
}
>
>
<
span
className=
"icon-text"
>
🏷️
</
span
>
{
tagQuery
}
<
span
className=
"icon-text"
>
🏷️
</
span
>
{
tagQuery
}
...
@@ -45,7 +45,7 @@ const MemoFilter: React.FC<FilterProps> = () => {
...
@@ -45,7 +45,7 @@ const MemoFilter: React.FC<FilterProps> = () => {
<
div
<
div
className=
"filter-item-container"
className=
"filter-item-container"
onClick=
{
()
=>
{
onClick=
{
()
=>
{
locationService
.
setFromAndToQuery
(
0
,
0
);
locationService
.
setFromAndToQuery
();
}
}
}
}
>
>
<
span
className=
"icon-text"
>
🗓️
</
span
>
{
utils
.
getDateString
(
duration
.
from
)
}
to
{
utils
.
getDateString
(
duration
.
to
)
}
<
span
className=
"icon-text"
>
🗓️
</
span
>
{
utils
.
getDateString
(
duration
.
from
)
}
to
{
utils
.
getDateString
(
duration
.
to
)
}
...
...
web/src/components/MemoTrashDialog.tsx
View file @
a580df5c
...
@@ -18,9 +18,7 @@ const MemoTrashDialog: React.FC<Props> = (props: Props) => {
...
@@ -18,9 +18,7 @@ const MemoTrashDialog: React.FC<Props> = (props: Props) => {
memoService
memoService
.
fetchDeletedMemos
()
.
fetchDeletedMemos
()
.
then
((
result
)
=>
{
.
then
((
result
)
=>
{
if
(
result
!==
false
)
{
setDeletedMemos
(
result
);
setDeletedMemos
(
result
);
}
})
})
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
toastHelper
.
error
(
"Failed to fetch deleted memos: "
,
error
);
toastHelper
.
error
(
"Failed to fetch deleted memos: "
,
error
);
...
...
web/src/components/MenuBtnsPopup.tsx
View file @
a580df5c
...
@@ -32,7 +32,9 @@ const MenuBtnsPopup: React.FC<Props> = (props: Props) => {
...
@@ -32,7 +32,9 @@ const MenuBtnsPopup: React.FC<Props> = (props: Props) => {
};
};
const
handleSignOutBtnClick
=
async
()
=>
{
const
handleSignOutBtnClick
=
async
()
=>
{
await
userService
.
doSignOut
();
userService
.
doSignOut
().
catch
(()
=>
{
// do nth
});
locationService
.
replaceHistory
(
"/signin"
);
locationService
.
replaceHistory
(
"/signin"
);
window
.
location
.
reload
();
window
.
location
.
reload
();
};
};
...
...
web/src/components/Settings/MyAccountSection.tsx
View file @
a580df5c
...
@@ -39,8 +39,9 @@ const MyAccountSection: React.FC<Props> = () => {
...
@@ -39,8 +39,9 @@ const MyAccountSection: React.FC<Props> = () => {
}
}
try
{
try
{
await
userService
.
updateUsername
(
username
);
await
userService
.
patchUser
({
await
userService
.
doSignIn
();
name
:
username
,
});
toastHelper
.
info
(
"Username changed"
);
toastHelper
.
info
(
"Username changed"
);
}
catch
(
error
:
any
)
{
}
catch
(
error
:
any
)
{
toastHelper
.
error
(
error
.
message
);
toastHelper
.
error
(
error
.
message
);
...
...
web/src/components/Settings/PreferencesSection.tsx
View file @
a580df5c
...
@@ -45,7 +45,11 @@ const PreferencesSection: React.FC<Props> = () => {
...
@@ -45,7 +45,11 @@ const PreferencesSection: React.FC<Props> = () => {
const
createdTs
=
(
memo
as
any
).
createdAt
||
memo
.
createdTs
||
Date
.
now
();
const
createdTs
=
(
memo
as
any
).
createdAt
||
memo
.
createdTs
||
Date
.
now
();
try
{
try
{
await
memoService
.
importMemo
(
content
,
createdTs
);
const
memoCreate
=
{
content
,
createdTs
:
Math
.
floor
(
utils
.
getTimeStampByDate
(
createdTs
)
/
1000
),
};
await
memoService
.
createMemo
(
memoCreate
);
succeedAmount
++
;
succeedAmount
++
;
}
catch
(
error
)
{
}
catch
(
error
)
{
// do nth
// do nth
...
...
web/src/components/ShortcutList.tsx
View file @
a580df5c
...
@@ -96,19 +96,11 @@ const ShortcutContainer: React.FC<ShortcutContainerProps> = (props: ShortcutCont
...
@@ -96,19 +96,11 @@ const ShortcutContainer: React.FC<ShortcutContainerProps> = (props: ShortcutCont
event
.
stopPropagation
();
event
.
stopPropagation
();
try
{
try
{
if
(
shortcut
.
rowStatus
===
"ARCHIVED"
)
{
const
shortcutPatch
:
ShortcutPatch
=
{
await
shortcutService
.
unpinShortcut
(
shortcut
.
id
);
id
:
shortcut
.
id
,
shortcutService
.
editShortcut
({
rowStatus
:
shortcut
.
rowStatus
===
"ARCHIVED"
?
"NORMAL"
:
"ARCHIVED"
,
...
shortcut
,
};
rowStatus
:
"NORMAL"
,
await
shortcutService
.
patchShortcut
(
shortcutPatch
);
});
}
else
{
await
shortcutService
.
pinShortcut
(
shortcut
.
id
);
shortcutService
.
editShortcut
({
...
shortcut
,
rowStatus
:
"ARCHIVED"
,
});
}
}
catch
(
error
)
{
}
catch
(
error
)
{
// do nth
// do nth
}
}
...
...
web/src/components/UsageHeatMap.tsx
View file @
a580df5c
...
@@ -72,7 +72,7 @@ const UsageHeatMap: React.FC<Props> = () => {
...
@@ -72,7 +72,7 @@ const UsageHeatMap: React.FC<Props> = () => {
const
handleUsageStatItemClick
=
useCallback
((
item
:
DailyUsageStat
)
=>
{
const
handleUsageStatItemClick
=
useCallback
((
item
:
DailyUsageStat
)
=>
{
if
(
locationService
.
getState
().
query
?.
duration
?.
from
===
item
.
timestamp
)
{
if
(
locationService
.
getState
().
query
?.
duration
?.
from
===
item
.
timestamp
)
{
locationService
.
setFromAndToQuery
(
0
,
0
);
locationService
.
setFromAndToQuery
();
setCurrentStat
(
null
);
setCurrentStat
(
null
);
}
else
if
(
item
.
count
>
0
)
{
}
else
if
(
item
.
count
>
0
)
{
if
(
!
[
"/"
].
includes
(
locationService
.
getState
().
pathname
))
{
if
(
!
[
"/"
].
includes
(
locationService
.
getState
().
pathname
))
{
...
...
web/src/helpers/api.ts
View file @
a580df5c
...
@@ -159,26 +159,6 @@ namespace api {
...
@@ -159,26 +159,6 @@ namespace api {
});
});
}
}
export
function
archiveMemo
(
memoId
:
MemoId
)
{
return
request
({
method
:
"PATCH"
,
url
:
`/api/memo/
${
memoId
}
`
,
data
:
{
rowStatus
:
"ARCHIVED"
,
},
});
}
export
function
restoreMemo
(
memoId
:
MemoId
)
{
return
request
({
method
:
"PATCH"
,
url
:
`/api/memo/
${
memoId
}
`
,
data
:
{
rowStatus
:
"NORMAL"
,
},
});
}
export
function
deleteMemo
(
memoId
:
MemoId
)
{
export
function
deleteMemo
(
memoId
:
MemoId
)
{
return
request
({
return
request
({
method
:
"DELETE"
,
method
:
"DELETE"
,
...
@@ -193,25 +173,19 @@ namespace api {
...
@@ -193,25 +173,19 @@ namespace api {
});
});
}
}
export
function
createShortcut
(
title
:
string
,
payload
:
string
)
{
export
function
createShortcut
(
shortcutCreate
:
ShortcutCreate
)
{
return
request
<
Shortcut
>
({
return
request
<
Shortcut
>
({
method
:
"POST"
,
method
:
"POST"
,
url
:
"/api/shortcut"
,
url
:
"/api/shortcut"
,
data
:
{
data
:
shortcutCreate
,
title
,
payload
,
},
});
});
}
}
export
function
updateShortcut
(
shortcutId
:
ShortcutId
,
title
:
string
,
payload
:
string
)
{
export
function
patchShortcut
(
shortcutPatch
:
ShortcutPatch
)
{
return
request
<
Shortcut
>
({
return
request
<
Shortcut
>
({
method
:
"PATCH"
,
method
:
"PATCH"
,
url
:
`/api/shortcut/
${
shortcutId
}
`
,
url
:
`/api/shortcut/
${
shortcutPatch
.
id
}
`
,
data
:
{
data
:
shortcutPatch
,
title
,
payload
,
},
});
});
}
}
...
@@ -222,26 +196,6 @@ namespace api {
...
@@ -222,26 +196,6 @@ namespace api {
});
});
}
}
export
function
pinShortcut
(
shortcutId
:
ShortcutId
)
{
return
request
({
method
:
"PATCH"
,
url
:
`/api/shortcut/
${
shortcutId
}
`
,
data
:
{
rowStatus
:
"ARCHIVED"
,
},
});
}
export
function
unpinShortcut
(
shortcutId
:
ShortcutId
)
{
return
request
({
method
:
"PATCH"
,
url
:
`/api/shortcut/
${
shortcutId
}
`
,
data
:
{
rowStatus
:
"NORMAL"
,
},
});
}
export
function
uploadFile
(
formData
:
FormData
)
{
export
function
uploadFile
(
formData
:
FormData
)
{
return
request
<
Resource
>
({
return
request
<
Resource
>
({
method
:
"POST"
,
method
:
"POST"
,
...
...
web/src/less/search-bar.less
View file @
a580df5c
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
> .search-bar-inputer {
> .search-bar-inputer {
.flex(row, flex-start, center);
.flex(row, flex-start, center);
@apply w-full py-2 px-4 rounded-lg flex flex-row justify-start items-center bg-
gray
-200;
@apply w-full py-2 px-4 rounded-lg flex flex-row justify-start items-center bg-
zinc
-200;
> .icon-img {
> .icon-img {
@apply mr-2 w-4 h-auto opacity-80;
@apply mr-2 w-4 h-auto opacity-80;
...
...
web/src/services/editorStateService.ts
View file @
a580df5c
...
@@ -6,13 +6,21 @@ const editorStateService = {
...
@@ -6,13 +6,21 @@ const editorStateService = {
return
store
.
getState
().
editor
;
return
store
.
getState
().
editor
;
},
},
setEditMemo
:
(
editMemoId
:
MemoId
)
=>
{
setEditMemo
WithId
:
(
editMemoId
:
MemoId
)
=>
{
store
.
dispatch
(
setEditMemoId
(
editMemoId
));
store
.
dispatch
(
setEditMemoId
(
editMemoId
));
},
},
setMarkMemo
:
(
markMemoId
:
MemoId
)
=>
{
clearEditMemo
:
()
=>
{
store
.
dispatch
(
setEditMemoId
());
},
setMarkMemoWithId
:
(
markMemoId
:
MemoId
)
=>
{
store
.
dispatch
(
setMarkMemoId
(
markMemoId
));
store
.
dispatch
(
setMarkMemoId
(
markMemoId
));
},
},
clearMarkMemo
:
()
=>
{
store
.
dispatch
(
setMarkMemoId
());
},
};
};
export
default
editorStateService
;
export
default
editorStateService
;
web/src/services/locationService.ts
View file @
a580df5c
import
utils
from
"../helpers/utils"
;
import
utils
from
"../helpers/utils"
;
import
store
from
"../store"
;
import
store
from
"../store"
;
import
{
setQuery
,
setPathname
}
from
"../store/modules/location"
;
import
{
setQuery
,
setPathname
,
Query
}
from
"../store/modules/location"
;
const
updateLocationUrl
=
(
method
:
"replace"
|
"push"
=
"replace"
)
=>
{
const
updateLocationUrl
=
(
method
:
"replace"
|
"push"
=
"replace"
)
=>
{
const
{
query
,
pathname
,
hash
}
=
store
.
getState
().
location
;
const
{
query
,
pathname
,
hash
}
=
store
.
getState
().
location
;
...
@@ -23,36 +23,34 @@ const locationService = {
...
@@ -23,36 +23,34 @@ const locationService = {
return
store
.
getState
().
location
;
return
store
.
getState
().
location
;
},
},
clearQuery
:
()
=>
{
setPathname
:
(
pathname
:
string
)
=>
{
store
.
dispatch
(
setQuery
({}));
updateLocationUrl
();
},
setQuery
:
(
query
:
Query
)
=>
{
store
.
dispatch
(
setQuery
(
query
));
updateLocationUrl
();
},
setPathname
:
(
pathname
:
AppRouter
)
=>
{
store
.
dispatch
(
setPathname
(
pathname
));
store
.
dispatch
(
setPathname
(
pathname
));
updateLocationUrl
();
updateLocationUrl
();
},
},
pushHistory
:
(
pathname
:
AppRouter
)
=>
{
pushHistory
:
(
pathname
:
string
)
=>
{
store
.
dispatch
(
setPathname
(
pathname
));
store
.
dispatch
(
setPathname
(
pathname
));
updateLocationUrl
(
"push"
);
updateLocationUrl
(
"push"
);
},
},
replaceHistory
:
(
pathname
:
AppRouter
)
=>
{
replaceHistory
:
(
pathname
:
string
)
=>
{
store
.
dispatch
(
setPathname
(
pathname
));
store
.
dispatch
(
setPathname
(
pathname
));
updateLocationUrl
(
"replace"
);
updateLocationUrl
(
"replace"
);
},
},
setQuery
:
(
query
:
Query
)
=>
{
store
.
dispatch
(
setQuery
(
query
));
updateLocationUrl
();
},
clearQuery
:
()
=>
{
store
.
dispatch
(
setQuery
({}));
updateLocationUrl
();
},
setMemoTypeQuery
:
(
type
?:
MemoSpecType
)
=>
{
setMemoTypeQuery
:
(
type
?:
MemoSpecType
)
=>
{
const
{
query
}
=
store
.
getState
().
location
;
store
.
dispatch
(
store
.
dispatch
(
setQuery
({
setQuery
({
...
query
,
type
:
type
,
type
:
type
,
})
})
);
);
...
@@ -60,10 +58,8 @@ const locationService = {
...
@@ -60,10 +58,8 @@ const locationService = {
},
},
setMemoShortcut
:
(
shortcutId
?:
ShortcutId
)
=>
{
setMemoShortcut
:
(
shortcutId
?:
ShortcutId
)
=>
{
const
{
query
}
=
store
.
getState
().
location
;
store
.
dispatch
(
store
.
dispatch
(
setQuery
({
setQuery
({
...
query
,
shortcutId
:
shortcutId
,
shortcutId
:
shortcutId
,
})
})
);
);
...
@@ -71,10 +67,8 @@ const locationService = {
...
@@ -71,10 +67,8 @@ const locationService = {
},
},
setTextQuery
:
(
text
?:
string
)
=>
{
setTextQuery
:
(
text
?:
string
)
=>
{
const
{
query
}
=
store
.
getState
().
location
;
store
.
dispatch
(
store
.
dispatch
(
setQuery
({
setQuery
({
...
query
,
text
:
text
,
text
:
text
,
})
})
);
);
...
@@ -82,34 +76,30 @@ const locationService = {
...
@@ -82,34 +76,30 @@ const locationService = {
},
},
setTagQuery
:
(
tag
?:
string
)
=>
{
setTagQuery
:
(
tag
?:
string
)
=>
{
const
{
query
}
=
store
.
getState
().
location
;
store
.
dispatch
(
store
.
dispatch
(
setQuery
({
setQuery
({
...
query
,
tag
:
tag
,
tag
:
tag
,
})
})
);
);
updateLocationUrl
();
updateLocationUrl
();
},
},
setFromAndToQuery
:
(
from
:
number
,
to
:
number
)
=>
{
setFromAndToQuery
:
(
from
?:
number
,
to
?:
number
)
=>
{
const
{
query
}
=
store
.
getState
().
location
;
let
duration
=
undefined
;
if
(
from
&&
to
&&
from
<
to
)
{
duration
=
{
from
,
to
,
};
}
store
.
dispatch
(
store
.
dispatch
(
setQuery
({
setQuery
({
...
query
,
duration
,
duration
:
{
from
,
to
},
})
})
);
);
updateLocationUrl
();
updateLocationUrl
();
},
},
getValidPathname
:
(
pathname
:
string
):
AppRouter
=>
{
if
([
"/"
,
"/signin"
].
includes
(
pathname
))
{
return
pathname
as
AppRouter
;
}
else
{
return
"/"
;
}
},
};
};
export
default
locationService
;
export
default
locationService
;
web/src/services/memoService.ts
View file @
a580df5c
import
api
from
"../helpers/api"
;
import
api
from
"../helpers/api"
;
import
{
TAG_REG
}
from
"../helpers/consts"
;
import
{
TAG_REG
}
from
"../helpers/consts"
;
import
utils
from
"../helpers/utils"
;
import
{
createMemo
,
patchMemo
,
setMemos
,
setTags
}
from
"../store/modules/memo"
;
import
{
patchMemo
,
setMemos
,
setTags
}
from
"../store/modules/memo"
;
import
store
from
"../store"
;
import
store
from
"../store"
;
import
userService
from
"./userService"
;
const
convertResponseModelMemo
=
(
memo
:
Memo
):
Memo
=>
{
const
convertResponseModelMemo
=
(
memo
:
Memo
):
Memo
=>
{
return
{
return
{
...
@@ -19,36 +17,24 @@ const memoService = {
...
@@ -19,36 +17,24 @@ const memoService = {
},
},
fetchAllMemos
:
async
()
=>
{
fetchAllMemos
:
async
()
=>
{
if
(
!
userService
.
getState
().
user
)
{
return
false
;
}
const
data
=
await
api
.
getMyMemos
();
const
data
=
await
api
.
getMyMemos
();
const
memos
:
Memo
[]
=
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
));
return
memos
;
return
memos
;
},
},
fetchDeletedMemos
:
async
()
=>
{
fetchDeletedMemos
:
async
()
=>
{
if
(
!
userService
.
getState
().
user
)
{
return
false
;
}
const
data
=
await
api
.
getMyArchivedMemos
();
const
data
=
await
api
.
getMyArchivedMemos
();
const
deletedMemos
:
Memo
[]
=
data
.
map
((
m
)
=>
{
const
deletedMemos
=
data
.
map
((
m
)
=>
{
return
convertResponseModelMemo
(
m
);
return
convertResponseModelMemo
(
m
);
});
});
return
deletedMemos
;
return
deletedMemos
;
},
},
pushMemo
:
(
memo
:
Memo
)
=>
{
getMemoById
:
(
memoId
:
MemoId
)
=>
{
store
.
dispatch
(
setMemos
(
memoService
.
getState
().
memos
.
concat
(
memo
)));
},
getMemoById
:
(
id
:
MemoId
)
=>
{
for
(
const
m
of
memoService
.
getState
().
memos
)
{
for
(
const
m
of
memoService
.
getState
().
memos
)
{
if
(
m
.
id
===
i
d
)
{
if
(
m
.
id
===
memoI
d
)
{
return
m
;
return
m
;
}
}
}
}
...
@@ -56,35 +42,6 @@ const memoService = {
...
@@ -56,35 +42,6 @@ const memoService = {
return
null
;
return
null
;
},
},
archiveMemoById
:
async
(
id
:
MemoId
)
=>
{
const
memo
=
memoService
.
getMemoById
(
id
);
if
(
!
memo
)
{
return
;
}
await
api
.
archiveMemo
(
id
);
store
.
dispatch
(
patchMemo
({
...
memo
,
rowStatus
:
"ARCHIVED"
,
})
);
},
restoreMemoById
:
async
(
id
:
MemoId
)
=>
{
await
api
.
restoreMemo
(
id
);
memoService
.
clearMemos
();
memoService
.
fetchAllMemos
();
},
deleteMemoById
:
async
(
id
:
MemoId
)
=>
{
await
api
.
deleteMemo
(
id
);
},
editMemo
:
(
memo
:
Memo
)
=>
{
store
.
dispatch
(
patchMemo
(
memo
));
},
updateTagsState
:
()
=>
{
updateTagsState
:
()
=>
{
const
{
memos
}
=
memoService
.
getState
();
const
{
memos
}
=
memoService
.
getState
();
const
tagsSet
=
new
Set
<
string
>
();
const
tagsSet
=
new
Set
<
string
>
();
...
@@ -97,43 +54,46 @@ const memoService = {
...
@@ -97,43 +54,46 @@ const memoService = {
store
.
dispatch
(
setTags
(
Array
.
from
(
tagsSet
).
filter
((
t
)
=>
Boolean
(
t
))));
store
.
dispatch
(
setTags
(
Array
.
from
(
tagsSet
).
filter
((
t
)
=>
Boolean
(
t
))));
},
},
clearMemos
:
()
=>
{
store
.
dispatch
(
setMemos
([]));
},
getLinkedMemos
:
async
(
memoId
:
MemoId
):
Promise
<
Memo
[]
>
=>
{
getLinkedMemos
:
async
(
memoId
:
MemoId
):
Promise
<
Memo
[]
>
=>
{
const
{
memos
}
=
memoService
.
getState
();
const
{
memos
}
=
memoService
.
getState
();
return
memos
.
filter
((
m
)
=>
m
.
content
.
includes
(
`
${
memoId
}
`
));
return
memos
.
filter
((
m
)
=>
m
.
content
.
includes
(
`
${
memoId
}
`
));
},
},
createMemo
:
async
(
content
:
string
):
Promise
<
Memo
>
=>
{
createMemo
:
async
(
memoCreate
:
MemoCreate
)
=>
{
const
memo
=
await
api
.
createMemo
({
const
data
=
await
api
.
createMemo
(
memoCreate
);
content
,
const
memo
=
convertResponseModelMemo
(
data
);
});
store
.
dispatch
(
createMemo
(
memo
));
return
convertResponseModelMemo
(
memo
);
},
},
updateMemo
:
async
(
memoId
:
MemoId
,
content
:
string
):
Promise
<
Memo
>
=>
{
patchMemo
:
async
(
memoPatch
:
MemoPatch
):
Promise
<
Memo
>
=>
{
const
memo
=
await
api
.
patchMemo
({
const
data
=
await
api
.
patchMemo
(
memoPatch
);
id
:
memoId
,
const
memo
=
convertResponseModelMemo
(
data
);
content
,
store
.
dispatch
(
patchMemo
(
memo
));
});
return
memo
;
return
convertResponseModelMemo
(
memo
);
},
},
pinMemo
:
async
(
memoId
:
MemoId
)
=>
{
pinMemo
:
async
(
memoId
:
MemoId
)
=>
{
await
api
.
pinMemo
(
memoId
);
await
api
.
pinMemo
(
memoId
);
store
.
dispatch
(
patchMemo
({
id
:
memoId
,
pinned
:
true
,
})
);
},
},
unpinMemo
:
async
(
memoId
:
MemoId
)
=>
{
unpinMemo
:
async
(
memoId
:
MemoId
)
=>
{
await
api
.
unpinMemo
(
memoId
);
await
api
.
unpinMemo
(
memoId
);
store
.
dispatch
(
patchMemo
({
id
:
memoId
,
pinned
:
false
,
})
);
},
},
importMemo
:
async
(
content
:
string
,
createdTs
:
TimeStamp
)
=>
{
deleteMemoById
:
async
(
memoId
:
MemoId
)
=>
{
await
api
.
createMemo
({
await
api
.
deleteMemo
(
memoId
);
content
,
createdTs
:
Math
.
floor
(
utils
.
getTimeStampByDate
(
createdTs
)
/
1000
),
});
},
},
};
};
...
...
web/src/services/shortcutService.ts
View file @
a580df5c
import
userService
from
"./userService"
;
import
api
from
"../helpers/api"
;
import
api
from
"../helpers/api"
;
import
{
UNKNOWN_ID
}
from
"../helpers/consts"
;
import
store
from
"../store/"
;
import
store
from
"../store/"
;
import
{
deleteShortcut
,
patchShortcut
,
setShortcuts
}
from
"../store/modules/shortcut"
;
import
{
createShortcut
,
deleteShortcut
,
patchShortcut
,
setShortcuts
}
from
"../store/modules/shortcut"
;
const
convertResponseModelShortcut
=
(
shortcut
:
Shortcut
):
Shortcut
=>
{
const
convertResponseModelShortcut
=
(
shortcut
:
Shortcut
):
Shortcut
=>
{
return
{
return
{
...
@@ -18,21 +16,12 @@ const shortcutService = {
...
@@ -18,21 +16,12 @@ const shortcutService = {
},
},
getMyAllShortcuts
:
async
()
=>
{
getMyAllShortcuts
:
async
()
=>
{
if
(
!
userService
.
getState
().
user
)
{
const
rawData
=
await
api
.
getMyShortcuts
();
return
false
;
const
shortcuts
=
rawData
.
map
((
s
)
=>
convertResponseModelShortcut
(
s
));
}
const
data
=
await
api
.
getMyShortcuts
();
const
shortcuts
=
data
.
map
((
s
)
=>
convertResponseModelShortcut
(
s
));
store
.
dispatch
(
setShortcuts
(
shortcuts
));
store
.
dispatch
(
setShortcuts
(
shortcuts
));
return
shortcuts
;
},
},
getShortcutById
:
(
id
:
ShortcutId
)
=>
{
getShortcutById
:
(
id
:
ShortcutId
)
=>
{
if
(
id
===
UNKNOWN_ID
)
{
return
null
;
}
for
(
const
s
of
shortcutService
.
getState
().
shortcuts
)
{
for
(
const
s
of
shortcutService
.
getState
().
shortcuts
)
{
if
(
s
.
id
===
id
)
{
if
(
s
.
id
===
id
)
{
return
s
;
return
s
;
...
@@ -42,11 +31,15 @@ const shortcutService = {
...
@@ -42,11 +31,15 @@ const shortcutService = {
return
null
;
return
null
;
},
},
pushShortcut
:
(
shortcut
:
Shortcut
)
=>
{
createShortcut
:
async
(
shortcutCreate
:
ShortcutCreate
)
=>
{
store
.
dispatch
(
setShortcuts
(
shortcutService
.
getState
().
shortcuts
.
concat
(
shortcut
)));
const
data
=
await
api
.
createShortcut
(
shortcutCreate
);
const
shortcut
=
convertResponseModelShortcut
(
data
);
store
.
dispatch
(
createShortcut
(
shortcut
));
},
},
editShortcut
:
(
shortcut
:
Shortcut
)
=>
{
patchShortcut
:
async
(
shortcutPatch
:
ShortcutPatch
)
=>
{
const
data
=
await
api
.
patchShortcut
(
shortcutPatch
);
const
shortcut
=
convertResponseModelShortcut
(
data
);
store
.
dispatch
(
patchShortcut
(
shortcut
));
store
.
dispatch
(
patchShortcut
(
shortcut
));
},
},
...
@@ -54,24 +47,6 @@ const shortcutService = {
...
@@ -54,24 +47,6 @@ const shortcutService = {
await
api
.
deleteShortcutById
(
shortcutId
);
await
api
.
deleteShortcutById
(
shortcutId
);
store
.
dispatch
(
deleteShortcut
(
shortcutId
));
store
.
dispatch
(
deleteShortcut
(
shortcutId
));
},
},
createShortcut
:
async
(
title
:
string
,
payload
:
string
)
=>
{
const
data
=
await
api
.
createShortcut
(
title
,
payload
);
shortcutService
.
pushShortcut
(
convertResponseModelShortcut
(
data
));
},
updateShortcut
:
async
(
shortcutId
:
ShortcutId
,
title
:
string
,
payload
:
string
)
=>
{
const
data
=
await
api
.
updateShortcut
(
shortcutId
,
title
,
payload
);
store
.
dispatch
(
patchShortcut
(
convertResponseModelShortcut
(
data
)));
},
pinShortcut
:
async
(
shortcutId
:
ShortcutId
)
=>
{
await
api
.
pinShortcut
(
shortcutId
);
},
unpinShortcut
:
async
(
shortcutId
:
ShortcutId
)
=>
{
await
api
.
unpinShortcut
(
shortcutId
);
},
};
};
export
default
shortcutService
;
export
default
shortcutService
;
web/src/services/userService.ts
View file @
a580df5c
import
api
from
"../helpers/api"
;
import
api
from
"../helpers/api"
;
import
{
signin
,
signout
}
from
"../store/modules/user"
;
import
store
from
"../store"
;
import
store
from
"../store"
;
import
{
setUser
,
patchUser
}
from
"../store/modules/user"
;
const
convertResponseModelUser
=
(
user
:
User
):
User
=>
{
const
convertResponseModelUser
=
(
user
:
User
):
User
=>
{
return
{
return
{
...
@@ -18,7 +18,7 @@ const userService = {
...
@@ -18,7 +18,7 @@ const userService = {
doSignIn
:
async
()
=>
{
doSignIn
:
async
()
=>
{
const
user
=
await
api
.
getUser
();
const
user
=
await
api
.
getUser
();
if
(
user
)
{
if
(
user
)
{
store
.
dispatch
(
s
ignin
(
convertResponseModelUser
(
user
)));
store
.
dispatch
(
s
etUser
(
convertResponseModelUser
(
user
)));
}
else
{
}
else
{
userService
.
doSignOut
();
userService
.
doSignOut
();
}
}
...
@@ -26,29 +26,14 @@ const userService = {
...
@@ -26,29 +26,14 @@ const userService = {
},
},
doSignOut
:
async
()
=>
{
doSignOut
:
async
()
=>
{
store
.
dispatch
(
signout
);
store
.
dispatch
(
setUser
());
api
.
signout
().
catch
(()
=>
{
await
api
.
signout
();
// do nth
});
},
},
updateUsername
:
async
(
name
:
string
):
Promise
<
void
>
=>
{
patchUser
:
async
(
userPatch
:
UserPatch
):
Promise
<
void
>
=>
{
await
api
.
patchUser
({
const
data
=
await
api
.
patchUser
(
userPatch
);
name
,
const
user
=
convertResponseModelUser
(
data
);
});
store
.
dispatch
(
patchUser
(
user
));
},
updatePassword
:
async
(
password
:
string
):
Promise
<
void
>
=>
{
await
api
.
patchUser
({
password
,
});
},
resetOpenId
:
async
():
Promise
<
string
>
=>
{
const
user
=
await
api
.
patchUser
({
resetOpenId
:
true
,
});
return
user
.
openId
;
},
},
};
};
...
...
web/src/store/modules/editor.ts
View file @
a580df5c
...
@@ -10,10 +10,16 @@ const editorSlice = createSlice({
...
@@ -10,10 +10,16 @@ const editorSlice = createSlice({
initialState
:
{}
as
State
,
initialState
:
{}
as
State
,
reducers
:
{
reducers
:
{
setMarkMemoId
:
(
state
,
action
:
PayloadAction
<
Option
<
MemoId
>>
)
=>
{
setMarkMemoId
:
(
state
,
action
:
PayloadAction
<
Option
<
MemoId
>>
)
=>
{
state
.
markMemoId
=
action
.
payload
;
return
{
...
state
,
markMemoId
:
action
.
payload
,
};
},
},
setEditMemoId
:
(
state
,
action
:
PayloadAction
<
Option
<
MemoId
>>
)
=>
{
setEditMemoId
:
(
state
,
action
:
PayloadAction
<
Option
<
MemoId
>>
)
=>
{
state
.
editMemoId
=
action
.
payload
;
return
{
...
state
,
editMemoId
:
action
.
payload
,
};
},
},
},
},
});
});
...
...
web/src/store/modules/location.ts
View file @
a580df5c
import
{
createSlice
,
PayloadAction
}
from
"@reduxjs/toolkit"
;
import
{
createSlice
,
PayloadAction
}
from
"@reduxjs/toolkit"
;
interface
Duration
{
from
:
number
;
to
:
number
;
}
export
interface
Query
{
tag
?:
string
;
duration
?:
Duration
;
type
?:
MemoSpecType
;
text
?:
string
;
shortcutId
?:
ShortcutId
;
}
interface
State
{
interface
State
{
pathname
:
AppRouter
;
pathname
:
string
;
hash
:
string
;
hash
:
string
;
query
?
:
Query
;
query
:
Query
;
}
}
const
getValidPathname
=
(
pathname
:
string
):
AppRouter
=>
{
const
getValidPathname
=
(
pathname
:
string
):
string
=>
{
if
([
"/"
,
"/signin"
].
includes
(
pathname
))
{
if
([
"/"
,
"/signin"
].
includes
(
pathname
))
{
return
pathname
as
AppRouter
;
return
pathname
;
}
else
{
}
else
{
return
"/"
;
return
"/"
;
}
}
...
@@ -20,6 +33,7 @@ const getStateFromLocation = () => {
...
@@ -20,6 +33,7 @@ const getStateFromLocation = () => {
const
state
:
State
=
{
const
state
:
State
=
{
pathname
:
getValidPathname
(
pathname
),
pathname
:
getValidPathname
(
pathname
),
hash
:
hash
,
hash
:
hash
,
query
:
{},
};
};
if
(
search
!==
""
)
{
if
(
search
!==
""
)
{
...
@@ -48,11 +62,20 @@ const locationSlice = createSlice({
...
@@ -48,11 +62,20 @@ const locationSlice = createSlice({
updateStateWithLocation
:
()
=>
{
updateStateWithLocation
:
()
=>
{
return
getStateFromLocation
();
return
getStateFromLocation
();
},
},
setPathname
:
(
state
,
action
:
PayloadAction
<
AppRouter
>
)
=>
{
setPathname
:
(
state
,
action
:
PayloadAction
<
string
>
)
=>
{
state
.
pathname
=
action
.
payload
;
return
{
...
state
,
pathname
:
action
.
payload
,
};
},
},
setQuery
:
(
state
,
action
:
PayloadAction
<
Partial
<
Query
>>
)
=>
{
setQuery
:
(
state
,
action
:
PayloadAction
<
Partial
<
Query
>>
)
=>
{
state
.
query
=
action
.
payload
;
return
{
...
state
,
query
:
{
...
state
.
query
,
...
action
.
payload
,
},
};
},
},
},
},
});
});
...
...
web/src/store/modules/memo.ts
View file @
a580df5c
...
@@ -33,12 +33,9 @@ const memoSlice = createSlice({
...
@@ -33,12 +33,9 @@ const memoSlice = createSlice({
}
}
});
});
},
},
deleteMemo
:
(
state
,
action
:
PayloadAction
<
MemoId
>
)
=>
{
state
.
memos
=
[...
state
.
memos
].
filter
((
memo
)
=>
memo
.
id
!==
action
.
payload
);
},
},
},
});
});
export
const
{
setMemos
,
setTags
,
createMemo
,
patchMemo
,
deleteMemo
}
=
memoSlice
.
actions
;
export
const
{
setMemos
,
setTags
,
createMemo
,
patchMemo
}
=
memoSlice
.
actions
;
export
default
memoSlice
.
reducer
;
export
default
memoSlice
.
reducer
;
web/src/store/modules/user.ts
View file @
a580df5c
...
@@ -8,18 +8,12 @@ const userSlice = createSlice({
...
@@ -8,18 +8,12 @@ const userSlice = createSlice({
name
:
"user"
,
name
:
"user"
,
initialState
:
{}
as
State
,
initialState
:
{}
as
State
,
reducers
:
{
reducers
:
{
s
ignin
:
(
state
,
action
:
PayloadAction
<
User
>
)
=>
{
s
etUser
:
(
state
,
action
:
PayloadAction
<
User
|
undefined
>
)
=>
{
return
{
return
{
...
state
,
...
state
,
user
:
action
.
payload
,
user
:
action
.
payload
,
};
};
},
},
signout
:
(
state
)
=>
{
return
{
...
state
,
user
:
undefined
,
};
},
patchUser
:
(
state
,
action
:
PayloadAction
<
Partial
<
User
>>
)
=>
{
patchUser
:
(
state
,
action
:
PayloadAction
<
Partial
<
User
>>
)
=>
{
state
.
user
=
{
state
.
user
=
{
...
state
.
user
,
...
state
.
user
,
...
@@ -29,6 +23,6 @@ const userSlice = createSlice({
...
@@ -29,6 +23,6 @@ const userSlice = createSlice({
},
},
});
});
export
const
{
s
ignin
,
signout
,
patchUser
}
=
userSlice
.
actions
;
export
const
{
s
etUser
,
patchUser
}
=
userSlice
.
actions
;
export
default
userSlice
.
reducer
;
export
default
userSlice
.
reducer
;
web/src/types/location.d.ts
View file @
a580df5c
interface
Duration
{
from
:
number
;
to
:
number
;
}
interface
Query
{
tag
?:
string
;
duration
?:
Duration
;
type
?:
MemoSpecType
;
text
?:
string
;
shortcutId
?:
ShortcutId
;
}
type
AppRouter
=
"/"
|
"/signin"
;
interface
AppLocation
{
pathname
:
AppRouter
;
hash
:
string
;
query
:
Query
;
}
web/src/types/modules/shortcut.d.ts
View file @
a580df5c
...
@@ -10,3 +10,15 @@ interface Shortcut {
...
@@ -10,3 +10,15 @@ interface Shortcut {
title
:
string
;
title
:
string
;
payload
:
string
;
payload
:
string
;
}
}
interface
ShortcutCreate
{
title
:
string
;
payload
:
string
;
}
interface
ShortcutPatch
{
id
:
ShortcutId
;
title
?:
string
;
payload
?:
string
;
rowStatus
?:
RowStatus
;
}
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