fixed countdown wrap, css rgba colors, stale create-link gate and wired up reply drafts in talk
This commit is contained in:
@@ -44,6 +44,7 @@ class _ChatTextfieldState extends State<ChatTextfield> {
|
||||
final AsyncActionController _sendController = AsyncActionController();
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
final GlobalKey _sizeKey = GlobalKey();
|
||||
late final StreamSubscription<void> _replySubscription;
|
||||
String? _sendError;
|
||||
|
||||
/// Publishes the input bar's measured height so the downloads chip floats
|
||||
@@ -114,13 +115,20 @@ class _ChatTextfieldState extends State<ChatTextfield> {
|
||||
super.initState();
|
||||
settings = context.read<SettingsCubit>();
|
||||
_loadDraft();
|
||||
final draftReply = settings
|
||||
.val()
|
||||
.talkSettings
|
||||
.draftReplies[widget.sendToToken];
|
||||
if (draftReply != null) {
|
||||
context.read<ChatBloc>().setReferenceMessageId(draftReply);
|
||||
_replySubscription = context.read<ChatBloc>().stream.listen(
|
||||
(state) => _persistPickedReply(state.data),
|
||||
);
|
||||
}
|
||||
|
||||
/// Clearing is handled where it happens (send, dismiss); the bloc also
|
||||
/// drops the reference on every room switch, which must not erase the draft.
|
||||
void _persistPickedReply(ChatState? chatState) {
|
||||
final id = chatState?.referenceMessageId;
|
||||
if (id == null || chatState!.currentToken != widget.sendToToken) return;
|
||||
if (settings.val().talkSettings.draftReplies[widget.sendToToken] == id) {
|
||||
return;
|
||||
}
|
||||
_setDraftReply(id);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -137,8 +145,12 @@ class _ChatTextfieldState extends State<ChatTextfield> {
|
||||
/// so doing this per build would drop the cursor position, any active text
|
||||
/// selection and a running IME composition on every chat update.
|
||||
void _loadDraft() {
|
||||
_textBoxController.text =
|
||||
settings.val().talkSettings.drafts[widget.sendToToken] ?? '';
|
||||
final talkSettings = settings.val().talkSettings;
|
||||
_textBoxController.text = talkSettings.drafts[widget.sendToToken] ?? '';
|
||||
final draftReply = talkSettings.draftReplies[widget.sendToToken];
|
||||
if (draftReply != null) {
|
||||
context.read<ChatBloc>().setReferenceMessageId(draftReply);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -148,6 +160,7 @@ class _ChatTextfieldState extends State<ChatTextfield> {
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) => downloadChipBottomObstruction.value = 0,
|
||||
);
|
||||
unawaited(_replySubscription.cancel());
|
||||
_sendController.dispose();
|
||||
_focusNode.dispose();
|
||||
super.dispose();
|
||||
|
||||
Reference in New Issue
Block a user