You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
All: Refactor Markdown rendering (#1315)
* Refactoring MdToHtml to avoid manually rendering tokens * Minor fix * Fixed loading of resources * Handle clicking on checkboxes * Added back Katex support * Fixed issues with Katex and note rendering * Added back support for links * Restored code block highlighting support * clean up * Applying update to mobile * Fixed handling of links and cleaned up to share more code between mobile and desktop * Restored content caching and improved handling of additional assets * Clean up and a few fixes * Applied more updates to mobile and added code highlighting support
This commit is contained in:
38
ReactNativeClient/lib/services/ModelCache.js
Normal file
38
ReactNativeClient/lib/services/ModelCache.js
Normal file
@ -0,0 +1,38 @@
|
||||
const BaseItem = require('lib/models/BaseItem');
|
||||
|
||||
class ModelCache {
|
||||
|
||||
constructor() {
|
||||
this.cache_ = {};
|
||||
}
|
||||
|
||||
async byIds(itemType, ids) {
|
||||
const ModelClass = BaseItem.getClassByItemType(itemType);
|
||||
const output = [];
|
||||
|
||||
const remainingIds = [];
|
||||
for (let i = 0; i < ids.length; i++) {
|
||||
const id = ids[i];
|
||||
if (!this.cache_[id]) {
|
||||
remainingIds.push(id);
|
||||
} else {
|
||||
output.push(this.cache_[id].model);
|
||||
}
|
||||
}
|
||||
|
||||
const models = await ModelClass.byIds(remainingIds);
|
||||
for (let i = 0; i < models.length; i++) {
|
||||
this.cache_[models[i].id] = {
|
||||
model: models[i],
|
||||
timestamp: Date.now(),
|
||||
}
|
||||
|
||||
output.push(models[i]);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = ModelCache;
|
Reference in New Issue
Block a user