Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
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
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
a3adf21a
Commit
a3adf21a
authored
Nov 08, 2021
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve types in sidebar/helpers/build-thread.js
parent
7b775f6d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
build-thread.js
src/sidebar/helpers/build-thread.js
+5
-3
No files found.
src/sidebar/helpers/build-thread.js
View file @
a3adf21a
...
@@ -48,20 +48,22 @@ function annotationId(annotation) {
...
@@ -48,20 +48,22 @@ function annotationId(annotation) {
* Is there a valid path from the thread indicated by `id` to the root thread,
* Is there a valid path from the thread indicated by `id` to the root thread,
* with no circular references?
* with no circular references?
*
*
* @param {Record<string, Thread>} threads
* @param {string} id - The id of the thread to be verified
* @param {string} id - The id of the thread to be verified
* @param {string} ancestorId - The ancestor of the thread indicated by id that
* @param {string} ancestorId - The ancestor of the thread indicated by id that
* is to be verified: is it extant and not a circular reference?
* is to be verified: is it extant and not a circular reference?
* @return {boolean}
* @return {boolean}
*/
*/
function
hasPathToRoot
(
threads
,
id
,
ancestorId
)
{
function
hasPathToRoot
(
threads
,
id
,
ancestorId
)
{
if
(
!
threads
[
ancestorId
]
||
threads
[
ancestorId
].
parent
===
id
)
{
const
ancestor
=
threads
[
ancestorId
];
if
(
!
ancestor
||
ancestor
.
parent
===
id
)
{
// Thread for ancestor not found, or points at itself: circular reference
// Thread for ancestor not found, or points at itself: circular reference
return
false
;
return
false
;
}
else
if
(
!
threads
[
ancestorId
]
.
parent
)
{
}
else
if
(
!
ancestor
.
parent
)
{
// Top of the tree: we've made it
// Top of the tree: we've made it
return
true
;
return
true
;
}
}
return
hasPathToRoot
(
threads
,
id
,
threads
[
ancestorId
]
.
parent
);
return
hasPathToRoot
(
threads
,
id
,
ancestor
.
parent
);
}
}
/**
/**
...
...
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