라이브 티커 · 갤럭시 검색 색인 · 주간 랭킹 스냅샷 · 연속 ZAP 상한 · 가입 행성 Zap · 성운 목표 · 랭킹 갱신 안내 · 행성 터치 반응

This commit is contained in:
Sn-Kinos
2026-10-05 22:38:42 +09:00
parent 000c058097
commit 4bb92c2ee7
44 changed files with 727 additions and 78 deletions
@@ -1,5 +1,5 @@
import 'package:cloud_firestore/cloud_firestore.dart'
show QueryDocumentSnapshot;
show FieldPath, QueryDocumentSnapshot;
import '../../core/data/backend.dart';
import '../planet/planet_data.dart' show rankWithTies;
@@ -102,9 +102,42 @@ class FirestoreGalaxyRepository implements GalaxyRepository {
// Zap 은 가입·생성한 사용자에게만 보인다(Figma 「Zap 버튼」 규칙).
joined: myFandomId.isNotEmpty,
memberships: [for (final id in membershipIds) ?byId[id]],
joinedIds: {
...?(user['fandomIds'] as List?)?.whereType<String>(),
if (myFandomId.isNotEmpty) myFandomId,
},
);
}
/// 전체 행성 이름 접두 검색 — 이름 색인 `fandomNames/{소문자 이름}`(서버가 성운 생성 때 쓴다).
/// 맵 상위 [visibleCount] 개 안에서만 거르던 것을 고쳤다(Figma `353:217832` 「행성 검색으로 대상 행성 탐색」).
/// ponytail: 접두 일치만 — 중간 글자 일치가 필요하면 검색 색인(n-gram)을 서버에 둔다.
@override
Future<List<PlanetNode>> search(String query) async {
final q = query.trim().toLowerCase();
if (q.isEmpty) return const [];
final uid = _backend.requireUid;
final db = _backend.db;
final user = (await db.doc('users/$uid').get()).data() ?? const <String, dynamic>{};
final myFandomId = user.strOr('primaryFandomId', user.strOr('fandomId'));
final names = await db
.collection('fandomNames')
.where(FieldPath.documentId, isGreaterThanOrEqualTo: q)
.where(FieldPath.documentId, isLessThan: '$q\uf8ff')
.limit(20)
.get();
final ids = {
for (final d in names.docs)
if (d.data()['fandomId'] case final String id when id.isNotEmpty) id,
};
final docs = await Future.wait([for (final id in ids) db.doc('fandoms/$id').get()]);
return [
for (final doc in docs)
if (doc.data() case final data?)
_node(doc.id, data, 0, myFandomId, ranked: false),
];
}
PlanetNode _node(
String id,
Map<String, dynamic> data,