private async void OnStateServiceChangedProfile(object sender, ChangedProfileSignalArgs e) { try { if (e.Profile.BackgroundImage != null) { e.Profile.BackgroundImage.Url = string.Format(GlobalSettings.Instance.Endpoints.MediaEndPoints.GetMediaEndPoints, e.Profile.BackgroundImage.Url); e.Profile.BackgroundImage.ThumbnailUrl = string.Format(GlobalSettings.Instance.Endpoints.MediaEndPoints.GetMediaEndPoints, e.Profile.BackgroundImage.ThumbnailUrl); } bool fieldsDifference = GlobalSettings.Instance.UserProfile.About == e.Profile.About && GlobalSettings.Instance.UserProfile.MySports == e.Profile.MySports && GlobalSettings.Instance.UserProfile.Type == e.Profile.Type && GlobalSettings.Instance.UserProfile.FirstName == e.Profile.FirstName && GlobalSettings.Instance.UserProfile.LastName == e.Profile.LastName && GlobalSettings.Instance.UserProfile.DisplayName == e.Profile.DisplayName && GlobalSettings.Instance.UserProfile.ShortId == e.Profile.ShortId && GlobalSettings.Instance.UserProfile.IsEmailConfirmed == e.Profile.IsEmailConfirmed && GlobalSettings.Instance.UserProfile.DateOfBirth == e.Profile.DateOfBirth && GlobalSettings.Instance.UserProfile.Availability == e.Profile.Availability && GlobalSettings.Instance.UserProfile.LastSeen == e.Profile.LastSeen && GlobalSettings.Instance.UserProfile.ParentId == e.Profile.ParentId && GlobalSettings.Instance.UserProfile.ChildUserName == e.Profile.ChildUserName && GlobalSettings.Instance.UserProfile.ChildPassword == e.Profile.ChildPassword && GlobalSettings.Instance.UserProfile.Contact == e.Profile.Contact && GlobalSettings.Instance.UserProfile.Address.City == e.Profile.Address.City && GlobalSettings.Instance.UserProfile.Address.State == e.Profile.Address.State && GlobalSettings.Instance.UserProfile.Address.Street == e.Profile.Address.Street && GlobalSettings.Instance.UserProfile.Address.Zip == e.Profile.Address.Zip; //bool fieldsDifference = GlobalSettings.Instance.UserProfile.FirstName == e.Profile.FirstName && //GlobalSettings.Instance.UserProfile.LastName == e.Profile.LastName && //GlobalSettings.Instance.UserProfile.Id == e.Profile.Id && //GlobalSettings.Instance.UserProfile.ParentId == e.Profile.ParentId && //GlobalSettings.Instance.UserProfile.Contact.Email == e.Profile.Contact.Email && //GlobalSettings.Instance.UserProfile.Contact.Phone == e.Profile.Contact.Phone && //GlobalSettings.Instance.UserProfile.DateOfBirth == e.Profile.DateOfBirth && //GlobalSettings.Instance.UserProfile.Address.City == e.Profile.Address.City && //GlobalSettings.Instance.UserProfile.Address.State == e.Profile.Address.State && //GlobalSettings.Instance.UserProfile.Address.Street == e.Profile.Address.Street && //GlobalSettings.Instance.UserProfile.Address.Zip == e.Profile.Address.Zip && //GlobalSettings.Instance.UserProfile.DisplayName == e.Profile.DisplayName && //GlobalSettings.Instance.UserProfile.ShortId == e.Profile.ShortId && //GlobalSettings.Instance.UserProfile.About == e.Profile.About && //GlobalSettings.Instance.UserProfile.MySports == e.Profile.MySports; string currentAvatar = GlobalSettings.Instance.UserProfile.Avatar?.Url; string newAvatar = e.Profile.Avatar?.Url; bool avatarsDifference = currentAvatar == newAvatar; //if (GlobalSettings.Instance.UserProfile.Avatar?.Url != null && e.Profile.Avatar != null) { // avatarsDifference = GlobalSettings.Instance.UserProfile.Avatars.Last().Url == e.Profile.Avatars.Last().Url; //} string currentBackground = GlobalSettings.Instance.UserProfile.AppBackgroundImage?.Url; string newBackground = e.Profile.BackgroundImage?.Url; bool backgroundDifference = currentBackground == newBackground; //if (GlobalSettings.Instance.UserProfile.AppBackgroundImage != null && e.Profile.BackgroundImage != null) { // backgroundDifference = GlobalSettings.Instance.UserProfile.AppBackgroundImage.Url == e.Profile.BackgroundImage.Url; //} bool isNecessaryToUpdate = !fieldsDifference || !avatarsDifference || !backgroundDifference; if (isNecessaryToUpdate) { //GlobalSettings.Instance.UserProfile.FirstName = e.Profile.FirstName; //GlobalSettings.Instance.UserProfile.LastName = e.Profile.LastName; //GlobalSettings.Instance.UserProfile.Id = e.Profile.Id; //GlobalSettings.Instance.UserProfile.ParentId = e.Profile.ParentId; //GlobalSettings.Instance.UserProfile.Contact = e.Profile.Contact; //GlobalSettings.Instance.UserProfile.DateOfBirth = e.Profile.DateOfBirth; //GlobalSettings.Instance.UserProfile.Address = e.Profile.Address; //GlobalSettings.Instance.UserProfile.DisplayName = e.Profile.DisplayName; //GlobalSettings.Instance.UserProfile.ShortId = e.Profile.ShortId; //GlobalSettings.Instance.UserProfile.Avatars = e.Profile.Avatars; //GlobalSettings.Instance.UserProfile.About = e.Profile.About; //GlobalSettings.Instance.UserProfile.Children = (e.Profile.Children != null && e.Profile.Children.Any()) ? e.Profile.Children : null; //GlobalSettings.Instance.UserProfile.MySports = e.Profile.MySports; //GlobalSettings.Instance.UserProfile.ProfileType = (ProfileType)Enum.Parse(typeof(ProfileType), e.Profile.Type); GlobalSettings.Instance.UserProfile.About = e.Profile.About; GlobalSettings.Instance.UserProfile.MySports = e.Profile.MySports; GlobalSettings.Instance.UserProfile.Children = e.Profile.Children; GlobalSettings.Instance.UserProfile.Id = e.Profile.Id; GlobalSettings.Instance.UserProfile.Type = e.Profile.Type; GlobalSettings.Instance.UserProfile.FirstName = e.Profile.FirstName; GlobalSettings.Instance.UserProfile.LastName = e.Profile.LastName; GlobalSettings.Instance.UserProfile.DisplayName = e.Profile.DisplayName; GlobalSettings.Instance.UserProfile.ShortId = e.Profile.ShortId; GlobalSettings.Instance.UserProfile.IsEmailConfirmed = e.Profile.IsEmailConfirmed; GlobalSettings.Instance.UserProfile.DateOfBirth = e.Profile.DateOfBirth; GlobalSettings.Instance.UserProfile.Avatar = e.Profile.Avatar; GlobalSettings.Instance.UserProfile.Availability = e.Profile.Availability; GlobalSettings.Instance.UserProfile.LastSeen = e.Profile.LastSeen; GlobalSettings.Instance.UserProfile.ParentId = e.Profile.ParentId; GlobalSettings.Instance.UserProfile.ChildUserName = e.Profile.ChildUserName; GlobalSettings.Instance.UserProfile.ChildPassword = e.Profile.ChildPassword; GlobalSettings.Instance.UserProfile.Contact = e.Profile.Contact; GlobalSettings.Instance.UserProfile.Address = e.Profile.Address; GlobalSettings.Instance.UserProfile.BackgroundImage = e.Profile.BackgroundImage; GlobalSettings.Instance.UserProfile.AppBackgroundImage = e.Profile.BackgroundImage; GlobalSettings.Instance.UserProfile.BrandImage = e.Profile.BrandImage; GlobalSettings.Instance.UserProfile.ProfileType = (ProfileType)Enum.Parse(typeof(ProfileType), e.Profile.Type); if (backgroundDifference) { GlobalSettings.Instance.AppMessagingEvents.ProfileSettingsEvents.AppBackgroundImageChangedInvoke(this, new EventArgs()); } Settings.UserProfile = JsonConvert.SerializeObject(GlobalSettings.Instance.UserProfile); GlobalSettings.Instance.AppMessagingEvents.ProfileSettingsEvents.ProfileUpdatedInvoke(this, new ProfileUpdatedArgs() { }); } } catch (Exception exc) { Debugger.Break(); await _dialogService.ToastAsync(StateService.CHANGED_PROFILE_HANDLING_ERROR); } }
protected override void OnStartListeningToHub() { _hubConnection.On <object>(_CHANGED_PROFILE_ACTION_KEY, (args) => { Console.WriteLine("===> {0}", _CHANGED_PROFILE_ACTION_KEY); try { ChangedProfileSignalArgs changedProfileSignalArgs = new ChangedProfileSignalArgs() { Profile = JsonConvert.DeserializeObject <ProfileDTO>(args.ToString()) }; ChangedProfile.Invoke(this, changedProfileSignalArgs); } catch (Exception exc) { Debugger.Break(); throw new InvalidOperationException(CHANGED_PROFILE_HANDLING_ERROR, exc); } }); _hubConnection.On <object>(_CHANGED_FRIENDSHIP_ACTION_KEY, (args) => { Console.WriteLine("===> {0}", _CHANGED_FRIENDSHIP_ACTION_KEY); try { ChangedFriendshipSignalArgs changedFriendshipSignalArgs = JsonConvert.DeserializeObject <ChangedFriendshipSignalArgs>(args.ToString()); ChangedFriendship.Invoke(this, changedFriendshipSignalArgs); } catch (Exception exc) { Debugger.Break(); throw new InvalidOperationException(CHANGED_FRIENDSHIP_HANDLING_ERROR, exc); } }); _hubConnection.On <object>(_CHANGED_TEAMS_ACTION_KEY, (args) => { Console.WriteLine("===> {0}", _CHANGED_TEAMS_ACTION_KEY); try { ChangedTeamsSignalArgs changedTeamsSignalArgs = JsonConvert.DeserializeObject <ChangedTeamsSignalArgs>(args.ToString()); ChangedTeams.Invoke(this, changedTeamsSignalArgs); } catch (Exception exc) { Debugger.Break(); throw new InvalidOperationException(CHANGED_TEAMS_HANDLING_ERROR, exc); } }); _hubConnection.On <object>(_CHANGED_GROUPS_ACTION_KEY, (args) => { Console.WriteLine("===> {0}", _CHANGED_GROUPS_ACTION_KEY); try { ChangedGroupsSignalArgs changedGroupsSignalArgs = JsonConvert.DeserializeObject <ChangedGroupsSignalArgs>(args.ToString()); ChangedGroups.Invoke(this, changedGroupsSignalArgs); } catch (Exception exc) { Debugger.Break(); throw new InvalidOperationException(CHANGED_GROUPS_HANDLING_ERROR, exc); } }); _hubConnection.On <object>(_CHANGED_INVITES_ACTION_KEY, (args) => { Console.WriteLine("===> {0}", _CHANGED_INVITES_ACTION_KEY); try { ChangedInvitesSignalArgs changedInvitesSignalArgs = JsonConvert.DeserializeObject <ChangedInvitesSignalArgs>(args.ToString()); InvitesChanged.Invoke(this, changedInvitesSignalArgs); } catch (Exception exc) { Debugger.Break(); throw new InvalidOperationException(CHANGED_INVITES_HANDLING_ERROR, exc); } }); }