Substantially improved item libraries UI, locked behind Patreon tier 5

This commit is contained in:
Stefan Zermatten
2019-05-06 14:51:48 +02:00
parent d4864dda5f
commit 81a3ede86e
24 changed files with 493 additions and 248 deletions

View File

@@ -10,19 +10,21 @@ Schemas.Library = new SimpleSchema({
Libraries.attachSchema(Schemas.Library);
Libraries.after.remove(function(userId, library) {
LibraryItems.remove({library: library._id});
LibrarySpells.remove({library: library._id});
});
if (Meteor.isServer){
Libraries.after.remove(function(userId, library) {
LibraryItems.remove({library: library._id});
LibrarySpells.remove({library: library._id});
});
}
Meteor.methods({
removeLibrary: function(libraryId) {
unshareLibraryWithMe: function(libraryId) {
let library = Libraries.findOne(libraryId);
let userId = Meteor.userId();
let userId = Meteor.userId();
if (!library) return;
if (library.owner === userId){
Libraries.remove(libraryId);
throw new Meteor.error("Can't unshare, you own this")
} else {
if (_.contains(library.readers, userId)){
Libraries.update(libraryId, {$pull: {"readers": userId}});