From 4a8b72f1635c59da1964cab358c4597f0b594b3d Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Tue, 27 Jul 2021 15:51:09 +0200 Subject: [PATCH] Made sure the unsubscribe button always shows on libraries you are subscribed to --- app/imports/ui/library/SingleLibraryToolbar.vue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/imports/ui/library/SingleLibraryToolbar.vue b/app/imports/ui/library/SingleLibraryToolbar.vue index 24d19b75..fc953903 100644 --- a/app/imports/ui/library/SingleLibraryToolbar.vue +++ b/app/imports/ui/library/SingleLibraryToolbar.vue @@ -53,15 +53,16 @@ export default { subscribed(){ let libraryId = this.$route.params.id; let user = Meteor.user(); - if (!user) return false; - let subs = user.subscribedLibraries; - return subs && subs.includes(libraryId); + return user?.subscribedLibraries?.includes(libraryId); }, showSubscribeButton(){ - let userId = Meteor.userId(); + let user = Meteor.user(); let library = this.library; - if (!library) return; - if ( + if (!user || !library) return; + let userId = user._id; + if (user.subscribedLibraries.includes(library._id)){ + return true + } else if ( library.readers.includes(userId) || library.writers.includes(userId) || library.owner === userId