save message drafts (until cwtch close)
continuous-integration/drone/pr Build was killed Details

This commit is contained in:
erinn 2022-08-26 14:34:33 -07:00
parent 93284708e0
commit cac2064731
2 changed files with 13 additions and 2 deletions

View File

@ -57,6 +57,7 @@ class ContactInfoState extends ChangeNotifier {
late bool _pinned;
String? _acnCircuit;
String? _messageDraft;
ContactInfoState(this.profileOnion, this.identifier, this.onion,
{nickname = "",
@ -93,12 +94,14 @@ class ContactInfoState extends ChangeNotifier {
keys = Map<String, GlobalKey<MessageRowState>>();
}
String get nickname => this._nickname;
String get nickname => this._nickname + (this._messageDraft != null && this._messageDraft != "" ? "*" : "");
String get savePeerHistory => this._savePeerHistory;
String? get acnCircuit => this._acnCircuit;
String? get messageDraft => this._messageDraft;
set acnCircuit(String? acnCircuit) {
this._acnCircuit = acnCircuit;
notifyListeners();
@ -152,6 +155,11 @@ class ContactInfoState extends ChangeNotifier {
notifyListeners();
}
set messageDraft(String? newVal) {
this._messageDraft = newVal;
notifyListeners();
}
void selected() {
this._newMarkerMsgIndex = this._unreadMessages - 1;
this._unreadMessages = 0;

View File

@ -41,7 +41,7 @@ class MessageView extends StatefulWidget {
}
class _MessageViewState extends State<MessageView> {
final ctrlrCompose = TextEditingController();
var ctrlrCompose = TextEditingController();
final focusNode = FocusNode();
int selectedContact = -1;
ItemPositionsListener scrollListener = ItemPositionsListener.create();
@ -65,6 +65,7 @@ class _MessageViewState extends State<MessageView> {
showDown = false;
}
});
ctrlrCompose.text = Provider.of<ContactInfoState>(context).messageDraft ?? "";
super.initState();
}
@ -348,6 +349,7 @@ class _MessageViewState extends State<MessageView> {
);
}
Provider.of<ContactInfoState>(context).messageDraft = null;
ctrlrCompose.clear();
focusNode.requestFocus();
@ -545,6 +547,7 @@ class _MessageViewState extends State<MessageView> {
enabled: true, // always allow editing...
onChanged: (String x) {
Provider.of<ContactInfoState>(context).messageDraft = x;
setState(() {
// we need to force a rerender here to update the max length count
});