Skip to content

Commit 2640f89

Browse files
committed
fix: Migrate to new files API
Signed-off-by: Enjeck C. <patrathewhiz@gmail.com>
1 parent 693b2c3 commit 2640f89

File tree

3 files changed

+72
-9
lines changed

3 files changed

+72
-9
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@nextcloud/axios": "^2.5.1",
2121
"@nextcloud/dialogs": "^7.1.0",
2222
"@nextcloud/event-bus": "^3.3.3",
23+
"@nextcloud/files": "^4.0.0-rc.1",
2324
"@nextcloud/initial-state": "^3.0.0",
2425
"@nextcloud/moment": "^1.3.5",
2526
"@nextcloud/router": "^3.1.0",

src/components/NoteItem.vue

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ import { showError } from '@nextcloud/dialogs'
116116
import { setFavorite, setTitle, fetchNote, deleteNote, setCategory } from '../NotesService.js'
117117
import ShareVariantOutlineIcon from 'vue-material-design-icons/ShareVariantOutline.vue'
118118
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
119+
import { getSidebar } from '@nextcloud/files'
119120
120121
export default {
121122
name: 'NoteItem',
@@ -239,6 +240,7 @@ export default {
239240
this.loading.favorite = true
240241
setFavorite(this.note.id, !this.note.favorite)
241242
.catch(() => {
243+
this.loading.favorite = false
242244
})
243245
.then(() => {
244246
this.loading.favorite = false
@@ -312,13 +314,28 @@ export default {
312314
}
313315
},
314316
onToggleSharing() {
315-
if (window?.OCA?.Files?.Sidebar?.setActiveTab) {
317+
const sidebar = getSidebar()
318+
if (!sidebar) {
319+
showError(this.t('notes', 'Sharing not available.'))
320+
return
321+
}
322+
323+
try {
316324
emit('toggle-navigation', { open: false })
317325
setTimeout(() => {
318326
window.dispatchEvent(new Event('resize'))
319327
}, 200)
320-
window.OCA.Files.Sidebar.setActiveTab('sharing')
321-
window.OCA.Files.Sidebar.open(this.note.internalPath)
328+
sidebar.open(this.note.internalPath)
329+
setTimeout(() => {
330+
try {
331+
sidebar.setActiveTab('sharing')
332+
} catch (e) {
333+
console.warn('Could not activate sharing tab:', e.message)
334+
}
335+
}, 100)
336+
} catch (error) {
337+
console.error('Failed to open sidebar:', error)
338+
showError(this.t('notes', 'Could not open the sharing sidebar.'))
322339
}
323340
},
324341
async onShareCreated(event) {

0 commit comments

Comments
 (0)