Skip to content

Commit

Permalink
feat(neon_framework): Enable viewing and editing profile properties
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Aug 3, 2024
1 parent 3228df6 commit ad33020
Show file tree
Hide file tree
Showing 10 changed files with 1,027 additions and 60 deletions.
27 changes: 27 additions & 0 deletions packages/neon_framework/lib/l10n/en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,33 @@
}
}
},
"accountOptionsCategoryProfile": "Profile",
"accountOptionsProfileDisplayNameLabel": "Full name",
"accountOptionsProfileDisplayNameHint": "Your full name",
"accountOptionsProfileEmailLabel": "Email",
"accountOptionsProfileEmailHint": "Primary email for password reset and notifications",
"accountOptionsProfilePhoneLabel": "Phone number",
"accountOptionsProfilePhoneHint": "Your phone number",
"accountOptionsProfileAddressLabel": "Location",
"accountOptionsProfileAddressHint": "Your city",
"accountOptionsProfileWebsiteLabel": "Website",
"accountOptionsProfileWebsiteHint": "Your website",
"accountOptionsProfileTwitterLabel": "X (formerly Twitter)",
"accountOptionsProfileTwitterHint": "Your X (formerly Twitter) handle",
"accountOptionsProfileFediverseLabel": "Fediverse (e.g. Mastodon)",
"accountOptionsProfileFediverseHint": "Your handle",
"accountOptionsProfileOrganisationLabel": "Organisation",
"accountOptionsProfileOrganisationHint": "Your organisation",
"accountOptionsProfileRoleLabel": "Role",
"accountOptionsProfileRoleHint": "Your role",
"accountOptionsProfileHeadlineLabel": "Headline",
"accountOptionsProfileHeadlineHint": "Your headline",
"accountOptionsProfileBiographyLabel": "About",
"accountOptionsProfileBiographyHint": "Your biography",
"accountOptionsProfileScopePrivate": "Only visible to people matched via phone number integration through Talk on mobile",
"accountOptionsProfileScopeLocal": "Only visible to people on this instance and guests",
"accountOptionsProfileScopeFederated": "Only synchronize to trusted servers",
"accountOptionsProfileScopePublished": "Synchronize to trusted servers and the global and public address book",
"accountOptionsInitialApp": "App to show initially",
"accountOptionsAutomatic": "Automatic",
"licenses": "Licenses",
Expand Down
162 changes: 162 additions & 0 deletions packages/neon_framework/lib/l10n/localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,168 @@ abstract class NeonLocalizations {
/// **'{used} used of {total} ({relative}%)'**
String accountOptionsQuotaUsedOf(String used, String total, String relative);

/// No description provided for @accountOptionsCategoryProfile.
///
/// In en, this message translates to:
/// **'Profile'**
String get accountOptionsCategoryProfile;

/// No description provided for @accountOptionsProfileDisplayNameLabel.
///
/// In en, this message translates to:
/// **'Full name'**
String get accountOptionsProfileDisplayNameLabel;

/// No description provided for @accountOptionsProfileDisplayNameHint.
///
/// In en, this message translates to:
/// **'Your full name'**
String get accountOptionsProfileDisplayNameHint;

/// No description provided for @accountOptionsProfileEmailLabel.
///
/// In en, this message translates to:
/// **'Email'**
String get accountOptionsProfileEmailLabel;

/// No description provided for @accountOptionsProfileEmailHint.
///
/// In en, this message translates to:
/// **'Primary email for password reset and notifications'**
String get accountOptionsProfileEmailHint;

/// No description provided for @accountOptionsProfilePhoneLabel.
///
/// In en, this message translates to:
/// **'Phone number'**
String get accountOptionsProfilePhoneLabel;

/// No description provided for @accountOptionsProfilePhoneHint.
///
/// In en, this message translates to:
/// **'Your phone number'**
String get accountOptionsProfilePhoneHint;

/// No description provided for @accountOptionsProfileAddressLabel.
///
/// In en, this message translates to:
/// **'Location'**
String get accountOptionsProfileAddressLabel;

/// No description provided for @accountOptionsProfileAddressHint.
///
/// In en, this message translates to:
/// **'Your city'**
String get accountOptionsProfileAddressHint;

/// No description provided for @accountOptionsProfileWebsiteLabel.
///
/// In en, this message translates to:
/// **'Website'**
String get accountOptionsProfileWebsiteLabel;

/// No description provided for @accountOptionsProfileWebsiteHint.
///
/// In en, this message translates to:
/// **'Your website'**
String get accountOptionsProfileWebsiteHint;

/// No description provided for @accountOptionsProfileTwitterLabel.
///
/// In en, this message translates to:
/// **'X (formerly Twitter)'**
String get accountOptionsProfileTwitterLabel;

/// No description provided for @accountOptionsProfileTwitterHint.
///
/// In en, this message translates to:
/// **'Your X (formerly Twitter) handle'**
String get accountOptionsProfileTwitterHint;

/// No description provided for @accountOptionsProfileFediverseLabel.
///
/// In en, this message translates to:
/// **'Fediverse (e.g. Mastodon)'**
String get accountOptionsProfileFediverseLabel;

/// No description provided for @accountOptionsProfileFediverseHint.
///
/// In en, this message translates to:
/// **'Your handle'**
String get accountOptionsProfileFediverseHint;

/// No description provided for @accountOptionsProfileOrganisationLabel.
///
/// In en, this message translates to:
/// **'Organisation'**
String get accountOptionsProfileOrganisationLabel;

/// No description provided for @accountOptionsProfileOrganisationHint.
///
/// In en, this message translates to:
/// **'Your organisation'**
String get accountOptionsProfileOrganisationHint;

/// No description provided for @accountOptionsProfileRoleLabel.
///
/// In en, this message translates to:
/// **'Role'**
String get accountOptionsProfileRoleLabel;

/// No description provided for @accountOptionsProfileRoleHint.
///
/// In en, this message translates to:
/// **'Your role'**
String get accountOptionsProfileRoleHint;

/// No description provided for @accountOptionsProfileHeadlineLabel.
///
/// In en, this message translates to:
/// **'Headline'**
String get accountOptionsProfileHeadlineLabel;

/// No description provided for @accountOptionsProfileHeadlineHint.
///
/// In en, this message translates to:
/// **'Your headline'**
String get accountOptionsProfileHeadlineHint;

/// No description provided for @accountOptionsProfileBiographyLabel.
///
/// In en, this message translates to:
/// **'About'**
String get accountOptionsProfileBiographyLabel;

/// No description provided for @accountOptionsProfileBiographyHint.
///
/// In en, this message translates to:
/// **'Your biography'**
String get accountOptionsProfileBiographyHint;

/// No description provided for @accountOptionsProfileScopePrivate.
///
/// In en, this message translates to:
/// **'Only visible to people matched via phone number integration through Talk on mobile'**
String get accountOptionsProfileScopePrivate;

/// No description provided for @accountOptionsProfileScopeLocal.
///
/// In en, this message translates to:
/// **'Only visible to people on this instance and guests'**
String get accountOptionsProfileScopeLocal;

/// No description provided for @accountOptionsProfileScopeFederated.
///
/// In en, this message translates to:
/// **'Only synchronize to trusted servers'**
String get accountOptionsProfileScopeFederated;

/// No description provided for @accountOptionsProfileScopePublished.
///
/// In en, this message translates to:
/// **'Synchronize to trusted servers and the global and public address book'**
String get accountOptionsProfileScopePublished;

/// No description provided for @accountOptionsInitialApp.
///
/// In en, this message translates to:
Expand Down
83 changes: 83 additions & 0 deletions packages/neon_framework/lib/l10n/localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,89 @@ class NeonLocalizationsEn extends NeonLocalizations {
return '$used used of $total ($relative%)';
}

@override
String get accountOptionsCategoryProfile => 'Profile';

@override
String get accountOptionsProfileDisplayNameLabel => 'Full name';

@override
String get accountOptionsProfileDisplayNameHint => 'Your full name';

@override
String get accountOptionsProfileEmailLabel => 'Email';

@override
String get accountOptionsProfileEmailHint => 'Primary email for password reset and notifications';

@override
String get accountOptionsProfilePhoneLabel => 'Phone number';

@override
String get accountOptionsProfilePhoneHint => 'Your phone number';

@override
String get accountOptionsProfileAddressLabel => 'Location';

@override
String get accountOptionsProfileAddressHint => 'Your city';

@override
String get accountOptionsProfileWebsiteLabel => 'Website';

@override
String get accountOptionsProfileWebsiteHint => 'Your website';

@override
String get accountOptionsProfileTwitterLabel => 'X (formerly Twitter)';

@override
String get accountOptionsProfileTwitterHint => 'Your X (formerly Twitter) handle';

@override
String get accountOptionsProfileFediverseLabel => 'Fediverse (e.g. Mastodon)';

@override
String get accountOptionsProfileFediverseHint => 'Your handle';

@override
String get accountOptionsProfileOrganisationLabel => 'Organisation';

@override
String get accountOptionsProfileOrganisationHint => 'Your organisation';

@override
String get accountOptionsProfileRoleLabel => 'Role';

@override
String get accountOptionsProfileRoleHint => 'Your role';

@override
String get accountOptionsProfileHeadlineLabel => 'Headline';

@override
String get accountOptionsProfileHeadlineHint => 'Your headline';

@override
String get accountOptionsProfileBiographyLabel => 'About';

@override
String get accountOptionsProfileBiographyHint => 'Your biography';

@override
String get accountOptionsProfileScopePrivate =>
'Only visible to people matched via phone number integration through Talk on mobile';

@override
String get accountOptionsProfileScopeLocal => 'Only visible to people on this instance and guests';

@override
String get accountOptionsProfileScopeFederated => 'Only synchronize to trusted servers';

@override
String get accountOptionsProfileScopePublished =>
'Synchronize to trusted servers and the global and public address book';

@override
String get accountOptionsInitialApp => 'App to show initially';

Expand Down
33 changes: 33 additions & 0 deletions packages/neon_framework/lib/src/blocs/user_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ abstract class UserDetailsBloc implements InteractiveBloc {

/// Contains the user details.
BehaviorSubject<Result<provisioning_api.UserDetails>> get userDetails;

/// Updates a property of the [userDetails].
void updateProperty(String key, String value);
}

class _UserDetailsBloc extends InteractiveBloc implements UserDetailsBloc {
Expand Down Expand Up @@ -54,4 +57,34 @@ class _UserDetailsBloc extends InteractiveBloc implements UserDetailsBloc {
unwrap: (response) => response.body.ocs.data,
);
}

@override
Future<void> updateProperty(String key, String value) async {
await wrapAction(
() async {
userDetails.add(userDetails.valueOrNull?.asLoading() ?? Result.loading());

await account.client.provisioningApi.users.editUser(
userId: account.username,
$body: provisioning_api.UsersEditUserRequestApplicationJson(
(b) => b
..key = key
..value = value,
),
);

var data = userDetails.valueOrNull?.data;
if (data == null) {
return;
}

final raw = data.toJson();
raw[key] = value;
data = provisioning_api.UserDetails.fromJson(raw);

userDetails.add(Result.success(data));
},
refresh: () async {},
);
}
}
Loading

0 comments on commit ad33020

Please sign in to comment.