save message drafts (until cwtch close) #529
|
@ -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;
|
||||
|
|
|
@ -65,6 +65,7 @@ class _MessageViewState extends State<MessageView> {
|
|||
showDown = false;
|
||||
}
|
||||
});
|
||||
ctrlrCompose.text = Provider.of<ContactInfoState>(context, listen: false).messageDraft ?? "";
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
@ -348,6 +349,7 @@ class _MessageViewState extends State<MessageView> {
|
|||
);
|
||||
}
|
||||
|
||||
Provider.of<ContactInfoState>(context, listen: false).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, listen: false).messageDraft = x;
|
||||
setState(() {
|
||||
// we need to force a rerender here to update the max length count
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue