< Summary

Class:DCL.MyAccount.MyProfileController
Assembly:MyAccountHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/MyAccountHUD/MyProfileController.cs
Covered lines:288
Uncovered lines:16
Coverable lines:304
Total lines:749
Line coverage:94.7% (288 of 304)
Covered branches:0
Total branches:0
Covered methods:37
Total methods:39
Method coverage:94.8% (37 of 39)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
MyProfileController(...)0%110100%
Dispose()0%110100%
OnKernelConfigChanged(...)0%110100%
OnMyAccountSectionVisibleChanged(...)0%2.52050%
OpenSection()0%110100%
RefreshContentLayout()0%330100%
CloseSection()0%2100%
LoadAndShowOwnedNamesAsync()0%8.838076.47%
RefreshNamesSectionStatus()0%110100%
OnNameEdited(...)0%3.583060%
OnNameSubmitted(...)0%4.434070%
<OnNameSubmitted()0%8.36060%
OnAboutDescriptionSubmitted(...)0%2.032080%
<OnAboutDescriptionSubmitted()0%3.213071.43%
ShowAboutDescription(...)0%110100%
IsValidUserName(...)0%220100%
OnOwnUserProfileUpdated(...)0%2.012087.5%
ShowLinks(...)0%550100%
GoFromClaimedToNonClaimName()0%2100%
OnClaimNameRequested()0%110100%
SplitUserName(...)0%770100%
OnAddLinkRequested(...)0%440100%
<OnAddLinkRequested()0%7.465053.85%
<OnRemoveLinkRequested()0%6.65060%
OnRemoveLinkRequested(...)0%110100%
ShowAdditionalInfoOptions(...)0%110100%
GetEmploymentStatusList()0%110100%
GetLanguageList()0%110100%
GetSexualOrientationList()0%110100%
GetRelationshipStatusList()0%110100%
GetPronounList()0%110100%
GetGenderList()0%110100%
GetCountryList()0%110100%
<SaveAdditionalInfo()0%3.583060%
SaveAdditionalInfo(...)0%110100%
ShowAdditionalInfoValues(...)0%14140100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/MyAccountHUD/MyProfileController.cs

