Vendored
+6
@@ -192,6 +192,12 @@ export interface PlacesClient {
|
||||
* @param id - The slug ID of the list.
|
||||
*/
|
||||
get(id: string): Promise<List | null>;
|
||||
/**
|
||||
* Get all places from a list.
|
||||
* @param listId - The slug ID of the list.
|
||||
* @returns Array of Place objects.
|
||||
*/
|
||||
getPlaces(listId: string): Promise<Place[]>;
|
||||
/**
|
||||
* Create or update a list.
|
||||
* @param id - The slug ID (e.g., "to-go").
|
||||
|
||||
Vendored
+18
@@ -103,6 +103,24 @@ const Places = function (privateClient /*, publicClient: BaseClient */) {
|
||||
const path = `_lists/${id}`;
|
||||
return privateClient.getObject(path);
|
||||
},
|
||||
async getPlaces(listId) {
|
||||
const list = await this.get(listId);
|
||||
if (!list) {
|
||||
throw new Error(`List not found: ${listId}`);
|
||||
}
|
||||
if (!list.placeRefs || !Array.isArray(list.placeRefs)) {
|
||||
return [];
|
||||
}
|
||||
const promises = list.placeRefs.map(async (ref) => {
|
||||
if (!ref.id || !ref.geohash)
|
||||
return null;
|
||||
const path = getPath(ref.geohash, ref.id);
|
||||
const place = await privateClient.getObject(path);
|
||||
return place;
|
||||
});
|
||||
const results = await Promise.all(promises);
|
||||
return results.filter((p) => !!p);
|
||||
},
|
||||
async create(id, title, color) {
|
||||
const path = `_lists/${id}`;
|
||||
let list = (await privateClient.getObject(path));
|
||||
|
||||
Reference in New Issue
Block a user