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

Method selectPhoto

modules/core/PhotoSystem.js:417–459  ·  view source on GitHub ↗

* selectPhoto * Pass falsy values to deselect the layer and photo. * @param {string} layerID? - The layerID to select * @param {string} photoID? - The photoID to select

(layerID = null, photoID = null)

Source from the content-addressed store, hash-verified

415 * @param {string} photoID? - The photoID to select
416 */
417 selectPhoto(layerID = null, photoID = null) {
418 const context = this.context;
419 const map = context.systems.map;
420 const scene = context.systems.gfx.scene;
421
422 const didChange = (this._currPhotoLayerID !== layerID || this._currPhotoID !== photoID);
423
424 // If we're selecting a photo then make sure its layer is enabled too.
425 if (this.photoLayerIDs.includes(layerID) && !this.isLayerEnabled(layerID)) {
426 scene.enableLayers(layerID);
427 return; // exit to avoid infinite loop, we will be right back in here via `_layerchange` handler.
428 }
429
430 // Clear out any existing selection..
431 this._currPhotoLayerID = null;
432 this._currPhotoID = null;
433 scene.clearClass('selectphoto');
434
435 // Apply the new selection..
436 if (photoID && this.photoLayerIDs.includes(layerID)) {
437 const service = context.services[layerID];
438 if (!service) return;
439
440 this._currPhotoLayerID = layerID;
441 this._currPhotoID = photoID;
442 scene.setClass('selectphoto', layerID, photoID);
443
444 // Try to show the viewer with the image selected..
445 service.selectImageAsync(photoID)
446 .then(photo => {
447 if (!photo) return;
448 if (photo.id !== this._currPhotoID) return; // exit if something else is now selected
449 if (this._currDetectionID) return; // don't adjust the map if a detection is already selected
450
451 if (didChange) {
452 map.centerEase(photo.loc);
453 }
454 })
455 .then(() => this.showViewer());
456 }
457
458 this._photoChanged();
459 }
460
461
462 /**

Callers 12

_hashchangeMethod · 0.95
_layerchangeMethod · 0.95
selectDetectionMethod · 0.95
hideViewerMethod · 0.95
_doSelectMethod · 0.80
hideViewerMethod · 0.80
_stepMethod · 0.80
hideViewerMethod · 0.80
imageChangedMethod · 0.80
hideViewerMethod · 0.80
_stepMethod · 0.80
_loadedBubbleDataMethod · 0.80

Calls 8

isLayerEnabledMethod · 0.95
showViewerMethod · 0.95
_photoChangedMethod · 0.95
enableLayersMethod · 0.80
centerEaseMethod · 0.80
clearClassMethod · 0.45
setClassMethod · 0.45
selectImageAsyncMethod · 0.45

Tested by

no test coverage detected