forked from Foxyz/sync_replay_project
Restructure step 0: Connection extracted from the coordinator
Connection owns the socket lifecycle, connect/dial with epochs, reconnect, the clock offset, diagnostics upload and a sealed ConnState signal; the hello is built by an injectable builder, the resume token stays private, and the reconnect delay and silence limit are parameters. The coordinator maps ConnState to the same health texts and keeps the reconnect restore and drop handling (step 1 replaces them). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a52133b313
commit
eac45746ce
13 files changed
+780
-368
No files matched your search
@@ -43,7 +43,7 @@ class QueueController {
|
||||
QueueController(this.coord);
|
||||
|
||||
/// Queued items' pictures by hash, from `/i/`.
|
||||
late final PictureCache thumbs = PictureCache(coord.sync,
|
||||
late final PictureCache thumbs = PictureCache(coord.connection.client,
|
||||
route: 'i', keep: RelayConstants.maxQueueItems + 8, live: (s) => [for (final q in s.queue) q.thumb]);
|
||||
|
||||
/// Up next, in order (empty when nothing is queued or not in a server).
|
||||
@@ -77,12 +77,12 @@ class QueueController {
|
||||
String _continuationFor = '';
|
||||
final _random = Random.secure();
|
||||
|
||||
String get _me => coord.sync.memberId;
|
||||
String get _me => coord.connection.memberId;
|
||||
|
||||
void attach() {
|
||||
if (_attached) return;
|
||||
_attached = true;
|
||||
coord.sync.states.listen(_onState);
|
||||
coord.connection.states.listen(_onState);
|
||||
effect(() {
|
||||
final next = coord.nextEpisode.value;
|
||||
final plan = coord.jellyfinPlan.value;
|
||||
@@ -121,7 +121,7 @@ class QueueController {
|
||||
final item = built.item;
|
||||
if (item.key.isNotEmpty) _local[item.key] = (pick: pick, at: DateTime.now());
|
||||
final thumb = built.thumb;
|
||||
coord.sync.sendQueue(QueueIntent.add(item, next: next, thumb: thumb == null ? '' : base64Encode(thumb)));
|
||||
coord.connection.sendQueue(QueueIntent.add(item, next: next, thumb: thumb == null ? '' : base64Encode(thumb)));
|
||||
coord.notify(AddedToUpNext(item.title));
|
||||
return null;
|
||||
}
|
||||
@@ -288,12 +288,12 @@ class QueueController {
|
||||
|
||||
void move(String id, int to) {
|
||||
coord.markInput();
|
||||
coord.sync.sendQueue(QueueIntent.move(id, to));
|
||||
coord.connection.sendQueue(QueueIntent.move(id, to));
|
||||
}
|
||||
|
||||
void remove(String id) {
|
||||
coord.markInput();
|
||||
coord.sync.sendQueue(QueueIntent.remove(id));
|
||||
coord.connection.sendQueue(QueueIntent.remove(id));
|
||||
}
|
||||
|
||||
/// Plays [id] now: this app puts it up when it is the one that can,
|
||||
@@ -306,7 +306,7 @@ class QueueController {
|
||||
if (queuePerformer(item, r.members).id == _me) {
|
||||
_perform(item);
|
||||
} else {
|
||||
coord.sync.sendQueue(QueueIntent.play(id));
|
||||
coord.connection.sendQueue(QueueIntent.play(id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ class QueueController {
|
||||
if (perf.id == null) {
|
||||
final why = perf.why;
|
||||
if (why != null && queueJanitor(r.members) == _me && _skipped.add(item.id)) {
|
||||
coord.sync.sendQueue(QueueIntent.remove(item.id, why: why));
|
||||
coord.connection.sendQueue(QueueIntent.remove(item.id, why: why));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -461,7 +461,7 @@ class QueueController {
|
||||
}
|
||||
if (error != null) {
|
||||
debugPrint('queue: ${item.id} cannot go up: $error');
|
||||
coord.sync.sendQueue(QueueIntent.remove(item.id, why: "couldn't play it ($error)"));
|
||||
coord.connection.sendQueue(QueueIntent.remove(item.id, why: "couldn't play it ($error)"));
|
||||
}
|
||||
}());
|
||||
}
|
||||
@@ -615,7 +615,7 @@ class QueueController {
|
||||
final head = r?.queue.firstOrNull;
|
||||
final relay = head?.media.relay;
|
||||
if (r == null || head == null || relay == null || relay.fetch) return;
|
||||
final key = '${head.id}|${coord.sync.token}';
|
||||
final key = '${head.id}|${coord.connection.token}';
|
||||
if (key == _fedWarm) return;
|
||||
switch (head.how) {
|
||||
case QueueHow.through:
|
||||
|
||||
@@ -344,7 +344,7 @@ class UpNextPreview extends StatelessWidget {
|
||||
const picture = _width - 2 * _pad;
|
||||
if (item != null) {
|
||||
final r = queue.coord.serverState.value;
|
||||
final selfId = queue.coord.sync.memberId;
|
||||
final selfId = queue.coord.connection.memberId;
|
||||
final more = queue.items.value.length - 1;
|
||||
final ready = warm?.id == item.id ? warm!.state : null;
|
||||
return Column(
|
||||
@@ -449,7 +449,7 @@ class _KeyCap extends StatelessWidget {
|
||||
String? performerNote(QueueController queue, QueueItem item, StateBroadcast? r) {
|
||||
if (r == null) return null;
|
||||
final id = queuePerformer(item, r.members).id;
|
||||
if (id == null || id == queue.coord.sync.memberId) return null;
|
||||
if (id == null || id == queue.coord.connection.memberId) return null;
|
||||
final name = r.members.where((m) => m.id == id).firstOrNull?.name;
|
||||
return name == null ? null : '$name puts it up';
|
||||
}
|
||||
@@ -841,7 +841,7 @@ class _QueuePanelState extends State<QueuePanel> {
|
||||
final cont = _q.shownContinuation.value;
|
||||
final warm = _q.warm.value;
|
||||
final r = _q.coord.serverState.value;
|
||||
final selfId = _q.coord.sync.memberId;
|
||||
final selfId = _q.coord.connection.memberId;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -1558,7 +1558,7 @@ class UpNextCard extends StatelessWidget {
|
||||
final item = c.item;
|
||||
final left = c.secondsLeft;
|
||||
final r = queue.coord.serverState.value;
|
||||
final selfId = queue.coord.sync.memberId;
|
||||
final selfId = queue.coord.connection.memberId;
|
||||
final waiting = left == null ? performerNote(queue, item, r) : null;
|
||||
return AppGlass(
|
||||
key: const ValueKey('up-next-card'),
|
||||
|
||||
Reference in new issue
Block a user