Substantially improved item libraries UI, locked behind Patreon tier 5
This commit is contained in:
@@ -25,16 +25,61 @@ Meteor.publish("standardLibrarySpells", function(level){
|
||||
});
|
||||
|
||||
Meteor.publish("customLibraries", function(){
|
||||
userId = this.userId;
|
||||
const userId = this.userId;
|
||||
let user = Meteor.user()
|
||||
let subs = user && user.profile && user.profile.librarySubscriptions;
|
||||
return Libraries.find({
|
||||
$or: [
|
||||
{readers: userId},
|
||||
{writers: userId},
|
||||
{owner: userId},
|
||||
{public: true, _id: {$in: subs || []}},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish("singleLibrary", function(id){
|
||||
const userId = this.userId;
|
||||
return Libraries.find({
|
||||
_id: id,
|
||||
$or: [
|
||||
{readers: userId},
|
||||
{writers: userId},
|
||||
{owner: userId},
|
||||
{public: true},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish("libraryItems", function(libraryId){
|
||||
return LibraryItems.find({library: libraryId});
|
||||
return LibraryItems.find({
|
||||
library: libraryId
|
||||
}, {
|
||||
fields: {
|
||||
name: 1,
|
||||
libraryName: 1,
|
||||
library: 1,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish("libraryItem", function(itemId){
|
||||
let cursor = LibraryItems.find(itemId);
|
||||
let item = cursor.fetch()[0];
|
||||
let userId = Meteor.userId();
|
||||
if (!item) return [];
|
||||
let library = Libraries.findOne(item.library);
|
||||
if (!library) {
|
||||
throw new Meteor.Error("Library item " + item._id + " is an orphan");
|
||||
}
|
||||
if (
|
||||
library.public ||
|
||||
library.owner === userId ||
|
||||
_.contains(library.readers, userId) ||
|
||||
_.contains(library.writers, userId)
|
||||
) {
|
||||
return cursor;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user