9393import Vue from ' vue'
9494
9595import Modal from ' nextcloud-vue/dist/Components/Modal'
96+ import isMobile from ' nextcloud-vue/dist/Mixins/isMobile'
9697import { generateRemoteUrl , generateUrl } from ' nextcloud-server/dist/router'
9798
9899import Error from ' Components/Error'
@@ -106,6 +107,8 @@ export default {
106107 Error
107108 },
108109
110+ mixins: [isMobile],
111+
109112 data : () => ({
110113 handlers: OCA .Viewer .availableHandlers ,
111114
@@ -121,8 +124,8 @@ export default {
121124
122125 fileList: [],
123126
124- isMobile: window .outerWidth < 768 ,
125127 isFullscreen: window .innerWidth === screen .width ,
128+ isLoaded: false ,
126129
127130 showSidebar: false ,
128131 sidebarWidth: 0 ,
@@ -161,8 +164,13 @@ export default {
161164
162165 watch: {
163166 // make sure any late external app can register handlers
164- handlers : function () {
165- this .registerHandler (this .handlers [this .handlers .length - 1 ])
167+ handlers : function (x , y ) {
168+ // make sure the viewer is done registering handlers
169+ // so we only register handlers added AFTER the init
170+ // of the viewer
171+ if (this .isLoaded ) {
172+ this .registerHandler (this .handlers [this .handlers .length - 1 ])
173+ }
166174 }
167175 },
168176
@@ -172,6 +180,7 @@ export default {
172180 this .handlers .forEach (handler => {
173181 this .registerHandler (handler)
174182 })
183+ this .isLoaded = true
175184 })
176185
177186 window .addEventListener (' resize' , this .onResize )
@@ -431,6 +440,7 @@ export default {
431440 this .currentModal = null
432441 this .fileList = []
433442 this .hideAppsSidebar ()
443+
434444 // restore default
435445 document .body .style .overflow = null
436446 },
@@ -515,7 +525,6 @@ export default {
515525
516526 onResize (event ) {
517527 // Update mobile & fullscreen mode
518- this .isMobile = window .outerWidth < 768
519528 this .isFullscreen = window .innerWidth === screen .width
520529
521530 // update sidebar width
0 commit comments