add currentSetting to ReactiveCache

This commit is contained in:
Martin Filser 2022-12-13 23:20:04 +01:00
parent c6ee58ef88
commit b7dbeba7de
13 changed files with 59 additions and 55 deletions

View file

@ -31,6 +31,10 @@ ReactiveCacheServer = {
const ret = CustomFields.find(selector).fetch();
return ret;
},
getCurrentSetting() {
const ret = Settings.findOne();
return ret;
},
}
// only the Client is reactive
@ -106,6 +110,16 @@ ReactiveCacheClient = {
}
const ret = this.__customFields.get(Jsons.stringify(selector));
return ret;
},
getCurrentSetting() {
if (!this.__currentSetting || !this.__currentSetting.get()) {
this.__currentSetting = new DataCache(() => {
const _ret = Settings.findOne();
return _ret;
});
}
const ret = this.__currentSetting.get();
return ret;
}
}
@ -179,6 +193,15 @@ ReactiveCache = {
}
return ret;
},
getCurrentSetting() {
let ret;
if (Meteor.isServer) {
ret = ReactiveCacheServer.getCurrentSetting();
} else {
ret = ReactiveCacheClient.getCurrentSetting();
}
return ret;
},
}
export { ReactiveCache };