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
b2ec0d12
Commit
b2ec0d12
authored
Dec 22, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add skip cache requesting
parent
5673e29e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
11 deletions
+13
-11
RelationListView.tsx
web/src/components/MemoEditor/RelationListView.tsx
+1
-1
MemoRelationListView.tsx
web/src/components/MemoRelationListView.tsx
+2
-2
MemoView.tsx
web/src/components/MemoView.tsx
+1
-1
MemoDetail.tsx
web/src/pages/MemoDetail.tsx
+1
-1
memo.ts
web/src/store/v1/memo.ts
+8
-6
No files found.
web/src/components/MemoEditor/RelationListView.tsx
View file @
b2ec0d12
...
@@ -19,7 +19,7 @@ const RelationListView = (props: Props) => {
...
@@ -19,7 +19,7 @@ const RelationListView = (props: Props) => {
const
requests
=
relationList
const
requests
=
relationList
.
filter
((
relation
)
=>
relation
.
type
===
MemoRelation_Type
.
REFERENCE
)
.
filter
((
relation
)
=>
relation
.
type
===
MemoRelation_Type
.
REFERENCE
)
.
map
(
async
(
relation
)
=>
{
.
map
(
async
(
relation
)
=>
{
return
await
memoStore
.
getOrFetchMemoById
(
relation
.
relatedMemoId
);
return
await
memoStore
.
getOrFetchMemoById
(
relation
.
relatedMemoId
,
{
skipStore
:
true
}
);
});
});
const
list
=
await
Promise
.
all
(
requests
);
const
list
=
await
Promise
.
all
(
requests
);
setReferencingMemoList
(
list
);
setReferencingMemoList
(
list
);
...
...
web/src/components/MemoRelationListView.tsx
View file @
b2ec0d12
...
@@ -22,13 +22,13 @@ const MemoRelationListView = (props: Props) => {
...
@@ -22,13 +22,13 @@ const MemoRelationListView = (props: Props) => {
const
referencingMemoList
=
await
Promise
.
all
(
const
referencingMemoList
=
await
Promise
.
all
(
relationList
relationList
.
filter
((
relation
)
=>
relation
.
memoId
===
memo
.
id
&&
relation
.
relatedMemoId
!==
memo
.
id
)
.
filter
((
relation
)
=>
relation
.
memoId
===
memo
.
id
&&
relation
.
relatedMemoId
!==
memo
.
id
)
.
map
((
relation
)
=>
memoStore
.
getOrFetchMemoById
(
relation
.
relatedMemoId
))
.
map
((
relation
)
=>
memoStore
.
getOrFetchMemoById
(
relation
.
relatedMemoId
,
{
skipStore
:
true
}
))
);
);
setReferencingMemoList
(
referencingMemoList
);
setReferencingMemoList
(
referencingMemoList
);
const
referencedMemoList
=
await
Promise
.
all
(
const
referencedMemoList
=
await
Promise
.
all
(
relationList
relationList
.
filter
((
relation
)
=>
relation
.
memoId
!==
memo
.
id
&&
relation
.
relatedMemoId
===
memo
.
id
)
.
filter
((
relation
)
=>
relation
.
memoId
!==
memo
.
id
&&
relation
.
relatedMemoId
===
memo
.
id
)
.
map
((
relation
)
=>
memoStore
.
getOrFetchMemoById
(
relation
.
memoId
))
.
map
((
relation
)
=>
memoStore
.
getOrFetchMemoById
(
relation
.
memoId
,
{
skipStore
:
true
}
))
);
);
setReferencedMemoList
(
referencedMemoList
);
setReferencedMemoList
(
referencedMemoList
);
})();
})();
...
...
web/src/components/MemoView.tsx
View file @
b2ec0d12
...
@@ -102,7 +102,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
...
@@ -102,7 +102,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
(
relation
)
=>
relation
.
memoId
===
memo
.
id
&&
relation
.
type
===
MemoRelation_Type
.
COMMENT
(
relation
)
=>
relation
.
memoId
===
memo
.
id
&&
relation
.
type
===
MemoRelation_Type
.
COMMENT
)?.
relatedMemoId
;
)?.
relatedMemoId
;
if
(
parentMemoId
)
{
if
(
parentMemoId
)
{
memoStore
.
getOrFetchMemoById
(
parentMemoId
).
then
((
memo
:
Memo
)
=>
{
memoStore
.
getOrFetchMemoById
(
parentMemoId
,
{
skipStore
:
true
}
).
then
((
memo
:
Memo
)
=>
{
setParentMemo
(
memo
);
setParentMemo
(
memo
);
});
});
}
}
...
...
web/src/pages/MemoDetail.tsx
View file @
b2ec0d12
...
@@ -106,7 +106,7 @@ const MemoDetail = () => {
...
@@ -106,7 +106,7 @@ const MemoDetail = () => {
const
handleCommentCreated
=
async
(
commentId
:
number
)
=>
{
const
handleCommentCreated
=
async
(
commentId
:
number
)
=>
{
await
memoStore
.
getOrFetchMemoById
(
commentId
);
await
memoStore
.
getOrFetchMemoById
(
commentId
);
await
memoStore
.
getOrFetchMemoById
(
memo
.
id
,
true
/* skip cache */
);
await
memoStore
.
getOrFetchMemoById
(
memo
.
id
,
{
skipCache
:
true
}
);
};
};
return
(
return
(
...
...
web/src/store/v1/memo.ts
View file @
b2ec0d12
...
@@ -22,9 +22,9 @@ export const useMemoV1Store = create(
...
@@ -22,9 +22,9 @@ export const useMemoV1Store = create(
});
});
return
memos
;
return
memos
;
},
},
getOrFetchMemoById
:
async
(
id
:
number
,
skipCache
=
false
)
=>
{
getOrFetchMemoById
:
async
(
id
:
number
,
options
?:
{
skipCache
?:
boolean
;
skipStore
?:
boolean
}
)
=>
{
const
memo
=
get
().
memoById
.
get
(
id
);
const
memo
=
get
().
memoById
.
get
(
id
);
if
(
memo
&&
!
skipCache
)
{
if
(
memo
&&
!
options
?.
skipCache
)
{
return
memo
;
return
memo
;
}
}
...
@@ -35,10 +35,12 @@ export const useMemoV1Store = create(
...
@@ -35,10 +35,12 @@ export const useMemoV1Store = create(
throw
new
Error
(
"Memo not found"
);
throw
new
Error
(
"Memo not found"
);
}
}
set
((
state
)
=>
{
if
(
!
options
?.
skipStore
)
{
state
.
memoById
.
set
(
id
,
res
.
memo
as
Memo
);
set
((
state
)
=>
{
return
cloneDeep
(
state
);
state
.
memoById
.
set
(
id
,
res
.
memo
as
Memo
);
});
return
cloneDeep
(
state
);
});
}
return
res
.
memo
;
return
res
.
memo
;
},
},
getMemoById
:
(
id
:
number
)
=>
{
getMemoById
:
(
id
:
number
)
=>
{
...
...
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