#LineLine coverage
 1using Cysharp.Threading.Tasks;
 2using DCL.Browser;
 3using DCL.Tasks;
 4using DCL.UserProfiles;
 5using DCLServices.Lambdas.NamesService;
 6using SocialFeaturesAnalytics;
 7using System;
 8using System.Collections.Generic;
 9using System.Globalization;
 10using System.Linq;
 11using System.Text.RegularExpressions;
 12using System.Threading;
 13using UnityEngine;
 14using UnityEngine.Networking;
 15
 16namespace DCL.MyAccount
 17{
 18    public class MyProfileController
 19    {
 20        private const string CLAIM_UNIQUE_NAME_URL = "https://builder.decentraland.org/claim-name?utm_source=dcl_explore
 21
 22        private readonly IMyProfileComponentView view;
 23        private readonly DataStore dataStore;
 24        private readonly IUserProfileBridge userProfileBridge;
 25        private readonly INamesService namesService;
 26        private readonly IBrowserBridge browserBridge;
 27        private readonly MyAccountSectionHUDController myAccountSectionHUDController;
 28        private readonly KernelConfig kernelConfig;
 29        private readonly IMyAccountAnalyticsService myAccountAnalyticsService;
 30        private readonly ISocialAnalytics socialAnalytics;
 31        private readonly IProfileAdditionalInfoValueListProvider countryListProvider;
 32        private readonly IProfileAdditionalInfoValueListProvider genderListProvider;
 33        private readonly IProfileAdditionalInfoValueListProvider sexualOrientationProvider;
 34        private readonly IProfileAdditionalInfoValueListProvider employmentStatusProvider;
 35        private readonly IProfileAdditionalInfoValueListProvider relationshipStatusProvider;
 36        private readonly IProfileAdditionalInfoValueListProvider languageListProvider;
 37        private readonly IProfileAdditionalInfoValueListProvider pronounListProvider;
 4138        private readonly List<string> loadedNames = new ();
 39
 4140        private CancellationTokenSource saveLinkCancellationToken = new ();
 4141        private CancellationTokenSource saveNameCancellationToken = new ();
 4142        private CancellationTokenSource saveDescriptionCancellationToken = new ();
 4143        private CancellationTokenSource additionalInfoCancellationToken = new ();
 4144        private CancellationTokenSource refreshContentCancellationToken = new ();
 45        private CancellationTokenSource lifeTimeCancellationToken;
 46        private Regex nameRegex;
 47
 25848        private UserProfile ownUserProfile => userProfileBridge.GetOwn();
 3549        private string ownUserMainName => SplitUserName(ownUserProfile).mainName;
 3150        private string ownUserNonClaimedHashtag => SplitUserName(ownUserProfile).nonClaimedHashtag;
 51
 4152        public MyProfileController(
 53            IMyProfileComponentView view,
 54            DataStore dataStore,
 55            IUserProfileBridge userProfileBridge,
 56            INamesService namesService,
 57            IBrowserBridge browserBridge,
 58            MyAccountSectionHUDController myAccountSectionHUDController,
 59            KernelConfig kernelConfig,
 60            IMyAccountAnalyticsService myAccountAnalyticsService,
 61            ISocialAnalytics socialAnalytics,
 62            IProfileAdditionalInfoValueListProvider countryListProvider,
 63            IProfileAdditionalInfoValueListProvider genderListProvider,
 64            IProfileAdditionalInfoValueListProvider sexualOrientationProvider,
 65            IProfileAdditionalInfoValueListProvider employmentStatusProvider,
 66            IProfileAdditionalInfoValueListProvider relationshipStatusProvider,
 67            IProfileAdditionalInfoValueListProvider languageListProvider,
 68            IProfileAdditionalInfoValueListProvider pronounListProvider)
 69        {
 4170            this.view = view;
 4171            this.dataStore = dataStore;
 4172            this.userProfileBridge = userProfileBridge;
 4173            this.namesService = namesService;
 4174            this.browserBridge = browserBridge;
 4175            this.myAccountSectionHUDController = myAccountSectionHUDController;
 4176            this.kernelConfig = kernelConfig;
 4177            this.myAccountAnalyticsService = myAccountAnalyticsService;
 4178            this.socialAnalytics = socialAnalytics;
 4179            this.countryListProvider = countryListProvider;
 4180            this.genderListProvider = genderListProvider;
 4181            this.sexualOrientationProvider = sexualOrientationProvider;
 4182            this.employmentStatusProvider = employmentStatusProvider;
 4183            this.relationshipStatusProvider = relationshipStatusProvider;
 4184            this.languageListProvider = languageListProvider;
 4185            this.pronounListProvider = pronounListProvider;
 86
 4187            dataStore.myAccount.isMyAccountSectionVisible.OnChange += OnMyAccountSectionVisibleChanged;
 4188            view.OnCurrentNameEdited += OnNameEdited;
 4189            view.OnCurrentNameSubmitted += OnNameSubmitted;
 4190            view.OnGoFromClaimedToNonClaimNameClicked += GoFromClaimedToNonClaimName;
 4191            view.OnClaimNameClicked += OnClaimNameRequested;
 4192            view.OnAboutDescriptionSubmitted += OnAboutDescriptionSubmitted;
 4193            view.OnLinkAdded += OnAddLinkRequested;
 4194            view.OnLinkRemoved += OnRemoveLinkRequested;
 95
 4196            ownUserProfile.OnUpdate += OnOwnUserProfileUpdated;
 97
 4198            kernelConfig.EnsureConfigInitialized()
 4199                        .Then(config => OnKernelConfigChanged(config, null));
 100
 41101            kernelConfig.OnChange += OnKernelConfigChanged;
 41102        }
 103
 104        public void Dispose()
 105        {
 41106            dataStore.myAccount.isMyAccountSectionVisible.OnChange -= OnMyAccountSectionVisibleChanged;
 41107            view.OnCurrentNameEdited -= OnNameEdited;
 41108            view.OnCurrentNameSubmitted -= OnNameSubmitted;
 41109            view.OnGoFromClaimedToNonClaimNameClicked -= GoFromClaimedToNonClaimName;
 41110            view.OnClaimNameClicked -= OnClaimNameRequested;
 41111            view.OnAboutDescriptionSubmitted -= OnAboutDescriptionSubmitted;
 41112            view.OnLinkAdded -= OnAddLinkRequested;
 41113            view.OnLinkRemoved -= OnRemoveLinkRequested;
 41114            ownUserProfile.OnUpdate -= OnOwnUserProfileUpdated;
 41115            kernelConfig.OnChange -= OnKernelConfigChanged;
 116
 41117            saveLinkCancellationToken.SafeCancelAndDispose();
 41118            saveNameCancellationToken.SafeCancelAndDispose();
 41119            saveDescriptionCancellationToken.SafeCancelAndDispose();
 41120            additionalInfoCancellationToken.SafeCancelAndDispose();
 41121            refreshContentCancellationToken.SafeCancelAndDispose();
 41122        }
 123
 124        private void OnKernelConfigChanged(KernelConfigModel current, KernelConfigModel _) =>
 41125            nameRegex = new Regex(current.profiles.nameValidRegex);
 126
 127        private void OnMyAccountSectionVisibleChanged(bool isVisible, bool _)
 128        {
 18129            if (isVisible)
 18130                OpenSection();
 131            else
 0132                CloseSection();
 0133        }
 134
 135        private void OpenSection()
 136        {
 18137            lifeTimeCancellationToken = lifeTimeCancellationToken.SafeRestart();
 18138            view.SetLoadingActive(true);
 139
 18140            ShowAboutDescription(ownUserProfile);
 18141            ShowLinks(ownUserProfile);
 18142            UserProfile userProfile = ownUserProfile;
 18143            ShowAdditionalInfoOptions(userProfile, userProfile.AdditionalInfo);
 18144            ShowAdditionalInfoValues(userProfile.AdditionalInfo);
 145
 18146            LoadAndShowOwnedNamesAsync(lifeTimeCancellationToken.Token)
 147               .ContinueWith(() =>
 148                {
 18149                    view.SetLoadingActive(false);
 18150                    refreshContentCancellationToken = refreshContentCancellationToken.SafeRestart();
 18151                    RefreshContentLayout(refreshContentCancellationToken.Token).Forget();
 18152                })
 153               .Forget();
 18154        }
 155
 156        private async UniTask RefreshContentLayout(CancellationToken ct)
 157        {
 54158            await UniTask.DelayFrame(1, cancellationToken: ct);
 1159            view.RefreshContentLayout();
 1160        }
 161
 162        private void CloseSection() =>
 0163            lifeTimeCancellationToken.SafeCancelAndDispose();
 164
 165        private async UniTask LoadAndShowOwnedNamesAsync(CancellationToken ct)
 166        {
 167            try
 168            {
 18169                loadedNames.Clear();
 170
 20171                var names = await namesService.RequestOwnedNamesAsync(
 172                    ownUserProfile.userId,
 173                    1,
 174                    int.MaxValue,
 175                    true,
 176                    ct);
 177
 18178                var optionsToLoad = new List<string>();
 179
 18180                if (names.names is { Count: > 0 })
 181                {
 1182                    optionsToLoad.AddRange(names.names
 3183                                                .OrderBy(x => x.Name)
 3184                                                .Select(x => x.Name));
 185
 1186                    view.SetClaimedNameDropdownOptions(optionsToLoad);
 1187                    loadedNames.AddRange(optionsToLoad);
 188                }
 189                else
 17190                    view.SetClaimedNameDropdownOptions(optionsToLoad);
 18191            }
 0192            catch (OperationCanceledException) { }
 0193            catch (Exception e) { Debug.LogError(e.Message); }
 18194            finally { RefreshNamesSectionStatus(); }
 18195        }
 196
 197        private void RefreshNamesSectionStatus()
 198        {
 31199            view.SetClaimedNameMode(loadedNames.Count > 0);
 31200            view.SetClaimedNameModeAsInput(!ownUserProfile.hasClaimedName);
 31201            view.SetCurrentName(ownUserMainName, ownUserNonClaimedHashtag);
 31202            view.SetClaimNameBannerActive(loadedNames.Count == 0);
 31203        }
 204
 205        private void OnNameEdited(string newName)
 206        {
 2207            if (string.IsNullOrEmpty(newName) || newName == ownUserMainName)
 208            {
 0209                view.SetNonValidNameWarningActive(false);
 0210                return;
 211            }
 212
 2213            view.SetNonValidNameWarningActive(!IsValidUserName(newName));
 2214        }
 215
 216        private void OnNameSubmitted(string newName, bool isClaimed)
 217        {
 2218            if (string.IsNullOrEmpty(newName) || newName == ownUserMainName)
 219            {
 0220                view.SetNonValidNameWarningActive(false);
 0221                return;
 222            }
 223
 2224            bool isValidUserName = IsValidUserName(newName);
 2225            view.SetNonValidNameWarningActive(!isValidUserName);
 226
 2227            if (!isValidUserName) return;
 228
 229            async UniTaskVoid SaveNameAsync(string newName, bool isClaimed, CancellationToken cancellationToken)
 230            {
 2231                if (isClaimed)
 1232                    await userProfileBridge.SaveVerifiedName(newName, cancellationToken);
 233                else
 1234                    await userProfileBridge.SaveUnverifiedName(newName, cancellationToken);
 235
 2236                myAccountSectionHUDController.ShowAccountSettingsUpdatedToast();
 2237                myAccountAnalyticsService.SendPlayerSwapNameAnalytic(isClaimed, loadedNames.Count);
 2238            }
 239
 2240            saveNameCancellationToken = saveNameCancellationToken.SafeRestart();
 2241            SaveNameAsync(newName, isClaimed, saveNameCancellationToken.Token).Forget();
 2242        }
 243
 244        private void OnAboutDescriptionSubmitted(string newDesc)
 245        {
 1246            if (newDesc == ownUserProfile.description)
 0247                return;
 248
 249            async UniTaskVoid SaveDescriptionAsync(string newDesc, CancellationToken cancellationToken)
 250            {
 1251                await userProfileBridge.SaveDescription(newDesc, cancellationToken);
 252
 1253                myAccountSectionHUDController.ShowAccountSettingsUpdatedToast();
 1254                myAccountAnalyticsService.SendProfileInfoEditAnalytic(newDesc.Length);
 1255                socialAnalytics.SendProfileEdit(newDesc.Length, false, PlayerActionSource.MyProfile, ProfileField.Descri
 1256            }
 257
 1258            saveDescriptionCancellationToken = saveDescriptionCancellationToken.SafeRestart();
 1259            SaveDescriptionAsync(newDesc, saveDescriptionCancellationToken.Token).Forget();
 1260        }
 261
 262        private void ShowAboutDescription(UserProfile userProfile)
 263        {
 31264            view.SetAboutDescription(userProfile.description);
 31265            view.SetAboutEnabled(!userProfile.isGuest);
 31266        }
 267
 268        private bool IsValidUserName(string newName) =>
 4269            nameRegex == null || nameRegex.IsMatch(newName);
 270
 271        private void OnOwnUserProfileUpdated(UserProfile userProfile)
 272        {
 13273            if (userProfile == null)
 0274                return;
 275
 13276            RefreshNamesSectionStatus();
 13277            ShowAboutDescription(userProfile);
 13278            ShowLinks(userProfile);
 13279            ShowAdditionalInfoOptions(userProfile, userProfile.AdditionalInfo);
 13280            ShowAdditionalInfoValues(userProfile.AdditionalInfo);
 13281        }
 282
 283        private void ShowLinks(UserProfile userProfile)
 284        {
 32285            view.SetLinks(userProfile.Links ?? new List<UserProfileModel.Link>(0));
 32286            view.EnableOrDisableAddLinksOption(userProfile.Links == null || userProfile.Links?.Count < 5);
 32287            view.SetLinksEnabled(!userProfile.isGuest);
 32288        }
 289
 290        private void GoFromClaimedToNonClaimName() =>
 0291            view.SetClaimedNameModeAsInput(true, ownUserProfile.hasClaimedName);
 292
 293        private void OnClaimNameRequested()
 294        {
 1295            browserBridge.OpenUrl(CLAIM_UNIQUE_NAME_URL);
 1296            myAccountAnalyticsService.SendPlayerOpenClaimNameAnalytic();
 1297        }
 298
 299        private (string mainName, string nonClaimedHashtag) SplitUserName(UserProfile userProfile)
 300        {
 66301            (string mainName, string nonClaimedHashtag) result = (
 302                string.Empty,
 303                userProfile.ethAddress != null ? userProfile.ethAddress.Length >= 4 ? userProfile.ethAddress.Substring(u
 304
 66305            string[] splitName = userProfile.userName.Split('#');
 306
 66307            if (splitName.Length > 0)
 66308                result.mainName = splitName[0];
 309
 66310            if (splitName.Length > 1)
 64311                result.nonClaimedHashtag = splitName[1];
 312
 66313            return result;
 314        }
 315
 316        private void OnAddLinkRequested((string title, string url) obj)
 317        {
 4318            if (ownUserProfile.Links?.Count >= 5) return;
 319
 320            async UniTaskVoid AddAndSaveLinkAsync(string title, string url, CancellationToken cancellationToken)
 321            {
 2322                List<UserProfileModel.Link> links = new ((IEnumerable<UserProfileModel.Link>)ownUserProfile.Links
 323                                                         ?? Array.Empty<UserProfileModel.Link>())
 324                {
 325                    new UserProfileModel.Link(title, url),
 326                };
 327
 328                try
 329                {
 2330                    await userProfileBridge.SaveLinks(links, cancellationToken);
 331
 2332                    view.ClearLinkInput();
 2333                    myAccountSectionHUDController.ShowAccountSettingsUpdatedToast();
 2334                    myAccountAnalyticsService.SendProfileLinkAddAnalytic(title, url);
 2335                }
 0336                catch (OperationCanceledException) { }
 0337                catch (Exception e) { Debug.LogException(e); }
 2338            }
 339
 2340            saveLinkCancellationToken = saveLinkCancellationToken.SafeRestart();
 2341            AddAndSaveLinkAsync(obj.title, obj.url, saveLinkCancellationToken.Token).Forget();
 2342        }
 343
 344        private void OnRemoveLinkRequested((string title, string url) obj)
 345        {
 346            async UniTaskVoid RemoveAndSaveLinkAsync(string title, string url, CancellationToken cancellationToken)
 347            {
 1348                url = UnityWebRequest.UnEscapeURL(url ?? "");
 1349                List<UserProfileModel.Link> links = new (ownUserProfile.Links);
 1350                links.RemoveAll(link =>
 351                {
 3352                    string linkTitle = link.title ?? "";
 3353                    string linkURL = UnityWebRequest.UnEscapeURL(link.url ?? "");
 354
 3355                    return linkTitle.Equals(title, StringComparison.OrdinalIgnoreCase)
 356                           && linkURL.Equals(url, StringComparison.OrdinalIgnoreCase);
 357                });
 358
 359                try
 360                {
 1361                    UserProfile profile = await userProfileBridge.SaveLinks(links, cancellationToken);
 362
 1363                    ShowLinks(profile);
 1364                    myAccountSectionHUDController.ShowAccountSettingsUpdatedToast();
 1365                    myAccountAnalyticsService.SendProfileLinkRemoveAnalytic(title, url);
 1366                }
 0367                catch (OperationCanceledException) { }
 0368                catch (Exception e) { Debug.LogException(e); }
 1369            }
 370
 1371            saveLinkCancellationToken = saveLinkCancellationToken.SafeRestart();
 1372            RemoveAndSaveLinkAsync(obj.title, obj.url, saveLinkCancellationToken.Token).Forget();
 1373        }
 374
 375        private void ShowAdditionalInfoOptions(UserProfile userProfile, AdditionalInfo additionalInfo)
 376        {
 31377            Dictionary<string, AdditionalInfoOptionsModel.Option> options = new ();
 378
 31379            options.Add("Country", new AdditionalInfoOptionsModel.Option
 380            {
 381                IsAvailable = string.IsNullOrEmpty(additionalInfo.Country),
 382                Name = "Country",
 383                InputType = AdditionalInfoOptionsModel.InputType.StrictValueList,
 384                Values = GetCountryList(),
 385                OnValueSubmitted = country =>
 386                {
 1387                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 388                    {
 389                        Country = country,
 390                    });
 391
 1392                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoAddAnalytic("Country", country);
 1393                },
 394                OnRemoved = () =>
 395                {
 1396                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 397                    {
 398                        Country = null,
 399                    });
 400
 1401                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoRemoveAnalytic("Country");
 1402                },
 403            });
 404
 31405            options.Add("Gender", new AdditionalInfoOptionsModel.Option
 406            {
 407                IsAvailable = string.IsNullOrEmpty(additionalInfo.Gender),
 408                Name = "Gender",
 409                InputType = AdditionalInfoOptionsModel.InputType.StrictValueList,
 410                Values = GetGenderList(),
 411                OnValueSubmitted = gender =>
 412                {
 1413                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 414                    {
 415                        Gender = gender,
 416                    });
 417
 1418                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoAddAnalytic("Gender", gender);
 1419                },
 420                OnRemoved = () =>
 421                {
 1422                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 423                    {
 424                        Gender = null,
 425                    });
 426
 1427                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoRemoveAnalytic("Gender");
 1428                },
 429            });
 430
 31431            options.Add("Pronouns", new AdditionalInfoOptionsModel.Option
 432            {
 433                IsAvailable = string.IsNullOrEmpty(additionalInfo.Pronouns),
 434                Name = "Pronouns",
 435                InputType = AdditionalInfoOptionsModel.InputType.StrictValueList,
 436                Values = GetPronounList(),
 437                OnValueSubmitted = pronouns =>
 438                {
 1439                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 440                    {
 441                        Pronouns = pronouns,
 442                    });
 443
 1444                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoAddAnalytic("Pronouns", pronouns);
 1445                },
 446                OnRemoved = () =>
 447                {
 1448                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 449                    {
 450                        Pronouns = null,
 451                    });
 452
 1453                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoRemoveAnalytic("Pronouns");
 1454                },
 455            });
 456
 31457            options.Add("Relationship Status", new AdditionalInfoOptionsModel.Option
 458            {
 459                IsAvailable = string.IsNullOrEmpty(additionalInfo.RelationshipStatus),
 460                Name = "Relationship Status",
 461                InputType = AdditionalInfoOptionsModel.InputType.StrictValueList,
 462                Values = GetRelationshipStatusList(),
 463                OnValueSubmitted = relationshipStatus =>
 464                {
 1465                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 466                    {
 467                        RelationshipStatus = relationshipStatus,
 468                    });
 469
 1470                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoAddAnalytic("Relationship Status", relationsh
 1471                },
 472                OnRemoved = () =>
 473                {
 1474                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 475                    {
 476                        RelationshipStatus = null,
 477                    });
 478
 1479                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoRemoveAnalytic("Relationship Status");
 1480                },
 481            });
 482
 31483            options.Add("Sexual Orientation", new AdditionalInfoOptionsModel.Option
 484            {
 485                IsAvailable = string.IsNullOrEmpty(additionalInfo.SexualOrientation),
 486                Name = "Sexual Orientation",
 487                InputType = AdditionalInfoOptionsModel.InputType.StrictValueList,
 488                Values = GetSexualOrientationList(),
 489                OnValueSubmitted = sexualOrientation =>
 490                {
 1491                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 492                    {
 493                        SexualOrientation = sexualOrientation,
 494                    });
 495
 1496                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoAddAnalytic("Sexual Orientation", sexualOrien
 1497                },
 498                OnRemoved = () =>
 499                {
 1500                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 501                    {
 502                        SexualOrientation = null,
 503                    });
 504
 1505                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoRemoveAnalytic("Sexual Orientation");
 1506                },
 507            });
 508
 31509            options.Add("Language", new AdditionalInfoOptionsModel.Option
 510            {
 511                IsAvailable = string.IsNullOrEmpty(additionalInfo.Language),
 512                Name = "Language",
 513                InputType = AdditionalInfoOptionsModel.InputType.StrictValueList,
 514                Values = GetLanguageList(),
 515                OnValueSubmitted = language =>
 516                {
 1517                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 518                    {
 519                        Language = language,
 520                    });
 521
 1522                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoAddAnalytic("Language", language);
 1523                },
 524                OnRemoved = () =>
 525                {
 1526                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 527                    {
 528                        Language = null,
 529                    });
 530
 1531                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoRemoveAnalytic("Language");
 1532                },
 533            });
 534
 31535            options.Add("Employment Status", new AdditionalInfoOptionsModel.Option
 536            {
 537                IsAvailable = string.IsNullOrEmpty(additionalInfo.EmploymentStatus),
 538                Name = "Employment Status",
 539                InputType = AdditionalInfoOptionsModel.InputType.StrictValueList,
 540                Values = GetEmploymentStatusList(),
 541                OnValueSubmitted = employmentStatus =>
 542                {
 1543                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 544                    {
 545                        EmploymentStatus = employmentStatus,
 546                    });
 547
 1548                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoAddAnalytic("Employment Status", employmentSt
 1549                },
 550                OnRemoved = () =>
 551                {
 1552                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 553                    {
 554                        EmploymentStatus = null,
 555                    });
 556
 1557                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoRemoveAnalytic("Employment Status");
 1558                },
 559            });
 560
 31561            options.Add("Profession", new AdditionalInfoOptionsModel.Option
 562            {
 563                IsAvailable = string.IsNullOrEmpty(additionalInfo.Profession),
 564                Name = "Profession",
 565                InputType = AdditionalInfoOptionsModel.InputType.FreeFormText,
 566                OnValueSubmitted = profession =>
 567                {
 1568                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 569                    {
 570                        Profession = profession,
 571                    });
 572
 1573                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoAddAnalytic("Profession", profession);
 1574                },
 575                OnRemoved = () =>
 576                {
 1577                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 578                    {
 579                        Profession = null,
 580                    });
 581
 1582                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoRemoveAnalytic("Profession");
 1583                },
 584            });
 585
 31586            options.Add("Birth Date", new AdditionalInfoOptionsModel.Option
 587            {
 588                IsAvailable = additionalInfo.BirthDate == null,
 589                Name = "Birth Date",
 590                InputType = AdditionalInfoOptionsModel.InputType.Date,
 591                DateFormat = "dd/MM/yyyy",
 592                OnValueSubmitted = birthDate =>
 593                {
 1594                    var dateTime = DateTime.ParseExact(birthDate, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeSt
 595
 1596                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 597                    {
 598                        BirthDate = dateTime,
 599                    });
 600
 1601                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoAddAnalytic("Birth Date", birthDate);
 1602                },
 603                OnRemoved = () =>
 604                {
 1605                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 606                    {
 607                        BirthDate = null,
 608                    });
 609
 1610                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoRemoveAnalytic("Birth Date");
 1611                },
 612            });
 613
 31614            options.Add("Real Name", new AdditionalInfoOptionsModel.Option
 615            {
 616                IsAvailable = string.IsNullOrEmpty(additionalInfo.RealName),
 617                Name = "Real Name",
 618                InputType = AdditionalInfoOptionsModel.InputType.FreeFormText,
 619                OnValueSubmitted = realName =>
 620                {
 1621                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 622                    {
 623                        RealName = realName,
 624                    });
 625
 1626                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoAddAnalytic("Real Name", realName);
 1627                },
 628                OnRemoved = () =>
 629                {
 1630                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 631                    {
 632                        RealName = null,
 633                    });
 634
 1635                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoRemoveAnalytic("Real Name");
 1636                },
 637            });
 638
 31639            options.Add("Hobbies", new AdditionalInfoOptionsModel.Option
 640            {
 641                IsAvailable = string.IsNullOrEmpty(additionalInfo.Hobbies),
 642                Name = "Hobbies",
 643                InputType = AdditionalInfoOptionsModel.InputType.FreeFormText,
 644                OnValueSubmitted = hobbies =>
 645                {
 1646                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 647                    {
 648                        Hobbies = hobbies,
 649                    });
 650
 1651                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoAddAnalytic("Hobbies", hobbies);
 1652                },
 653                OnRemoved = () =>
 654                {
 1655                    SaveAdditionalInfo(new AdditionalInfo(additionalInfo)
 656                    {
 657                        Hobbies = null,
 658                    });
 659
 1660                    myAccountAnalyticsService.SendProfileInfoAdditionalInfoRemoveAnalytic("Hobbies");
 1661                },
 662            });
 663
 31664            view.SetAdditionalInfoOptions(new AdditionalInfoOptionsModel
 665            {
 666                Options = options,
 667            });
 668
 31669            view.SetAdditionalInfoEnabled(!userProfile.isGuest);
 31670        }
 671
 672        private string[] GetEmploymentStatusList() =>
 31673            employmentStatusProvider.Provide();
 674
 675        private string[] GetLanguageList() =>
 31676            languageListProvider.Provide();
 677
 678        private string[] GetSexualOrientationList() =>
 31679            sexualOrientationProvider.Provide();
 680
 681        private string[] GetRelationshipStatusList() =>
 31682            relationshipStatusProvider.Provide();
 683
 684        private string[] GetPronounList() =>
 31685            pronounListProvider.Provide();
 686
 687        private string[] GetGenderList() =>
 31688            genderListProvider.Provide();
 689
 690        private string[] GetCountryList() =>
 31691            countryListProvider.Provide();
 692
 693        private void SaveAdditionalInfo(AdditionalInfo additionalInfo)
 694        {
 695            async UniTaskVoid SaveAdditionalInfoAsync(AdditionalInfo additionalInfo, CancellationToken cancellationToken
 696            {
 22697                await userProfileBridge.SaveAdditionalInfo(additionalInfo, cancellationToken);
 698
 22699                myAccountSectionHUDController.ShowAccountSettingsUpdatedToast();
 22700            }
 701
 22702            additionalInfoCancellationToken = additionalInfoCancellationToken.SafeRestart();
 703
 22704            SaveAdditionalInfoAsync(additionalInfo,
 705                    additionalInfoCancellationToken.Token)
 706               .Forget();
 22707        }
 708
 709        private void ShowAdditionalInfoValues(AdditionalInfo additionalInfo)
 710        {
 31711            Dictionary<string, (string title, string value)> values = new ();
 712
 31713            if (!string.IsNullOrEmpty(additionalInfo.Country))
 2714                values["Country"] = ("Country", additionalInfo.Country);
 715
 31716            if (!string.IsNullOrEmpty(additionalInfo.Gender))
 2717                values["Gender"] = ("Gender", additionalInfo.Gender);
 718
 31719            if (!string.IsNullOrEmpty(additionalInfo.Pronouns))
 2720                values["Pronouns"] = ("Pronouns", additionalInfo.Pronouns);
 721
 31722            if (!string.IsNullOrEmpty(additionalInfo.RelationshipStatus))
 2723                values["Relationship Status"] = ("Relationship Status", additionalInfo.RelationshipStatus);
 724
 31725            if (!string.IsNullOrEmpty(additionalInfo.SexualOrientation))
 2726                values["Sexual Orientation"] = ("Sexual Orientation", additionalInfo.SexualOrientation);
 727
 31728            if (!string.IsNullOrEmpty(additionalInfo.Language))
 2729                values["Language"] = ("Language", additionalInfo.Language);
 730
 31731            if (!string.IsNullOrEmpty(additionalInfo.EmploymentStatus))
 2732                values["Employment Status"] = ("Employment Status", additionalInfo.EmploymentStatus);
 733
 31734            if (!string.IsNullOrEmpty(additionalInfo.Profession))
 2735                values["Profession"] = ("Profession", additionalInfo.Profession);
 736
 31737            if (additionalInfo.BirthDate != null)
 2738                values["Birth Date"] = ("Birth Date", additionalInfo.BirthDate?.ToString("dd/MM/yyyy"));
 739
 31740            if (!string.IsNullOrEmpty(additionalInfo.RealName))
 2741                values["Real Name"] = ("Real Name", additionalInfo.RealName);
 742
 31743            if (!string.IsNullOrEmpty(additionalInfo.Hobbies))
 2744                values["Hobbies"] = ("Hobbies", additionalInfo.Hobbies);
 745
 31746            view.SetAdditionalInfoValues(values);
 31747        }
 748    }
 749}

