saving message references in draft

This commit is contained in:
2024-05-10 22:27:24 +02:00
parent 81f5b662b7
commit 0f84257eba
6 changed files with 34 additions and 14 deletions

View File

@ -279,7 +279,7 @@ class _ChatBubbleState extends State<ChatBubble> with SingleTickerProviderStateM
_position = const Offset(0, 0);
});
if(widget.bubbleData.isReplyable) {
Provider.of<ChatProps>(context, listen: false).setReferenceMessageId(widget.bubbleData.id);
Provider.of<ChatProps>(context, listen: false).setReferenceMessageId(widget.bubbleData.id, context, widget.chatData.token);
}
},
onLongPress: showOptionsDialog,

View File

@ -1,6 +1,5 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:nextcloud/nextcloud.dart';
import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart';
@ -81,7 +80,8 @@ class _ChatTextfieldState extends State<ChatTextfield> {
void initState() {
super.initState();
settings = Provider.of<SettingsProvider>(context, listen: false);
Provider.of<ChatProps>(context, listen: false).referenceMessageId = null;
Provider.of<ChatProps>(context, listen: false).unsafeInternalSetReferenceMessageId =
settings.val().talkSettings.draftReplies[widget.sendToToken];
}
@override
@ -99,8 +99,8 @@ class _ChatTextfieldState extends State<ChatTextfield> {
children: [
Consumer<ChatProps>(
builder: (context, data, child) {
if(data.referenceMessageId != null) {
var referenceMessage = data.getChatResponse.sortByTimestamp().where((element) => element.id == data.referenceMessageId).last;
if(data.getReferenceMessageId != null) {
var referenceMessage = data.getChatResponse.sortByTimestamp().where((element) => element.id == data.getReferenceMessageId).last;
return Row(
children: [
Expanded(
@ -111,7 +111,7 @@ class _ChatTextfieldState extends State<ChatTextfield> {
),
),
IconButton(
onPressed: () => data.setReferenceMessageId(null),
onPressed: () => data.setReferenceMessageId(null, context, widget.sendToToken),
icon: const Icon(Icons.close_outlined),
padding: const EdgeInsets.only(left: 0),
),
@ -194,7 +194,7 @@ class _ChatTextfieldState extends State<ChatTextfield> {
const SizedBox(width: 15),
FloatingActionButton(
mini: true,
onPressed: (){
onPressed: () {
if(_textBoxController.text.isEmpty) return;
if(isLoading) return;
@ -203,7 +203,7 @@ class _ChatTextfieldState extends State<ChatTextfield> {
});
SendMessage(widget.sendToToken, SendMessageParams(
_textBoxController.text,
replyTo: Provider.of<ChatProps>(context, listen: false).referenceMessageId.toString()
replyTo: Provider.of<ChatProps>(context, listen: false).getReferenceMessageId.toString()
)).run().then((value) {
_query();
setState(() {
@ -211,8 +211,8 @@ class _ChatTextfieldState extends State<ChatTextfield> {
});
_textBoxController.text = '';
setDraft('');
Provider.of<ChatProps>(context, listen: false).setReferenceMessageId(null, context, widget.sendToToken);
});
Provider.of<ChatProps>(context, listen: false).referenceMessageId = null;
},
backgroundColor: Theme.of(context).primaryColor,
elevation: 5,