@@ -116,6 +116,7 @@ import { showError } from '@nextcloud/dialogs'
116116import { setFavorite , setTitle , fetchNote , deleteNote , setCategory } from ' ../NotesService.js'
117117import ShareVariantOutlineIcon from ' vue-material-design-icons/ShareVariantOutline.vue'
118118import { emit , subscribe , unsubscribe } from ' @nextcloud/event-bus'
119+ import { getSidebar } from ' @nextcloud/files'
119120
120121export 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