submitName method
Submits the name field.
Implementation
Future<void> submitName() async {
name.focus.unfocus();
if (name.text == chat?.chat.value.name?.val) {
name.unsubmit();
nameEditing.value = false;
return;
}
ChatName? chatName;
try {
chatName = name.text.isEmpty ? null : ChatName(name.text);
} on FormatException catch (_) {
name.status.value = RxStatus.empty();
name.error.value = 'err_incorrect_input'.l10n;
name.unsubmit();
return;
}
if (name.error.value == null || name.resubmitOnError.isTrue) {
name.status.value = RxStatus.loading();
name.editable.value = false;
try {
await _chatService.renameChat(chat!.chat.value.id, chatName);
name.error.value = null;
nameEditing.value = false;
name.unsubmit();
} on RenameChatException catch (e) {
name.error.value = e.toString();
} catch (e) {
name.resubmitOnError.value = true;
name.error.value = 'err_data_transfer'.l10n;
rethrow;
} finally {
name.status.value = RxStatus.empty();
name.editable.value = true;
}
}
}