mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-04-22 14:32:53 +00:00
Improved: Username change error handling
This commit is contained in:
parent
60e5a5c7cc
commit
492ad835ba
2 changed files with 18 additions and 3 deletions
|
|
@ -3,6 +3,7 @@
|
|||
## 0.1.6
|
||||
|
||||
- Improved: Show input indicator in the chat overview as well
|
||||
- Improved: Username change error handling
|
||||
- Fix: Phantom push notification
|
||||
- Fix: Start in chat, if configured
|
||||
- Fix: Smaller UI fixes
|
||||
|
|
|
|||
|
|
@ -57,14 +57,28 @@ class _ProfileViewState extends State<ProfileView> {
|
|||
}
|
||||
|
||||
Future<void> _updateUsername(String username) async {
|
||||
final result = await apiService.changeUsername(username);
|
||||
var filteredUsername = username.replaceAll(
|
||||
RegExp('[^a-zA-Z0-9._]'),
|
||||
'',
|
||||
);
|
||||
|
||||
if (filteredUsername.length > 12) {
|
||||
filteredUsername = filteredUsername.substring(0, 12);
|
||||
}
|
||||
|
||||
final result = await apiService.changeUsername(filteredUsername);
|
||||
if (result.isError) {
|
||||
if (!mounted) return;
|
||||
|
||||
if (result.error == ErrorCode.UsernameAlreadyTaken) {
|
||||
if (result.error == ErrorCode.UsernameAlreadyTaken ||
|
||||
result.error == ErrorCode.UsernameNotValid) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(context.lang.errorUsernameAlreadyTaken),
|
||||
content: Text(
|
||||
result.error == ErrorCode.UsernameAlreadyTaken
|
||||
? context.lang.errorUsernameAlreadyTaken
|
||||
: context.lang.errorUsernameNotValid,
|
||||
),
|
||||
duration: const Duration(seconds: 3),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue