Skip to content

Commit

Permalink
feat: Refresh page after onlyoffice idle session
Browse files Browse the repository at this point in the history
OnlyOffice displays an alert if the user stays too long on a document without acting. This alert asks him to reload the page. We capture the event and automatically refresh the page. After the refresh, the page is back in reading mode so the user can click to edit it again
  • Loading branch information
cballevre committed Mar 13, 2023
1 parent 6ef7975 commit 8276fed
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/drive/web/modules/views/OnlyOffice/useConfig.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ const useConfig = () => {
public_name
})

const onWarning = event => {
// sessionIdle
if (event.data.warningCode === -121) {
window.location.reload()
}
}

const serverUrl = onlyoffice.url
const apiUrl = `${serverUrl}/web-apps/apps/api/documents/api.js`
const docEditorConfig = {
Expand All @@ -92,7 +99,8 @@ const useConfig = () => {
token: onlyoffice.token,
documentType: onlyoffice.documentType,
events: {
onAppReady: () => setIsEditorReady(true)
onAppReady: () => setIsEditorReady(true),
onWarning
}
}

Expand Down

0 comments on commit 8276fed

Please sign in to comment.