Merge pull request #347 from twonlyapp/dev

Dev
This commit is contained in:
Tobi 2025-12-22 15:05:43 +01:00 committed by GitHub
commit 333f033993
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 42 additions and 8 deletions

View file

@ -20,6 +20,7 @@
"registerUsernameSlogan": "Bitte wähle einen Benutzernamen, damit dich andere finden können!",
"registerUsernameDecoration": "Benutzername",
"registerUsernameLimits": "Der Benutzername muss mindestens 3 Zeichen lang sein.",
"registerProofOfWorkFailed": "Beim Captcha-Test gab es ein Problem. Bitte versuche es erneut.",
"registerSubmitButton": "Jetzt registrieren!",
"registerTwonlyCodeText": "Hast du einen twonly-Code erhalten? Dann löse ihn entweder direkt hier oder später ein!",
"registerTwonlyCodeLabel": "twonly-Code",

View file

@ -20,6 +20,7 @@
"registerUsernameSlogan": "Please select a username so others can find you!",
"registerUsernameDecoration": "Username",
"registerUsernameLimits": "Your username must be at least 3 characters long.",
"registerProofOfWorkFailed": "There was an issue with the captcha test. Please try again.",
"registerSubmitButton": "Register now!",
"registerTwonlyCodeText": "Have you received a twonly code? Then redeem it either directly here or later!",
"registerTwonlyCodeLabel": "twonly-Code",

View file

@ -218,6 +218,12 @@ abstract class AppLocalizations {
/// **'Your username must be at least 3 characters long.'**
String get registerUsernameLimits;
/// No description provided for @registerProofOfWorkFailed.
///
/// In en, this message translates to:
/// **'There was an issue with the captcha test. Please try again.'**
String get registerProofOfWorkFailed;
/// No description provided for @registerSubmitButton.
///
/// In en, this message translates to:

View file

@ -79,6 +79,10 @@ class AppLocalizationsDe extends AppLocalizations {
String get registerUsernameLimits =>
'Der Benutzername muss mindestens 3 Zeichen lang sein.';
@override
String get registerProofOfWorkFailed =>
'Beim Captcha-Test gab es ein Problem. Bitte versuche es erneut.';
@override
String get registerSubmitButton => 'Jetzt registrieren!';

View file

@ -78,6 +78,10 @@ class AppLocalizationsEn extends AppLocalizations {
String get registerUsernameLimits =>
'Your username must be at least 3 characters long.';
@override
String get registerProofOfWorkFailed =>
'There was an issue with the captcha test. Please try again.';
@override
String get registerSubmitButton => 'Register now!';

View file

@ -178,7 +178,8 @@ class PurchasesProvider with ChangeNotifier, DiagnosticableTreeMixin {
for (var i = 0; i < 100; i++) {
if (apiService.isAuthenticated) {
Log.info(
'current user does not have a sub: ${purchaseDetails.productID}');
'current user does not have a sub: ${purchaseDetails.productID}',
);
await _verifyPurchase(purchaseDetails);
break;
}

View file

@ -364,5 +364,6 @@ String getAvatarSvg(Uint8List avatarSvgCompressed) {
void printWrapped(String text) {
final pattern = RegExp('.{1,800}'); // 800 is the size of each chunk
// ignore: avoid_print
pattern.allMatches(text).forEach((match) => print(match.group(0)));
}

View file

@ -169,7 +169,7 @@ class _SearchUsernameView extends State<AddNewUserView> {
},
inputFormatters: [
LengthLimitingTextInputFormatter(12),
FilteringTextInputFormatter.allow(RegExp('[a-z0-9A-Z]')),
FilteringTextInputFormatter.allow(RegExp('[a-z0-9A-Z._]')),
],
controller: searchUserName,
decoration:

View file

@ -40,6 +40,7 @@ class _RegisterViewState extends State<RegisterView> {
bool _isTryingToRegister = false;
bool _isValidUserName = false;
bool _showUserNameError = false;
bool _showProofOfWorkError = false;
late Future<int>? proofOfWork;
@ -63,6 +64,7 @@ class _RegisterViewState extends State<RegisterView> {
setState(() {
_isTryingToRegister = true;
_showUserNameError = false;
_showProofOfWorkError = false;
});
late int proof;
@ -93,6 +95,7 @@ class _RegisterViewState extends State<RegisterView> {
Log.info('Got user_id ${res.value} from server');
userId = res.value.userid.toInt() as int;
} else {
proofOfWork = null;
if (res.error == ErrorCode.RegistrationDisabled) {
_registrationDisabled = true;
return;
@ -103,9 +106,12 @@ class _RegisterViewState extends State<RegisterView> {
return createNewUser();
}
if (res.error == ErrorCode.InvalidProofOfWork) {
Log.error('Proof of Work is invalid. Try again.');
await deleteLocalUserData();
return createNewUser();
setState(() {
_showProofOfWorkError = true;
_isTryingToRegister = false;
});
return;
}
if (mounted) {
setState(() {
@ -232,7 +238,7 @@ class _RegisterViewState extends State<RegisterView> {
},
inputFormatters: [
LengthLimitingTextInputFormatter(12),
FilteringTextInputFormatter.allow(RegExp('[a-z0-9A-Z]')),
FilteringTextInputFormatter.allow(RegExp('[a-z0-9A-Z._]')),
],
style: const TextStyle(fontSize: 17),
decoration: getInputDecoration(
@ -248,7 +254,17 @@ class _RegisterViewState extends State<RegisterView> {
),
textAlign: TextAlign.center,
),
const SizedBox(height: 30),
const SizedBox(height: 10),
Text(
context.lang.registerProofOfWorkFailed,
style: TextStyle(
color:
_showProofOfWorkError ? Colors.red : Colors.transparent,
fontSize: 12,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 10),
Column(
children: [
FilledButton.icon(

View file

@ -146,7 +146,7 @@ class _ProfileViewState extends State<ProfileView> {
maxLength: 12,
inputFormatters: [
LengthLimitingTextInputFormatter(12),
FilteringTextInputFormatter.allow(RegExp('[a-z0-9A-Z]')),
FilteringTextInputFormatter.allow(RegExp('[a-z0-9A-Z._]')),
],
);
if (context.mounted && username != null && username != '') {

View file

@ -98,7 +98,7 @@ class _SettingsMainViewState extends State<SettingsMainView> {
},
icon: const FaIcon(FontAwesomeIcons.qrcode),
),
)
),
],
),
),