이클립스 흐름 — 배너 진입 · 이벤트 버튼 · 오버레이 · 방어 진행 표시 · 흔들기 감지 통일

This commit is contained in:
Sn-Kinos
2026-10-05 19:05:21 +09:00
parent be623d2e46
commit 576dcfbdfd
27 changed files with 1369 additions and 369 deletions
@@ -40,10 +40,16 @@ class FirestoreEclipseRepository implements EclipseRepository {
}
@override
Stream<EclipseState?> watch({String? fandomId, bool includeResults = false}) =>
(_watchers['${fandomId ?? ''}#$includeResults'] ??= SharedStream<EclipseState?>(
() => _openWatch(fandomId, includeResults),
)).stream;
Stream<EclipseState?> watch({
String? fandomId,
bool includeResults = false,
bool includeScheduled = false,
}) =>
(_watchers['${fandomId ?? ''}#$includeResults#$includeScheduled'] ??=
SharedStream<EclipseState?>(
() => _openWatch(fandomId, includeResults, includeScheduled),
))
.stream;
@override
Stream<List<LiveEvent>> liveEvents({String? fandomId, int limit = 20}) =>
@@ -54,6 +60,7 @@ class FirestoreEclipseRepository implements EclipseRepository {
Stream<EclipseState?> _openWatch(
String? fandomId,
bool includeResults,
bool includeScheduled,
) => Stream.fromFuture(_fandomId(fandomId)).asyncExpand((id) {
if (id.isEmpty) return Stream<EclipseState?>.value(null);
return Stream<EclipseState?>.multi((out) {
@@ -62,7 +69,11 @@ class FirestoreEclipseRepository implements EclipseRepository {
var generation = 0;
final eventsSub = _backend.db
.collection('fandoms/$id/eclipseRounds')
.where('status', whereIn: includeResults ? ['active', 'ended', 'cancelled'] : ['active'])
.where('status', whereIn: [
if (includeScheduled) 'scheduled',
'active',
if (includeResults) ...['ended', 'cancelled'],
])
.orderBy('startAt', descending: true)
.limit(1)
.snapshots(includeMetadataChanges: true)
@@ -169,6 +180,7 @@ class FirestoreEclipseRepository implements EclipseRepository {
return (acc.$1 + d.intOr('qualifiedParticipants'), acc.$2 + d.intOr('defenseCount'));
});
final endsAt = data['endsAt'];
final startAt = data['startAt'];
return EclipseState(
fandomId: fandomId,
eclipseId: eclipseId,
@@ -186,6 +198,8 @@ class FirestoreEclipseRepository implements EclipseRepository {
'cancelled_error' => EclipseResult.cancelled,
_ => null,
},
startAt: startAt is Timestamp ? startAt.toDate() : null,
scheduled: data['status'] == 'scheduled',
endsAt: endsAt is Timestamp ? endsAt.toDate() : null,
);
}