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

Method chooseDefaultSource

modules/core/ImagerySystem.js:415–432  ·  view source on GitHub ↗

* chooseDefaultSource * When we haven't been told to use a specific background imagery, * this tries several options to pick an appropriate imagery to use.

()

Source from the content-addressed store, hash-verified

413 * this tries several options to pick an appropriate imagery to use.
414 */
415 chooseDefaultSource() {
416 const context = this.context;
417 const storage = context.systems.storage;
418
419 const available = this.visibleSources();
420 const first = available[0];
421 const best = available.find(s => s.best);
422
423 // Consider previously chosen imagery unless it was 'none'
424 let previousID = storage.getItem('background-last-used') || 'none';
425 const previous = (previousID !== 'none') && this.getSourceByID(previousID);
426
427 return best ||
428 previous ||
429 this.getSourceByID('Bing') ||
430 first || // maybe this is a custom Rapid that doesn't include Bing?
431 this.getSourceByID('none');
432 }
433
434
435 /**

Callers 1

_hashchangeMethod · 0.95

Calls 3

visibleSourcesMethod · 0.95
getSourceByIDMethod · 0.95
getItemMethod · 0.45

Tested by

no test coverage detected