Skip to content

Commit ebba664

Browse files
authored
Merge pull request #709 from nextcloud/backport/702/stable28
2 parents 9e334fc + 1761354 commit ebba664

4 files changed

Lines changed: 23 additions & 26 deletions

File tree

js/recommendations-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/recommendations-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/RecommendedFile.vue

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/main.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ const header = new Header({
4545
// Load recommendations
4646
store.dispatch('fetchRecommendations')
4747

48-
const vm = new View({
49-
propsData: {},
48+
new View({
49+
name: 'RecommendationsHeader',
5050
store,
51-
})
52-
vm.$mount(el)
51+
}).$mount(el)
5352

5453
// Create settings
5554
const SettingsView = Vue.extend(Settings)

0 commit comments

Comments
 (0)