mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 16:33:16 +00:00
07d54d6f6e
An OSM or index place with a reviewed TREK Community picture showed it in its gallery but only a category pin in the lists and on the map: the marker photo asked Google and Wikimedia, never the community's pictures. It now asks them first, the order the gallery shows them in, and only while the TREK Places API is on.
76 lines
3.6 KiB
TypeScript
76 lines
3.6 KiB
TypeScript
import type { AppSettingsRepository } from '../../src/db/repositories/AppSettings.repository';
|
|
import type { PlaceDetailsCacheRepository } from '../../src/db/repositories/PlaceDetailsCache.repository';
|
|
import type { PlacesRepository } from '../../src/db/repositories/Places.repository';
|
|
import type { UsersRepository } from '../../src/db/repositories/Users.repository';
|
|
import type { GoogleQuotaService } from '../../src/nest/google-quota/google-quota.service';
|
|
import { MapsUrlResolver } from '../../src/nest/maps/maps-url.resolver';
|
|
import { MapsService } from '../../src/nest/maps/maps.service';
|
|
import { PlaceDetailsResolver } from '../../src/nest/maps/place-details.resolver';
|
|
import { PlacePhotoResolver } from '../../src/nest/maps/place-photo.resolver';
|
|
import { PlacesProviderSelector } from '../../src/nest/maps/places-provider.selector';
|
|
import { PoisAlongResolver } from '../../src/nest/maps/pois-along.resolver';
|
|
import { GooglePlacesClient } from '../../src/nest/maps/providers/google-places.provider';
|
|
import { OsmClient } from '../../src/nest/maps/providers/osm.client';
|
|
import { WikimediaClient } from '../../src/nest/maps/providers/wikimedia.client';
|
|
import type { TrekCommunityService } from '../../src/nest/maps/trek-community.service';
|
|
import type { PlacePhotoCacheService } from '../../src/nest/place-photos/place-photo-cache.service';
|
|
import { noGoogleQuota } from './google-quota';
|
|
import { photonOff } from './photon';
|
|
import { passThroughPlaceChanges } from './place-changes';
|
|
|
|
/** MapsService and the outbound clients it was wired with, for tests that reach a client directly. */
|
|
export interface MapsParts {
|
|
svc: MapsService;
|
|
google: GooglePlacesClient;
|
|
osm: OsmClient;
|
|
wiki: WikimediaClient;
|
|
selector: PlacesProviderSelector;
|
|
}
|
|
|
|
/**
|
|
* MapsService built by hand the way MapsModule wires it: the repositories and
|
|
* caches a test hands in, and real clients over the global fetch the test
|
|
* stubs. The argument order is MapsService's old six-argument constructor, so
|
|
* a hand-built service reads the same as it did before the providers split out.
|
|
*/
|
|
export function buildMapsParts(
|
|
photoCache: PlacePhotoCacheService,
|
|
appSettings: AppSettingsRepository,
|
|
users: UsersRepository,
|
|
placeDetailsCache: PlaceDetailsCacheRepository,
|
|
places: PlacesRepository,
|
|
googleQuota: GoogleQuotaService = noGoogleQuota,
|
|
): MapsParts {
|
|
const google = new GooglePlacesClient(googleQuota);
|
|
const osm = new OsmClient(photonOff());
|
|
const wiki = new WikimediaClient();
|
|
const selector = new PlacesProviderSelector(appSettings, users, googleQuota);
|
|
// No community pictures here: a hand-built service never reaches the TREK Places API.
|
|
const community = { photoPaths: async () => [], imageBytes: async () => null } as unknown as TrekCommunityService;
|
|
const photos = new PlacePhotoResolver(
|
|
photoCache,
|
|
places,
|
|
google,
|
|
wiki,
|
|
selector,
|
|
passThroughPlaceChanges(),
|
|
community,
|
|
);
|
|
const links = new MapsUrlResolver(osm);
|
|
const details = new PlaceDetailsResolver(placeDetailsCache, google, osm, selector);
|
|
const along = new PoisAlongResolver(osm);
|
|
const svc = new MapsService(photoCache, appSettings, google, osm, wiki, selector, photos, links, details, along);
|
|
return { svc, google, osm, wiki, selector };
|
|
}
|
|
|
|
export function buildMapsService(
|
|
photoCache: PlacePhotoCacheService,
|
|
appSettings: AppSettingsRepository,
|
|
users: UsersRepository,
|
|
placeDetailsCache: PlaceDetailsCacheRepository,
|
|
places: PlacesRepository,
|
|
googleQuota: GoogleQuotaService = noGoogleQuota,
|
|
): MapsService {
|
|
return buildMapsParts(photoCache, appSettings, users, placeDetailsCache, places, googleQuota).svc;
|
|
}
|