mirror of
https://github.com/wekan/wekan.git
synced 2025-04-24 14:08:31 -04:00
Move every Avatars.find(idOrFirstObjectSelector, options) to the ReactiveCache
This commit is contained in:
parent
36db6c6e2d
commit
538e197147
3 changed files with 59 additions and 2 deletions
|
@ -172,7 +172,8 @@ BlazeComponent.extendComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
uploadedAvatars() {
|
uploadedAvatars() {
|
||||||
return Avatars.find({ userId: Meteor.userId() }).each();
|
const ret = ReactiveCache.getAvatars({ userId: Meteor.userId() }, {}, true).each();
|
||||||
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
isSelected() {
|
isSelected() {
|
||||||
|
|
|
@ -113,6 +113,17 @@ ReactiveCacheServer = {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
getAvatar(idOrFirstObjectSelector, options) {
|
||||||
|
const ret = Avatars.findOne(idOrFirstObjectSelector, options);
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getAvatars(selector, options, getQuery) {
|
||||||
|
let ret = Avatars.find(selector, options);
|
||||||
|
if (getQuery !== true) {
|
||||||
|
ret = ret.fetch();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
getUser(idOrFirstObjectSelector, options) {
|
getUser(idOrFirstObjectSelector, options) {
|
||||||
const ret = Users.findOne(idOrFirstObjectSelector, options);
|
const ret = Users.findOne(idOrFirstObjectSelector, options);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -518,6 +529,33 @@ ReactiveCacheClient = {
|
||||||
const ret = this.__attachments.get(Jsons.stringify(select));
|
const ret = this.__attachments.get(Jsons.stringify(select));
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
getAvatar(idOrFirstObjectSelector, options) {
|
||||||
|
const idOrFirstObjectSelect = {idOrFirstObjectSelector, options}
|
||||||
|
if (!this.__avatar) {
|
||||||
|
this.__avatar = new DataCache(_idOrFirstObjectSelect => {
|
||||||
|
const __select = Jsons.parse(_idOrFirstObjectSelect);
|
||||||
|
const _ret = Avatars.findOne(__select.idOrFirstObjectSelector, __select.options);
|
||||||
|
return _ret;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const ret = this.__avatar.get(Jsons.stringify(idOrFirstObjectSelect));
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getAvatars(selector, options, getQuery) {
|
||||||
|
const select = {selector, options, getQuery}
|
||||||
|
if (!this.__avatars) {
|
||||||
|
this.__avatars = new DataCache(_select => {
|
||||||
|
const __select = Jsons.parse(_select);
|
||||||
|
let _ret = Avatars.find(__select.selector, __select.options);
|
||||||
|
if (__select.getQuery !== true) {
|
||||||
|
_ret = _ret.fetch();
|
||||||
|
}
|
||||||
|
return _ret;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const ret = this.__avatars.get(Jsons.stringify(select));
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
getUser(idOrFirstObjectSelector, options) {
|
getUser(idOrFirstObjectSelector, options) {
|
||||||
const idOrFirstObjectSelect = {idOrFirstObjectSelector, options}
|
const idOrFirstObjectSelect = {idOrFirstObjectSelector, options}
|
||||||
if (!this.__user) {
|
if (!this.__user) {
|
||||||
|
@ -997,6 +1035,24 @@ ReactiveCache = {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
getAvatar(idOrFirstObjectSelector, options) {
|
||||||
|
let ret;
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret = ReactiveCacheServer.getAvatar(idOrFirstObjectSelector, options);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveCacheClient.getAvatar(idOrFirstObjectSelector, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getAvatars(selector, options, getQuery) {
|
||||||
|
let ret;
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret = ReactiveCacheServer.getAvatars(selector, options, getQuery);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveCacheClient.getAvatars(selector, options, getQuery);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
getUser(idOrFirstObjectSelector, options) {
|
getUser(idOrFirstObjectSelector, options) {
|
||||||
let ret;
|
let ret;
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Avatars from '../../models/avatars';
|
import Avatars from '../../models/avatars';
|
||||||
Meteor.publish('my-avatars', function() {
|
Meteor.publish('my-avatars', function() {
|
||||||
const ret = Avatars.find({ userId: this.userId }).cursor;
|
const ret = ReactiveCache.getAvatars({ userId: this.userId }, {}, true).cursor;
|
||||||
return ret;
|
return ret;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue