perf(learn): discussions and feedback show what the person does at once
In a discussion, accepting an answer (or none), hiding or showing a post and deleting one waited for the instance with every action disabled (busy). DiscussionBloc now shows the discussion as the action leaves it at once (Discussion.withAccepted, withPost, DiscussionPost.copyWith), the actions staying available, and puts it back as it was where the instance refuses (the refusal's snack bar as before) or can't be reached, then reads it anew. Answering, commenting and editing still wait, as what the instance makes of them is theirs to say. In the feedback inbox, a thread opened shows read at once, a failure to record it said to nobody (the next read shows the truth), and a decision (closing, reopening, hiding, showing, declining) shows at once and is put back with the failure's snack bar where it isn't written (FeedbackThread.seen, decided). Accepting a suggestion still waits, as it changes the author's content and can fail with SuggestionNotTaken. Whats-New: Accepting, hiding and deleting in discussions, and closing or declining feedback, show at once. Whats-New-De: Annehmen, Ausblenden und Löschen in Diskussionen sowie Schließen oder Ablehnen von Rückmeldungen zeigen sich sofort. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
891e9dfd75
commit
107e6f9913
2 changed files with 416 additions and 11 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:halkyon_editor/halkyon_editor.dart';
|
||||
import 'package:halkyon_learn_flutter/src/core/profile/public_person.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/discussion/data/discussion_gateway.dart';
|
||||
|
|
@ -17,6 +19,10 @@ class FakeDiscussionGateway({
|
|||
/// Thrown by every call while set: the instance can't be reached.
|
||||
Exception? fail;
|
||||
|
||||
/// While set, deleting, accepting and hiding wait for it to complete, so
|
||||
/// that a test sees what shows before the instance answers.
|
||||
Completer<void>? hold;
|
||||
|
||||
/// The questions, by id, with what is in them.
|
||||
final questions = <String, Discussion>{};
|
||||
|
||||
|
|
@ -232,12 +238,14 @@ class FakeDiscussionGateway({
|
|||
|
||||
@override
|
||||
Future<void> delete(String postId) async {
|
||||
await hold?.future;
|
||||
_failing();
|
||||
questions.remove(postId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> accept(String questionId, String? answerId) async {
|
||||
await hold?.future;
|
||||
_failing();
|
||||
final discussion = questions[questionId] ?? (throw DiscussionMissing());
|
||||
questions[questionId] = _with(
|
||||
|
|
@ -253,6 +261,7 @@ class FakeDiscussionGateway({
|
|||
|
||||
@override
|
||||
Future<void> hide(String postId, {required bool hidden}) async {
|
||||
await hold?.future;
|
||||
_failing();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
|
|
@ -18,6 +19,12 @@ class FakeFeedbackWriteGateway() implements FeedbackWriteGateway {
|
|||
/// The decisions written, by thread.
|
||||
final decisions = <({String threadId, FeedbackDecision decision})>[];
|
||||
|
||||
/// When set, writing a decision fails with it.
|
||||
Exception? failDecisions;
|
||||
|
||||
/// While set, writing a decision waits for it to complete.
|
||||
Completer<void>? holdDecisions;
|
||||
|
||||
@override
|
||||
Future<String> insertThread({
|
||||
required String publicationId,
|
||||
|
|
@ -40,7 +47,13 @@ class FakeFeedbackWriteGateway() implements FeedbackWriteGateway {
|
|||
Future<void> insertDecision(
|
||||
String threadId,
|
||||
FeedbackDecision decision,
|
||||
) async => decisions.add((threadId: threadId, decision: decision));
|
||||
) async {
|
||||
await holdDecisions?.future;
|
||||
if (failDecisions case final error?) {
|
||||
throw error;
|
||||
}
|
||||
decisions.add((threadId: threadId, decision: decision));
|
||||
}
|
||||
|
||||
static Map<String, Object?> _json(ByteData payload) =>
|
||||
jsonDecode(utf8.decode(Uint8List.sublistView(payload)))
|
||||
|
|
@ -62,6 +75,9 @@ class FakeFeedbackServerGateway({
|
|||
/// When set, every request fails with it.
|
||||
Exception? fail;
|
||||
|
||||
/// While set, marking a thread read waits for it to complete.
|
||||
Completer<void>? holdSeen;
|
||||
|
||||
/// Replaces what the instance gathers.
|
||||
set gathered(List<FeedbackThread> threads) => _threads = [...threads];
|
||||
|
||||
|
|
@ -95,6 +111,7 @@ class FakeFeedbackServerGateway({
|
|||
|
||||
@override
|
||||
Future<void> markSeen(String threadId) async {
|
||||
await holdSeen?.future;
|
||||
await _maybeFail();
|
||||
seen.add(threadId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue