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
2e5b1209
Commit
2e5b1209
authored
May 22, 2022
by
boojack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update store selector
parent
948b5339
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
79 additions
and
75 deletions
+79
-75
MemoEditor.tsx
web/src/components/MemoEditor.tsx
+2
-4
MemoFilter.tsx
web/src/components/MemoFilter.tsx
+1
-3
MemoList.tsx
web/src/components/MemoList.tsx
+2
-5
MemosHeader.tsx
web/src/components/MemosHeader.tsx
+2
-5
SettingDialog.tsx
web/src/components/SettingDialog.tsx
+1
-3
MyAccountSection.tsx
web/src/components/Settings/MyAccountSection.tsx
+1
-2
ShortcutList.tsx
web/src/components/ShortcutList.tsx
+3
-4
Sidebar.tsx
web/src/components/Sidebar.tsx
+3
-4
TagList.tsx
web/src/components/TagList.tsx
+2
-4
UsageHeatMap.tsx
web/src/components/UsageHeatMap.tsx
+1
-3
UserBanner.tsx
web/src/components/UserBanner.tsx
+3
-5
Home.tsx
web/src/pages/Home.tsx
+1
-3
memo.ts
web/src/store/modules/memo.ts
+25
-13
shortcut.ts
web/src/store/modules/shortcut.ts
+25
-13
user.ts
web/src/store/modules/user.ts
+7
-4
No files found.
web/src/components/MemoEditor.tsx
View file @
2e5b1209
...
@@ -43,10 +43,8 @@ const getCursorPostion = (input: HTMLTextAreaElement) => {
...
@@ -43,10 +43,8 @@ const getCursorPostion = (input: HTMLTextAreaElement) => {
interface
Props
{}
interface
Props
{}
const
MemoEditor
:
React
.
FC
<
Props
>
=
()
=>
{
const
MemoEditor
:
React
.
FC
<
Props
>
=
()
=>
{
const
{
const
editorState
=
useAppSelector
((
state
)
=>
state
.
editor
);
editor
:
editorState
,
const
tags
=
useAppSelector
((
state
)
=>
state
.
memo
.
tags
);
memo
:
{
tags
},
}
=
useAppSelector
((
state
)
=>
state
);
const
[
isTagSeletorShown
,
toggleTagSeletor
]
=
useToggle
(
false
);
const
[
isTagSeletorShown
,
toggleTagSeletor
]
=
useToggle
(
false
);
const
editorRef
=
useRef
<
EditorRefActions
>
(
null
);
const
editorRef
=
useRef
<
EditorRefActions
>
(
null
);
const
prevGlobalStateRef
=
useRef
(
editorState
);
const
prevGlobalStateRef
=
useRef
(
editorState
);
...
...
web/src/components/MemoFilter.tsx
View file @
2e5b1209
...
@@ -7,9 +7,7 @@ import "../less/memo-filter.less";
...
@@ -7,9 +7,7 @@ import "../less/memo-filter.less";
interface
FilterProps
{}
interface
FilterProps
{}
const
MemoFilter
:
React
.
FC
<
FilterProps
>
=
()
=>
{
const
MemoFilter
:
React
.
FC
<
FilterProps
>
=
()
=>
{
const
{
const
query
=
useAppSelector
((
state
)
=>
state
.
location
.
query
);
location
:
{
query
},
}
=
useAppSelector
((
state
)
=>
state
);
const
{
tag
:
tagQuery
,
duration
,
type
:
memoType
,
text
:
textQuery
,
shortcutId
}
=
query
??
{};
const
{
tag
:
tagQuery
,
duration
,
type
:
memoType
,
text
:
textQuery
,
shortcutId
}
=
query
??
{};
const
shortcut
=
shortcutId
?
shortcutService
.
getShortcutById
(
shortcutId
)
:
null
;
const
shortcut
=
shortcutId
?
shortcutService
.
getShortcutById
(
shortcutId
)
:
null
;
const
showFilter
=
Boolean
(
tagQuery
||
(
duration
&&
duration
.
from
<
duration
.
to
)
||
memoType
||
textQuery
||
shortcut
);
const
showFilter
=
Boolean
(
tagQuery
||
(
duration
&&
duration
.
from
<
duration
.
to
)
||
memoType
||
textQuery
||
shortcut
);
...
...
web/src/components/MemoList.tsx
View file @
2e5b1209
...
@@ -11,10 +11,8 @@ import "../less/memo-list.less";
...
@@ -11,10 +11,8 @@ import "../less/memo-list.less";
interface
Props
{}
interface
Props
{}
const
MemoList
:
React
.
FC
<
Props
>
=
()
=>
{
const
MemoList
:
React
.
FC
<
Props
>
=
()
=>
{
const
{
const
query
=
useAppSelector
((
state
)
=>
state
.
location
.
query
);
location
:
{
query
},
const
memos
=
useAppSelector
((
state
)
=>
state
.
memo
.
memos
);
memo
:
{
memos
},
}
=
useAppSelector
((
state
)
=>
state
);
const
[
isFetching
,
setFetchStatus
]
=
useState
(
true
);
const
[
isFetching
,
setFetchStatus
]
=
useState
(
true
);
const
wrapperElement
=
useRef
<
HTMLDivElement
>
(
null
);
const
wrapperElement
=
useRef
<
HTMLDivElement
>
(
null
);
...
@@ -79,7 +77,6 @@ const MemoList: React.FC<Props> = () => {
...
@@ -79,7 +77,6 @@ const MemoList: React.FC<Props> = () => {
const pinnedMemos = shownMemos.filter((m) =
>
m.pinned);
const pinnedMemos = shownMemos.filter((m) =
>
m.pinned);
const unpinnedMemos = shownMemos.filter((m) =
>
!m.pinned);
const unpinnedMemos = shownMemos.filter((m) =
>
!m.pinned);
const sortedMemos = pinnedMemos.concat(unpinnedMemos).filter((m) =
>
m.rowStatus === "NORMAL");
const sortedMemos = pinnedMemos.concat(unpinnedMemos).filter((m) =
>
m.rowStatus === "NORMAL");
console.log(memos.length, sortedMemos.length);
useEffect(() =
>
{
useEffect(() =
>
{
memoService
memoService
...
...
web/src/components/MemosHeader.tsx
View file @
2e5b1209
...
@@ -9,11 +9,8 @@ let prevRequestTimestamp = Date.now();
...
@@ -9,11 +9,8 @@ let prevRequestTimestamp = Date.now();
interface
Props
{}
interface
Props
{}
const
MemosHeader
:
React
.
FC
<
Props
>
=
()
=>
{
const
MemosHeader
:
React
.
FC
<
Props
>
=
()
=>
{
const
{
const
query
=
useAppSelector
((
state
)
=>
state
.
location
.
query
);
location
:
{
query
},
const
shortcuts
=
useAppSelector
((
state
)
=>
state
.
shortcut
.
shortcuts
);
shortcut
:
{
shortcuts
},
}
=
useAppSelector
((
state
)
=>
state
);
const
[
titleText
,
setTitleText
]
=
useState
(
"MEMOS"
);
const
[
titleText
,
setTitleText
]
=
useState
(
"MEMOS"
);
useEffect
(()
=>
{
useEffect
(()
=>
{
...
...
web/src/components/SettingDialog.tsx
View file @
2e5b1209
...
@@ -15,10 +15,8 @@ interface State {
...
@@ -15,10 +15,8 @@ interface State {
}
}
const
SettingDialog
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
SettingDialog
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
{
user
:
{
user
},
}
=
useAppSelector
((
state
)
=>
state
);
const
{
destroy
}
=
props
;
const
{
destroy
}
=
props
;
const
user
=
useAppSelector
((
state
)
=>
state
.
user
.
user
);
const
[
state
,
setState
]
=
useState
<
State
>
({
const
[
state
,
setState
]
=
useState
<
State
>
({
selectedSection
:
"my-account"
,
selectedSection
:
"my-account"
,
});
});
...
...
web/src/components/Settings/MyAccountSection.tsx
View file @
2e5b1209
...
@@ -17,8 +17,7 @@ const validateConfig: ValidatorConfig = {
...
@@ -17,8 +17,7 @@ const validateConfig: ValidatorConfig = {
interface
Props
{}
interface
Props
{}
const
MyAccountSection
:
React
.
FC
<
Props
>
=
()
=>
{
const
MyAccountSection
:
React
.
FC
<
Props
>
=
()
=>
{
const
{
user
:
userState
}
=
useAppSelector
((
state
)
=>
state
);
const
user
=
useAppSelector
((
state
)
=>
state
.
user
.
user
as
User
);
const
user
=
userState
.
user
as
User
;
const
[
username
,
setUsername
]
=
useState
<
string
>
(
user
.
name
);
const
[
username
,
setUsername
]
=
useState
<
string
>
(
user
.
name
);
const
openAPIRoute
=
`
${
window
.
location
.
origin
}
/h/
${
user
.
openId
}
/memo`
;
const
openAPIRoute
=
`
${
window
.
location
.
origin
}
/h/
${
user
.
openId
}
/memo`
;
...
...
web/src/components/ShortcutList.tsx
View file @
2e5b1209
...
@@ -12,11 +12,10 @@ import "../less/shortcut-list.less";
...
@@ -12,11 +12,10 @@ import "../less/shortcut-list.less";
interface
Props
{}
interface
Props
{}
const
ShortcutList
:
React
.
FC
<
Props
>
=
()
=>
{
const
ShortcutList
:
React
.
FC
<
Props
>
=
()
=>
{
const
{
const
query
=
useAppSelector
((
state
)
=>
state
.
location
.
query
);
location
:
{
query
},
const
shortcuts
=
useAppSelector
((
state
)
=>
state
.
shortcut
.
shortcuts
);
shortcut
:
{
shortcuts
},
}
=
useAppSelector
((
state
)
=>
state
);
const
loadingState
=
useLoading
();
const
loadingState
=
useLoading
();
const
pinnedShortcuts
=
shortcuts
const
pinnedShortcuts
=
shortcuts
.
filter
((
s
)
=>
s
.
rowStatus
===
"ARCHIVED"
)
.
filter
((
s
)
=>
s
.
rowStatus
===
"ARCHIVED"
)
.
sort
((
a
,
b
)
=>
utils
.
getTimeStampByDate
(
b
.
createdTs
)
-
utils
.
getTimeStampByDate
(
a
.
createdTs
));
.
sort
((
a
,
b
)
=>
utils
.
getTimeStampByDate
(
b
.
createdTs
)
-
utils
.
getTimeStampByDate
(
a
.
createdTs
));
...
...
web/src/components/Sidebar.tsx
View file @
2e5b1209
...
@@ -12,10 +12,9 @@ import "../less/siderbar.less";
...
@@ -12,10 +12,9 @@ import "../less/siderbar.less";
interface
Props
{}
interface
Props
{}
const
Sidebar
:
React
.
FC
<
Props
>
=
()
=>
{
const
Sidebar
:
React
.
FC
<
Props
>
=
()
=>
{
const
{
const
{
memos
,
tags
}
=
useAppSelector
((
state
)
=>
state
.
memo
);
memo
:
{
memos
,
tags
},
const
user
=
useAppSelector
((
state
)
=>
state
.
user
.
user
);
user
:
{
user
},
}
=
useAppSelector
((
state
)
=>
state
);
const
createdDays
=
user
?
Math
.
ceil
((
Date
.
now
()
-
utils
.
getTimeStampByDate
(
user
.
createdTs
))
/
1000
/
3600
/
24
)
:
0
;
const
createdDays
=
user
?
Math
.
ceil
((
Date
.
now
()
-
utils
.
getTimeStampByDate
(
user
.
createdTs
))
/
1000
/
3600
/
24
)
:
0
;
const
handleMyAccountBtnClick
=
()
=>
{
const
handleMyAccountBtnClick
=
()
=>
{
...
...
web/src/components/TagList.tsx
View file @
2e5b1209
...
@@ -15,10 +15,8 @@ interface Tag {
...
@@ -15,10 +15,8 @@ interface Tag {
interface
Props
{}
interface
Props
{}
const
TagList
:
React
.
FC
<
Props
>
=
()
=>
{
const
TagList
:
React
.
FC
<
Props
>
=
()
=>
{
const
{
const
{
memos
,
tags
:
tagsText
}
=
useAppSelector
((
state
)
=>
state
.
memo
);
location
:
{
query
},
const
query
=
useAppSelector
((
state
)
=>
state
.
location
.
query
);
memo
:
{
memos
,
tags
:
tagsText
},
}
=
useAppSelector
((
state
)
=>
state
);
const
[
tags
,
setTags
]
=
useState
<
Tag
[]
>
([]);
const
[
tags
,
setTags
]
=
useState
<
Tag
[]
>
([]);
useEffect
(()
=>
{
useEffect
(()
=>
{
...
...
web/src/components/UsageHeatMap.tsx
View file @
2e5b1209
...
@@ -35,9 +35,7 @@ const UsageHeatMap: React.FC<Props> = () => {
...
@@ -35,9 +35,7 @@ const UsageHeatMap: React.FC<Props> = () => {
const
usedDaysAmount
=
(
tableConfig
.
width
-
1
)
*
tableConfig
.
height
+
todayDay
;
const
usedDaysAmount
=
(
tableConfig
.
width
-
1
)
*
tableConfig
.
height
+
todayDay
;
const
beginDayTimestemp
=
todayTimeStamp
-
usedDaysAmount
*
DAILY_TIMESTAMP
;
const
beginDayTimestemp
=
todayTimeStamp
-
usedDaysAmount
*
DAILY_TIMESTAMP
;
const
{
const
{
memos
}
=
useAppSelector
((
state
)
=>
state
.
memo
);
memo
:
{
memos
},
}
=
useAppSelector
((
state
)
=>
state
);
const
[
allStat
,
setAllStat
]
=
useState
<
DailyUsageStat
[]
>
(
getInitialUsageStat
(
usedDaysAmount
,
beginDayTimestemp
));
const
[
allStat
,
setAllStat
]
=
useState
<
DailyUsageStat
[]
>
(
getInitialUsageStat
(
usedDaysAmount
,
beginDayTimestemp
));
const
[
popupStat
,
setPopupStat
]
=
useState
<
DailyUsageStat
|
null
>
(
null
);
const
[
popupStat
,
setPopupStat
]
=
useState
<
DailyUsageStat
|
null
>
(
null
);
const
[
currentStat
,
setCurrentStat
]
=
useState
<
DailyUsageStat
|
null
>
(
null
);
const
[
currentStat
,
setCurrentStat
]
=
useState
<
DailyUsageStat
|
null
>
(
null
);
...
...
web/src/components/UserBanner.tsx
View file @
2e5b1209
...
@@ -7,13 +7,11 @@ import "../less/user-banner.less";
...
@@ -7,13 +7,11 @@ import "../less/user-banner.less";
interface
Props
{}
interface
Props
{}
const
UserBanner
:
React
.
FC
<
Props
>
=
()
=>
{
const
UserBanner
:
React
.
FC
<
Props
>
=
()
=>
{
const
{
const
user
=
useAppSelector
((
state
)
=>
state
.
user
.
user
);
user
:
{
user
},
}
=
useAppSelector
((
state
)
=>
state
);
const
username
=
user
?
user
.
name
:
"Memos"
;
const
[
shouldShowPopupBtns
,
setShouldShowPopupBtns
]
=
useState
(
false
);
const
[
shouldShowPopupBtns
,
setShouldShowPopupBtns
]
=
useState
(
false
);
const
username
=
user
?
user
.
name
:
"Memos"
;
const
handleUsernameClick
=
useCallback
(()
=>
{
const
handleUsernameClick
=
useCallback
(()
=>
{
locationService
.
pushHistory
(
"/"
);
locationService
.
pushHistory
(
"/"
);
locationService
.
clearQuery
();
locationService
.
clearQuery
();
...
...
web/src/pages/Home.tsx
View file @
2e5b1209
...
@@ -7,9 +7,7 @@ import useLoading from "../hooks/useLoading";
...
@@ -7,9 +7,7 @@ import useLoading from "../hooks/useLoading";
import
"../less/home.less"
;
import
"../less/home.less"
;
function
Home
()
{
function
Home
()
{
const
{
const
pathname
=
useAppSelector
((
state
)
=>
state
.
location
.
pathname
);
location
:
{
pathname
},
}
=
useAppSelector
((
state
)
=>
state
);
const
loadingState
=
useLoading
();
const
loadingState
=
useLoading
();
useEffect
(()
=>
{
useEffect
(()
=>
{
...
...
web/src/store/modules/memo.ts
View file @
2e5b1209
...
@@ -13,25 +13,37 @@ const memoSlice = createSlice({
...
@@ -13,25 +13,37 @@ const memoSlice = createSlice({
}
as
State
,
}
as
State
,
reducers
:
{
reducers
:
{
setMemos
:
(
state
,
action
:
PayloadAction
<
Memo
[]
>
)
=>
{
setMemos
:
(
state
,
action
:
PayloadAction
<
Memo
[]
>
)
=>
{
state
.
memos
=
action
.
payload
;
return
{
...
state
,
memos
:
action
.
payload
,
};
},
},
setTags
:
(
state
,
action
:
PayloadAction
<
string
[]
>
)
=>
{
setTags
:
(
state
,
action
:
PayloadAction
<
string
[]
>
)
=>
{
state
.
tags
=
action
.
payload
;
return
{
...
state
,
tags
:
action
.
payload
,
};
},
},
createMemo
:
(
state
,
action
:
PayloadAction
<
Memo
>
)
=>
{
createMemo
:
(
state
,
action
:
PayloadAction
<
Memo
>
)
=>
{
state
.
memos
=
state
.
memos
.
concat
(
action
.
payload
);
return
{
...
state
,
memos
:
state
.
memos
.
concat
(
action
.
payload
).
sort
((
a
,
b
)
=>
b
.
createdTs
-
a
.
createdTs
),
};
},
},
patchMemo
:
(
state
,
action
:
PayloadAction
<
Partial
<
Memo
>>
)
=>
{
patchMemo
:
(
state
,
action
:
PayloadAction
<
Partial
<
Memo
>>
)
=>
{
state
.
memos
=
state
.
memos
.
map
((
m
)
=>
{
return
{
if
(
m
.
id
===
action
.
payload
.
id
)
{
...
state
,
return
{
memos
:
state
.
memos
.
map
((
m
)
=>
{
...
m
,
if
(
m
.
id
===
action
.
payload
.
id
)
{
...
action
.
payload
,
return
{
};
...
m
,
}
else
{
...
action
.
payload
,
return
m
;
};
}
}
else
{
});
return
m
;
}
}),
};
},
},
},
},
});
});
...
...
web/src/store/modules/shortcut.ts
View file @
2e5b1209
...
@@ -11,25 +11,37 @@ const shortcutSlice = createSlice({
...
@@ -11,25 +11,37 @@ const shortcutSlice = createSlice({
}
as
State
,
}
as
State
,
reducers
:
{
reducers
:
{
setShortcuts
:
(
state
,
action
:
PayloadAction
<
Shortcut
[]
>
)
=>
{
setShortcuts
:
(
state
,
action
:
PayloadAction
<
Shortcut
[]
>
)
=>
{
state
.
shortcuts
=
action
.
payload
;
return
{
...
state
,
shortcuts
:
action
.
payload
,
};
},
},
createShortcut
:
(
state
,
action
:
PayloadAction
<
Shortcut
>
)
=>
{
createShortcut
:
(
state
,
action
:
PayloadAction
<
Shortcut
>
)
=>
{
state
.
shortcuts
=
state
.
shortcuts
.
concat
(
action
.
payload
);
return
{
...
state
,
shortcuts
:
state
.
shortcuts
.
concat
(
action
.
payload
).
sort
((
a
,
b
)
=>
b
.
createdTs
-
a
.
createdTs
),
};
},
},
patchShortcut
:
(
state
,
action
:
PayloadAction
<
Partial
<
Shortcut
>>
)
=>
{
patchShortcut
:
(
state
,
action
:
PayloadAction
<
Partial
<
Shortcut
>>
)
=>
{
state
.
shortcuts
=
state
.
shortcuts
.
map
((
s
)
=>
{
return
{
if
(
s
.
id
===
action
.
payload
.
id
)
{
...
state
,
return
{
shortcuts
:
state
.
shortcuts
.
map
((
s
)
=>
{
...
s
,
if
(
s
.
id
===
action
.
payload
.
id
)
{
...
action
.
payload
,
return
{
};
...
s
,
}
else
{
...
action
.
payload
,
return
s
;
};
}
}
else
{
});
return
s
;
}
}),
};
},
},
deleteShortcut
:
(
state
,
action
:
PayloadAction
<
ShortcutId
>
)
=>
{
deleteShortcut
:
(
state
,
action
:
PayloadAction
<
ShortcutId
>
)
=>
{
state
.
shortcuts
=
[...
state
.
shortcuts
].
filter
((
shortcut
)
=>
shortcut
.
id
!==
action
.
payload
);
return
{
...
state
,
shortcuts
:
[...
state
.
shortcuts
].
filter
((
shortcut
)
=>
shortcut
.
id
!==
action
.
payload
),
};
},
},
},
},
});
});
...
...
web/src/store/modules/user.ts
View file @
2e5b1209
...
@@ -15,10 +15,13 @@ const userSlice = createSlice({
...
@@ -15,10 +15,13 @@ const userSlice = createSlice({
};
};
},
},
patchUser
:
(
state
,
action
:
PayloadAction
<
Partial
<
User
>>
)
=>
{
patchUser
:
(
state
,
action
:
PayloadAction
<
Partial
<
User
>>
)
=>
{
state
.
user
=
{
return
{
...
state
.
user
,
...
state
,
...
action
.
payload
,
user
:
{
}
as
User
;
...
state
.
user
,
...
action
.
payload
,
}
as
User
,
};
},
},
},
},
});
});
...
...
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