second: open camera

This commit is contained in:
2026-06-08 16:23:24 +09:00
parent 15be996704
commit 2b4a005407
9 changed files with 352 additions and 54 deletions

View File

@@ -1,16 +1,24 @@
import { collection, query, where, getDocs } from 'firebase/firestore'; // tools for building and running db queries
import { db } from './config'; // database connection
import { getQueryPrefix } from '$lib/utils/geohash'; // convert coordinates into geohash string
import { collection, query, where, getDocs } from 'firebase/firestore';
import { getDb, isFirebaseConfigured } from './config.js';
import { getQueryPrefix } from '$lib/utils/geohash.js';
export async function getNearbyMessages(lat, lng) {
const prefix = getQueryPrefix(lat, lng);
if (!isFirebaseConfigured()) {
console.warn(
'Firebase가 설정되지 않아 메시지를 불러오지 못했습니다. 프로젝트 루트에 .env 파일을 추가하세요.'
);
return [];
}
const q = query(
collection(db, 'messages'),
where('geohash', '>=', prefix),
where('geohash', '<', prefix + 'z')
);
const prefix = getQueryPrefix(lat, lng);
const db = getDb();
const snapshot = await getDocs(q);
return snapshot.docs.map(doc => ({ id: doc.id, ...doc.data() }));
}
const q = query(
collection(db, 'messages'),
where('geohash', '>=', prefix),
where('geohash', '<', prefix + 'z')
);
const snapshot = await getDocs(q);
return snapshot.docs.map((doc) => ({ id: doc.id, ...doc.data() }));
}