From e562406ce3724532447e67ca94a0cccb9ceab295 Mon Sep 17 00:00:00 2001 From: "Zach Keeping [SSW]" <11418832+zacharykeeping@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:08:23 +1100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Mobile=20|=20Remove=20http/https?= =?UTF-8?q?=20from=20user=20titles=20(#1091)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove http and https * Clean up regex --- src/Common/DTOs/Leaderboard/LeaderboardUserDto.cs | 5 +++-- src/MobileUI/Features/Activity/ActivityPageViewModel.cs | 2 ++ src/MobileUI/Features/Leaderboard/LeaderViewModel.cs | 3 ++- src/MobileUI/Features/Profile/ProfileViewModelBase.cs | 5 ++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Common/DTOs/Leaderboard/LeaderboardUserDto.cs b/src/Common/DTOs/Leaderboard/LeaderboardUserDto.cs index 8d74c0ce..42375309 100644 --- a/src/Common/DTOs/Leaderboard/LeaderboardUserDto.cs +++ b/src/Common/DTOs/Leaderboard/LeaderboardUserDto.cs @@ -1,4 +1,5 @@ -using SSW.Rewards.Domain.Entities; +using System.Text.RegularExpressions; +using SSW.Rewards.Domain.Entities; namespace SSW.Rewards.Shared.DTOs.Leaderboard; @@ -52,7 +53,7 @@ public LeaderboardUserDto(User user, DateTime firstDayOfWeek) if (!string.IsNullOrEmpty(company)) { - Title = company; + Title = Regex.Replace(company, @"^https?://", string.Empty); } else { diff --git a/src/MobileUI/Features/Activity/ActivityPageViewModel.cs b/src/MobileUI/Features/Activity/ActivityPageViewModel.cs index 256b307c..e5832ee4 100644 --- a/src/MobileUI/Features/Activity/ActivityPageViewModel.cs +++ b/src/MobileUI/Features/Activity/ActivityPageViewModel.cs @@ -1,3 +1,4 @@ +using System.Text.RegularExpressions; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using SSW.Rewards.ApiClient.Services; @@ -123,6 +124,7 @@ private async Task> GetFeedData() : x.UserAvatar; x.AchievementMessage = GetMessage(x.Achievement); x.TimeElapsed = DateTimeHelpers.GetTimeElapsed(x.AwardedAt); + x.UserTitle = Regex.Replace(x.UserTitle, @"^https?://", string.Empty); return x; }).ToList(); } diff --git a/src/MobileUI/Features/Leaderboard/LeaderViewModel.cs b/src/MobileUI/Features/Leaderboard/LeaderViewModel.cs index 9cea01e7..02c41c91 100644 --- a/src/MobileUI/Features/Leaderboard/LeaderViewModel.cs +++ b/src/MobileUI/Features/Leaderboard/LeaderViewModel.cs @@ -1,4 +1,5 @@ using System.Net.Mail; +using System.Text.RegularExpressions; using SSW.Rewards.Shared.DTOs.Leaderboard; namespace SSW.Rewards.Mobile.ViewModels; @@ -35,7 +36,7 @@ public LeaderViewModel(LeaderboardUserDto dto, bool isMe) Balance = dto.Balance; Email = dto.Email; IsMe = isMe; - Title = dto.Title; + Title = Regex.Replace(dto.Title, @"^https?://", string.Empty); } public int DisplayPoints { get; set; } diff --git a/src/MobileUI/Features/Profile/ProfileViewModelBase.cs b/src/MobileUI/Features/Profile/ProfileViewModelBase.cs index 15346078..b9f4621a 100644 --- a/src/MobileUI/Features/Profile/ProfileViewModelBase.cs +++ b/src/MobileUI/Features/Profile/ProfileViewModelBase.cs @@ -1,4 +1,5 @@ using System.Collections.ObjectModel; +using System.Text.RegularExpressions; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using Mopups.Services; @@ -147,7 +148,9 @@ private string GetTitle() return "SSW"; } - return !string.IsNullOrEmpty(CompanyUrl) ? CompanyUrl : "Community"; + return !string.IsNullOrEmpty(CompanyUrl) + ? Regex.Replace(CompanyUrl, @"^https?://", string.Empty) + : "Community"; } [RelayCommand]