Methods/Properties

MyProfileController(DCL.MyAccount.IMyProfileComponentView, DCL.DataStore, IUserProfileBridge, DCLServices.Lambdas.NamesService.INamesService, DCL.Browser.IBrowserBridge, DCL.MyAccount.MyAccountSectionHUDController, KernelConfig, DCL.MyAccount.IMyAccountAnalyticsService, SocialFeaturesAnalytics.ISocialAnalytics, DCL.MyAccount.IProfileAdditionalInfoValueListProvider, DCL.MyAccount.IProfileAdditionalInfoValueListProvider, DCL.MyAccount.IProfileAdditionalInfoValueListProvider, DCL.MyAccount.IProfileAdditionalInfoValueListProvider, DCL.MyAccount.IProfileAdditionalInfoValueListProvider, DCL.MyAccount.IProfileAdditionalInfoValueListProvider, DCL.MyAccount.IProfileAdditionalInfoValueListProvider)
ownUserProfile()
ownUserMainName()
ownUserNonClaimedHashtag()
Dispose()
OnKernelConfigChanged(KernelConfigModel, KernelConfigModel)
OnMyAccountSectionVisibleChanged(System.Boolean, System.Boolean)
OpenSection()
RefreshContentLayout()
CloseSection()
LoadAndShowOwnedNamesAsync()
RefreshNamesSectionStatus()
OnNameEdited(System.String)
OnNameSubmitted(System.String, System.Boolean)
<OnNameSubmitted()
OnAboutDescriptionSubmitted(System.String)
<OnAboutDescriptionSubmitted()
ShowAboutDescription(UserProfile)
IsValidUserName(System.String)
OnOwnUserProfileUpdated(UserProfile)
ShowLinks(UserProfile)
GoFromClaimedToNonClaimName()
OnClaimNameRequested()
SplitUserName(UserProfile)
OnAddLinkRequested(System.ValueTuple[String,String])
<OnAddLinkRequested()
<OnRemoveLinkRequested()
OnRemoveLinkRequested(System.ValueTuple[String,String])
ShowAdditionalInfoOptions(UserProfile, DCL.UserProfiles.AdditionalInfo)
GetEmploymentStatusList()
GetLanguageList()
GetSexualOrientationList()
GetRelationshipStatusList()
GetPronounList()
GetGenderList()
GetCountryList()
<SaveAdditionalInfo()
SaveAdditionalInfo(DCL.UserProfiles.AdditionalInfo)
ShowAdditionalInfoValues(DCL.UserProfiles.AdditionalInfo)