@@ -96,9 +96,6 @@ export default {
9696 return this .name
9797 }
9898 },
99- isFileListAvailable () {
100- return OCA .Files .App .fileList .changeDirectory && OCA .Files .App .fileList .scrollTo
101- },
10299 path () {
103100 return (this .directory === ' /' ? ' ' : this .directory ) + ' /' + this .name
104101 },
@@ -119,26 +116,27 @@ export default {
119116 }
120117 },
121118 methods: {
122- changeDirectory (directory ) {
123- // This call does not always return a promise, so we
124- // wrap it
125- return Promise .resolve (OCA .Files .App .fileList .changeDirectory (directory))
126- },
127- scrollTo (name ) {
128- OCA .Files .App .fileList .scrollTo (name)
129- },
130119 navigate () {
131- if (OCA .Viewer && OCA .Viewer .mimetypes .indexOf (this .mimeType ) !== - 1 ) {
132- OCA .Viewer .open ({ path: this .path })
120+ // If Viewer is enabled and supports this file, open directly
121+ if (window .OCA ? .Viewer && window .OCA .Viewer .mimetypes .indexOf (this .mimeType ) !== - 1 ) {
122+ window .OCA .Viewer .open ({ path: this .path })
133123 return
134124 }
135- if (this .isFileListAvailable ) {
136- this .changeDirectory (this .directory )
137- .then (() => this .scrollTo (this .name ))
138- .catch (console .error .bind (this ))
139- } else {
140- window .location = generateUrl (' /f/' + this .id )
125+
126+ // Navigate to the file if the file router is available
127+ if (window .OCP ? .Files ? .Router ) {
128+ window .OCP .Files .Router .goToRoute (
129+ // use default route
130+ null ,
131+ // recommendations is only enabled on files
132+ { view: ' files' , fileid: this .id },
133+ { dir: this .directory },
134+ )
135+ return
141136 }
137+
138+ // Fallback to the old way of navigating to the file
139+ window .location = generateUrl (' /f/' + this .id )
142140 },
143141 },
144142}
0 commit comments