Skip to content

Commit

Permalink
fix: Disable auto logout while editing
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Oct 13, 2023
1 parent 28d6a71 commit 0d98fdf
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
50 changes: 50 additions & 0 deletions src/mixins/autoLogout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* @copyright Copyright (c) 2023 Julius Härtl <[email protected]>
*
* @author Julius Härtl <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { loadState } from '@nextcloud/initial-state'

export default {

mounted() {
const config = loadState('core', 'config')

if (!config.auto_logout) {
return
}

window.addEventListener('mousemove', this.extendAutoLogout)
window.addEventListener('touchstart', this.extendAutoLogout)
window.addEventListener('keydown', this.extendAutoLogout)
},

beforeDestroy() {
window.removeEventListener('mousemove', this.extendAutoLogout)
window.removeEventListener('touchstart', this.extendAutoLogout)
window.removeEventListener('keydown', this.extendAutoLogout)
},

methods: {
extendAutoLogout() {
localStorage.setItem('lastActive', Date.now().toString())
},
},

}
3 changes: 2 additions & 1 deletion src/view/Office.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import {
getUIDefaults,
} from '../helpers/coolParameters.js'
import Config from '../services/config.tsx'
import autoLogout from '../mixins/autoLogout.js'
import openLocal from '../mixins/openLocal.js'
import pickLink from '../mixins/pickLink.js'
import saveAs from '../mixins/saveAs.js'
Expand All @@ -124,7 +125,7 @@ export default {
ZoteroHint,
},
mixins: [
openLocal, pickLink, saveAs, uiMention, version,
autoLogout, openLocal, pickLink, saveAs, uiMention, version,
],
props: {
filename: {
Expand Down

0 comments on commit 0d98fdf

Please sign in to comment.