mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
Move every Activities.findOne() to the ReactiveCache
This commit is contained in:
parent
54f7361767
commit
79ea4d6d1e
3 changed files with 27 additions and 4 deletions
|
@ -16,15 +16,15 @@ Template.notification.events({
|
|||
Template.notification.helpers({
|
||||
mode: 'board',
|
||||
isOfActivityType(activityId, type) {
|
||||
const activity = Activities.findOne(activityId);
|
||||
const activity = ReactiveCache.getActivity(activityId);
|
||||
return activity && activity.activityType === type;
|
||||
},
|
||||
activityType(activityId) {
|
||||
const activity = Activities.findOne(activityId);
|
||||
const activity = ReactiveCache.getActivity(activityId);
|
||||
return activity ? activity.activityType : '';
|
||||
},
|
||||
activityUser(activityId) {
|
||||
const activity = Activities.findOne(activityId);
|
||||
const activity = ReactiveCache.getActivity(activityId);
|
||||
return activity && activity.userId;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -43,6 +43,10 @@ ReactiveCacheServer = {
|
|||
const ret = Users.findOne(id);
|
||||
return ret;
|
||||
},
|
||||
getActivity(id) {
|
||||
const ret = Activities.findOne(id);
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
const ret = Settings.findOne();
|
||||
return ret;
|
||||
|
@ -157,6 +161,16 @@ ReactiveCacheClient = {
|
|||
const ret = this.__user.get(id);
|
||||
return ret;
|
||||
},
|
||||
getActivity(id) {
|
||||
if (!this.__activity) {
|
||||
this.__activity = new DataCache(_id => {
|
||||
const _ret = Activities.findOne(_id);
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__activity.get(id);
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
if (!this.__currentSetting || !this.__currentSetting.get()) {
|
||||
this.__currentSetting = new DataCache(() => {
|
||||
|
@ -276,6 +290,15 @@ ReactiveCache = {
|
|||
}
|
||||
return ret;
|
||||
},
|
||||
getActivity(id) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getActivity(id);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getActivity(id);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
|
|
|
@ -808,7 +808,7 @@ Users.helpers({
|
|||
const notification = notifications[index];
|
||||
// this preserves their db sort order for editing
|
||||
notification.dbIndex = index;
|
||||
notification.activity = Activities.findOne(notification.activity);
|
||||
notification.activity = ReactiveCache.getActivity(notification.activity);
|
||||
}
|
||||
// this sorts them newest to oldest to match Trello's behavior
|
||||
notifications.reverse();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue