private IEnumerator RevertValueOnError(UserProfileEntryUI sender, UserProfileEntryType entryType, string oldValue)
        {
            yield return(new WaitWhile(_commonWaitCondition));

            if (_isProfileUpdated == false)
            {
                sender.InitializeEntry(entryType, oldValue);
            }
        }
        private void OnUserEntryEdited(UserProfileEntryUI sender, UserProfileEntryType entryType, string oldValue, string newValue)
        {
            if (newValue == null)
            {
                Debug.LogError($"New value of entryType {entryType} is null. Can not update");
                sender.InitializeEntry(entryType, oldValue);
                return;
            }

            if (_isUpdateInProgress)
            {
                Debug.LogWarning("Can not update new entry while another update is in progress");
                sender.InitializeEntry(entryType, oldValue);
                return;
            }

            _isUpdateInProgress = true;
            _isProfileUpdated   = null;
            ShowWaiting(waitWhile: _commonWaitCondition);
            StartCoroutine(UnsetIsInProgressOnCompletion());
            StartCoroutine(RevertValueOnError(sender, entryType, oldValue));

            switch (entryType)
            {
            case UserProfileEntryType.DateOfBirth:
            case UserProfileEntryType.FirstName:
            case UserProfileEntryType.Gender:
            case UserProfileEntryType.LastName:
            case UserProfileEntryType.Nickname:
                UpdateCommonEntries(entryType, newValue);
                break;

            case UserProfileEntryType.PhoneNumber:
                if (!string.IsNullOrEmpty(newValue))
                {
                    UpdateUserPhoneNumber(newValue);
                }
                else
                {
                    StartCoroutine(DeleteUserPhoneNumber());
                }
                break;

            default:
                Debug.LogWarning($"Update of {entryType} is not supported");
                _isProfileUpdated = false;
                return;
            }
        }
        private UserProfileEntryUI[] ResizeArrayIfNeeded(int targetLength, UserProfileEntryUI[] array)
        {
            if (array.Length == targetLength)
            {
                return(array);
            }
            else
            {
                UserProfileEntryUI[] newArray = new UserProfileEntryUI[targetLength];
                var length = targetLength > array.Length ? array.Length : targetLength;

                Array.Copy(sourceArray: array, destinationArray: newArray, length);

                return(newArray);
            }
        }