Merge pull request 'save message drafts (until cwtch close)' (#529) from savedrafts into trunk
continuous-integration/drone/push Build is passing Details

Reviewed-on: #529
This commit is contained in:
Sarah Jamie Lewis 2022-08-26 21:58:18 +00:00
commit 7edc46743f
2 changed files with 12 additions and 1 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

@ -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
});