Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Kotahi
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Omo Oaiya
Kotahi
Commits
f2d9d8a7
Commit
f2d9d8a7
authored
4 years ago
by
Jure
Browse files
Options
Downloads
Patches
Plain Diff
fix: use polling in a dead-end tree location to prevent rerenders
parent
5a9a42f1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/components/AdminPage.js
+2
-4
2 additions, 4 deletions
app/components/AdminPage.js
app/components/RolesUpdater.js
+25
-0
25 additions, 0 deletions
app/components/RolesUpdater.js
with
27 additions
and
4 deletions
app/components/AdminPage.js
+
2
−
4
View file @
f2d9d8a7
...
...
@@ -32,6 +32,7 @@ import Menu from './Menu'
import
{
Spinner
}
from
'
./shared
'
import
currentRolesVar
from
'
../shared/currentRolesVar
'
import
RolesUpdater
from
'
./RolesUpdater
'
const
getParams
=
routerPath
=>
{
const
path
=
'
/journal/versions/:version
'
...
...
@@ -79,10 +80,7 @@ const AdminPage = ({ children, history, match }) => {
const
journal
=
useContext
(
JournalContext
)
const
[
conversion
]
=
useContext
(
XpubContext
)
// Get the current user every 5 seconds (this includes authorization info)
const
{
loading
,
error
,
data
}
=
useQuery
(
GET_CURRENT_USER
,
{
pollInterval
:
5000
,
notifyOnNetworkStatusChange
:
true
,
fetchPolicy
:
'
network-only
'
,
// TODO: useCallback used because of bug: https://github.com/apollographql/apollo-client/issues/6301
onCompleted
:
useCallback
(
data
=>
updateStuff
(
data
),
[]),
...
...
@@ -199,7 +197,7 @@ const AdminPage = ({ children, history, match }) => {
path
=
"
/journal/admin/manuscripts
"
/>
<
/Switch
>
{
/* <Router history={history}>{children}</Router> */
}
<
RolesUpdater
/>
<
/Root
>
)
}
...
...
This diff is collapsed.
Click to expand it.
app/components/RolesUpdater.js
0 → 100644
+
25
−
0
View file @
f2d9d8a7
import
{
useCallback
}
from
'
react
'
import
{
useQuery
}
from
'
@apollo/client
'
import
{
GET_CURRENT_USER
}
from
'
../queries
'
import
currentRolesVar
from
'
../shared/currentRolesVar
'
const
updateStuff
=
data
=>
{
if
(
data
?.
currentUser
)
{
return
currentRolesVar
(
data
.
currentUser
.
_currentRoles
)
}
}
const
RolesUpdater
=
({
children
,
history
,
match
})
=>
{
// This updates the current roles app-wide using Apollo's makeVar
useQuery
(
GET_CURRENT_USER
,
{
pollInterval
:
5000
,
notifyOnNetworkStatusChange
:
true
,
fetchPolicy
:
'
network-only
'
,
// TODO: useCallback used because of bug: https://github.com/apollographql/apollo-client/issues/6301
onCompleted
:
useCallback
(
data
=>
updateStuff
(
data
),
[]),
})
return
null
}
export
default
RolesUpdater
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment