Skip to content

Commit

Permalink
fix: support 28 Files
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
  • Loading branch information
skjnldsv authored and nextcloud-command committed Mar 13, 2024
1 parent 9e334fc commit 1761354
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
4 changes: 2 additions & 2 deletions js/recommendations-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/recommendations-main.js.map

Large diffs are not rendered by default.

36 changes: 17 additions & 19 deletions src/components/RecommendedFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ export default {
return this.name
}
},
isFileListAvailable() {
return OCA.Files.App.fileList.changeDirectory && OCA.Files.App.fileList.scrollTo
},
path() {
return (this.directory === '/' ? '' : this.directory) + '/' + this.name
},
Expand All @@ -119,26 +116,27 @@ export default {
}
},
methods: {
changeDirectory(directory) {
// This call does not always return a promise, so we
// wrap it
return Promise.resolve(OCA.Files.App.fileList.changeDirectory(directory))
},
scrollTo(name) {
OCA.Files.App.fileList.scrollTo(name)
},
navigate() {
if (OCA.Viewer && OCA.Viewer.mimetypes.indexOf(this.mimeType) !== -1) {
OCA.Viewer.open({ path: this.path })
// If Viewer is enabled and supports this file, open directly
if (window.OCA?.Viewer && window.OCA.Viewer.mimetypes.indexOf(this.mimeType) !== -1) {
window.OCA.Viewer.open({ path: this.path })
return
}
if (this.isFileListAvailable) {
this.changeDirectory(this.directory)
.then(() => this.scrollTo(this.name))
.catch(console.error.bind(this))
} else {
window.location = generateUrl('/f/' + this.id)

// Navigate to the file if the file router is available
if (window.OCP?.Files?.Router) {
window.OCP.Files.Router.goToRoute(
// use default route
null,
// recommendations is only enabled on files
{ view: 'files', fileid: this.id },
{ dir: this.directory },
)
return
}

// Fallback to the old way of navigating to the file
window.location = generateUrl('/f/' + this.id)
},
},
}
Expand Down
7 changes: 3 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ const header = new Header({
// Load recommendations
store.dispatch('fetchRecommendations')

const vm = new View({
propsData: {},
new View({
name: 'RecommendationsHeader',
store,
})
vm.$mount(el)
}).$mount(el)

// Create settings
const SettingsView = Vue.extend(Settings)
Expand Down

0 comments on commit 1761354

Please sign in to comment.