MCPcopy Create free account
hub / github.com/facebook/Rapid / getRecents

Method getRecents

modules/core/PresetSystem.js:539–558  ·  view source on GitHub ↗

* getRecents * Returns the recently used presets * If this._recentIDs is unset, try to load them from localStorage * @return An Array of recent presets

()

Source from the content-addressed store, hash-verified

537 * @return An Array of recent presets
538 */
539 getRecents() {
540 let presetIDs = this._recentIDs;
541 if (!presetIDs) { // first time, try to get them from localStorage
542 const storage = this.context.systems.storage;
543 presetIDs = JSON.parse(storage.getItem('preset_recents')) || [];
544 }
545
546 const presets = presetIDs
547 .map(item => {
548 const id = item?.id || item; // previously we stored preset, now we just store presetID
549 return this._presets[id];
550 })
551 .filter(Boolean);
552
553 if (!this._recentIDs) {
554 this._recentIDs = presets.map(item => item.id);
555 }
556
557 return presets;
558 }
559
560
561 /**

Callers 1

defaultsMethod · 0.95

Calls 2

filterMethod · 0.80
getItemMethod · 0.45

Tested by

no test coverage detected