You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-18 23:07:45 +02:00
.github
Assets
CliClient
Clipper
ElectronClient
Modules
ReactNativeClient
MarkdownEditor
android
ios
lib
components
hooks
images
joplin-renderer
migrations
models
renderers
services
rest
AlarmService.js
AlarmServiceDriver.android.js
AlarmServiceDriver.ios.js
AlarmServiceDriverNode.js
BaseService.js
DecryptionWorker.js
EncryptionService.js
EncryptionServiceDriverNode.js
ExternalEditWatcher.js
InteropService.js
InteropService_Exporter_Base.js
InteropService_Exporter_Html.js
InteropService_Exporter_Jex.js
InteropService_Exporter_Json.js
InteropService_Exporter_Md.js
InteropService_Exporter_Raw.js
InteropService_Importer_Base.js
InteropService_Importer_EnexToHtml.js
InteropService_Importer_EnexToMd.js
InteropService_Importer_Jex.js
InteropService_Importer_Md.js
InteropService_Importer_Raw.js
ItemChangeUtils.js
KvStore.js
MigrationService.js
ModelCache.js
NavService.js
PluginManager.js
ResourceFetcher.js
ResourceService.js
RevisionService.js
SearchEngine.js
SearchEngineUtils.js
back-button.js
report.js
vendor
ArrayUtils.js
AsyncActionQueue.ts
BaseApplication.js
BaseModel.js
BaseSyncTarget.js
Cache.js
ClipperServer.js
CssUtils.js
DropboxApi.js
EventDispatcher.js
HtmlToMd.js
JoplinError.js
JoplinServerApi.ts
ModelCache.js
ObjectUtils.js
SyncTargetDropbox.js
SyncTargetFilesystem.js
SyncTargetMemory.js
SyncTargetNextcloud.js
SyncTargetOneDrive.js
SyncTargetOneDriveDev.js
SyncTargetRegistry.js
SyncTargetWebDAV.js
TaskQueue.js
TemplateUtils.js
WebDavApi.js
WelcomeUtils.js
database-driver-node.js
database-driver-react-native.js
database.js
dialogs.js
file-api-driver-dropbox.js
file-api-driver-local.js
file-api-driver-memory.js
file-api-driver-onedrive.js
file-api-driver-webdav.js
file-api.js
folders-screen-utils.js
fs-driver-base.js
fs-driver-dummy.js
fs-driver-node.js
fs-driver-rn.js
geolocation-node.js
geolocation-react.js
htmlUtils.js
import-enex-html-gen.js
import-enex-md-gen.js
import-enex.js
joplin-database.js
locale.js
logger.js
markJsUtils.js
markdownUtils.js
markupLanguageUtils.js
mime-utils.js
net-utils.js
onedrive-api-node-utils.js
onedrive-api.js
package.json
parameters.js
parseUri.js
path-utils.js
poor-man-intervals.js
promise-utils.js
randomClipperPort.js
react-logger.js
reducer.js
registry.js
reserved-ids.js
resourceUtils.js
shim-init-node.js
shim-init-react.js
shim.js
string-utils-common.js
string-utils.js
synchronizer.js
time-utils.js
urlUtils.js
uuid.js
welcomeAssets.js
locales
tools
.buckconfig
.flowconfig
.gitattributes
.gitignore
.watchmanconfig
PluginAssetsLoader.ts
app.json
clean_build.bat
gulpfile.js
index.android.js
index.ios.js
index.js
main.js
metro.config.js
package-lock.json
package.json
root.js
setUpQuickActions.ts
Tools
docs
patches
readme
.eslintignore
.eslintrc.js
.gitignore
.travis.yml
BUILD.md
CONTRIBUTING.md
Joplin_install_and_update.sh
LICENSE
README.md
SECURITY.md
_config.yml
appveyor.yml
build_tools_check.js
gulpfile.js
joplin.code-workspace
joplin.sublime-project
package-lock.json
package.json
tsconfig.json
37 lines
700 B
JavaScript
37 lines
700 B
JavaScript
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;
|