Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(auto_logout): Register auto_logout listeners to prevent auto_logout while editing #2845

Merged
merged 1 commit into from Mar 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/document.js
@@ -1,6 +1,7 @@
import { emit } from '@nextcloud/event-bus'
import { generateOcsUrl, getRootUrl, imagePath } from '@nextcloud/router'
import { getRequestToken } from '@nextcloud/auth'
import { loadState } from '@nextcloud/initial-state'
import { showError } from '@nextcloud/dialogs'
import { getLinkWithPicker } from '@nextcloud/vue-richtext'
import '@nextcloud/vue-richtext/dist/style.css'
Expand Down Expand Up @@ -271,6 +272,8 @@ const documentsMain = {
$('#mainContainer').append(frame)
$('#loleafletframe').focus()

documentsMain.registerAutoLogout($('#loleafletframe')[0])

emit('richdocuments:wopi-load:started', {
wopiFileId: fileId,
})
Expand Down Expand Up @@ -813,6 +816,27 @@ const documentsMain = {
postGrabFocus() {
PostMessages.sendWOPIPostMessage('loolframe', 'Grab_Focus')
},

/**
* Register activity listeners that prevent auto_logout from kicking in
* (Core mechanism for this doesn't work, because we create a new frame)
* @param window
*/
registerAutoLogout(window) {
const config = loadState('core', 'config')

if (!config.auto_logout) {
return
}

window.addEventListener('mousemove', e => {
localStorage.setItem('lastActive', Date.now())
})

window.addEventListener('touchstart', e => {
localStorage.setItem('lastActive', Date.now())
})
},
}

$(document).ready(function() {
Expand Down