| | 1 | | using AvatarSystem; |
| | 2 | | using Cysharp.Threading.Tasks; |
| | 3 | | using DCL.Helpers; |
| | 4 | | using DCL.ProfanityFiltering; |
| | 5 | | using DCLServices.CopyPaste.Analytics; |
| | 6 | | using DCLServices.Lambdas.LandsService; |
| | 7 | | using DCLServices.Lambdas.NamesService; |
| | 8 | | using DCLServices.WearablesCatalogService; |
| | 9 | | using System; |
| | 10 | | using System.Collections.Generic; |
| | 11 | | using System.Linq; |
| | 12 | | using System.Text.RegularExpressions; |
| | 13 | | using System.Threading; |
| | 14 | | using UnityEngine; |
| | 15 | |
|
| | 16 | | namespace DCL.Social.Passports |
| | 17 | | { |
| | 18 | | public class PassportNavigationComponentController : IDisposable |
| | 19 | | { |
| | 20 | | private const int MAX_NFT_COUNT = 40; |
| | 21 | |
|
| | 22 | | private readonly IProfanityFilter profanityFilter; |
| | 23 | | private readonly IWearableItemResolver wearableItemResolver; |
| | 24 | | private readonly IWearablesCatalogService wearablesCatalogService; |
| | 25 | | private readonly IEmotesCatalogService emotesCatalogService; |
| | 26 | | private readonly INamesService namesService; |
| | 27 | | private readonly ILandsService landsService; |
| | 28 | | private readonly IUserProfileBridge userProfileBridge; |
| | 29 | | private readonly DataStore dataStore; |
| | 30 | | private readonly ViewAllComponentController viewAllController; |
| | 31 | | private readonly IAdditionalInfoFieldIconProvider additionalInfoFieldIconProvider; |
| | 32 | | private readonly IClipboard clipboard; |
| | 33 | | private readonly ICopyPasteAnalyticsService copyPasteAnalyticsService; |
| 0 | 34 | | private readonly Regex linksRegex = new (@"\[(.*?)\]\((.*?)\)", RegexOptions.Multiline); |
| 0 | 35 | | private readonly List<(Sprite logo, string title, string value)> additionalFields = new (); |
| 0 | 36 | | private readonly List<UserProfileModel.Link> links = new (); |
| | 37 | |
|
| 0 | 38 | | private UserProfile ownUserProfile => userProfileBridge.GetOwn(); |
| | 39 | | private readonly IPassportNavigationComponentView view; |
| 0 | 40 | | private HashSet<string> cachedAvatarEquippedWearables = new (); |
| | 41 | | private string currentUserId; |
| 0 | 42 | | private CancellationTokenSource cts = new (); |
| | 43 | | private Promise<WearableItem[]> wearablesPromise; |
| | 44 | | private Promise<WearableItem[]> emotesPromise; |
| | 45 | |
|
| 0 | 46 | | private bool isMyAccountEnabled => dataStore.featureFlags.flags.Get().IsFeatureEnabled("my_account"); |
| | 47 | |
|
| | 48 | | public event Action<string, string> OnClickBuyNft; |
| | 49 | | public event Action OnClickedLink; |
| | 50 | | public event Action OnClickCollectibles; |
| | 51 | |
|
| 0 | 52 | | public PassportNavigationComponentController( |
| | 53 | | IPassportNavigationComponentView view, |
| | 54 | | IProfanityFilter profanityFilter, |
| | 55 | | IWearableItemResolver wearableItemResolver, |
| | 56 | | IWearablesCatalogService wearablesCatalogService, |
| | 57 | | IEmotesCatalogService emotesCatalogService, |
| | 58 | | INamesService namesService, |
| | 59 | | ILandsService landsService, |
| | 60 | | IUserProfileBridge userProfileBridge, |
| | 61 | | DataStore dataStore, |
| | 62 | | ViewAllComponentController viewAllController, |
| | 63 | | IAdditionalInfoFieldIconProvider additionalInfoFieldIconProvider, |
| | 64 | | IClipboard clipboard, |
| | 65 | | ICopyPasteAnalyticsService copyPasteAnalyticsService) |
| | 66 | | { |
| | 67 | | const string NAME_TYPE = "name"; |
| | 68 | | const string PARCEL_TYPE = "parcel"; |
| | 69 | | const string ESTATE_TYPE = "estate"; |
| | 70 | |
|
| 0 | 71 | | this.view = view; |
| 0 | 72 | | this.profanityFilter = profanityFilter; |
| 0 | 73 | | this.wearableItemResolver = wearableItemResolver; |
| 0 | 74 | | this.wearablesCatalogService = wearablesCatalogService; |
| 0 | 75 | | this.emotesCatalogService = emotesCatalogService; |
| 0 | 76 | | this.namesService = namesService; |
| 0 | 77 | | this.landsService = landsService; |
| 0 | 78 | | this.userProfileBridge = userProfileBridge; |
| 0 | 79 | | this.dataStore = dataStore; |
| 0 | 80 | | this.viewAllController = viewAllController; |
| 0 | 81 | | this.additionalInfoFieldIconProvider = additionalInfoFieldIconProvider; |
| 0 | 82 | | this.clipboard = clipboard; |
| 0 | 83 | | this.copyPasteAnalyticsService = copyPasteAnalyticsService; |
| | 84 | |
|
| 0 | 85 | | view.OnClickBuyNft += (wearableId, wearableType) => OnClickBuyNft?.Invoke(wearableType is NAME_TYPE or PARCE |
| 0 | 86 | | view.OnClickCollectibles += () => OnClickCollectibles?.Invoke(); |
| 0 | 87 | | view.OnClickedViewAll += ClickedViewAll; |
| 0 | 88 | | view.OnClickDescriptionCoordinates += OpenGoToPanel; |
| 0 | 89 | | view.OnCopyDescription += CopyDescriptionToClipboard; |
| 0 | 90 | | viewAllController.OnBackFromViewAll += BackFromViewAll; |
| 0 | 91 | | viewAllController.OnClickBuyNft += (nftId) => OnClickBuyNft?.Invoke(nftId.Category is NAME_TYPE or PARCEL_TY |
| 0 | 92 | | } |
| | 93 | |
|
| | 94 | | private void BackFromViewAll() |
| | 95 | | { |
| 0 | 96 | | view.OpenCollectiblesTab(); |
| 0 | 97 | | } |
| | 98 | |
|
| | 99 | | private void ClickedViewAll(PassportSection section) |
| | 100 | | { |
| 0 | 101 | | view.CloseAllSections(); |
| 0 | 102 | | viewAllController.SetViewAllVisibility(true); |
| 0 | 103 | | viewAllController.OpenViewAllSection(section); |
| 0 | 104 | | } |
| | 105 | |
|
| | 106 | | public void UpdateWithUserProfile(UserProfile userProfile) |
| | 107 | | { |
| | 108 | | async UniTaskVoid UpdateWithUserProfileAsync(CancellationToken cancellationToken) |
| | 109 | | { |
| 0 | 110 | | currentUserId = userProfile.userId; |
| 0 | 111 | | string filteredName = await FilterProfanityContentAsync(userProfile.userName, cancellationToken); |
| 0 | 112 | | view.SetGuestUser(userProfile.isGuest); |
| 0 | 113 | | view.SetName(filteredName); |
| 0 | 114 | | view.SetOwnUserTexts(userProfile.userId == ownUserProfile.userId); |
| | 115 | |
|
| 0 | 116 | | links.Clear(); |
| 0 | 117 | | additionalFields.Clear(); |
| | 118 | |
|
| 0 | 119 | | if (!userProfile.isGuest) |
| | 120 | | { |
| 0 | 121 | | string filteredDescription = await FilterProfanityContentAsync(userProfile.description, cancellation |
| | 122 | |
|
| 0 | 123 | | if (isMyAccountEnabled) |
| | 124 | | { |
| | 125 | | string filteredAdditionalValue; |
| | 126 | |
|
| 0 | 127 | | if (!string.IsNullOrEmpty(userProfile.AdditionalInfo.Gender)) |
| | 128 | | { |
| 0 | 129 | | filteredAdditionalValue = await FilterProfanityContentAsync(userProfile.AdditionalInfo.Gende |
| | 130 | |
|
| 0 | 131 | | additionalFields.Add(( |
| | 132 | | additionalInfoFieldIconProvider.Get(AdditionalInfoField.GENDER), |
| | 133 | | AdditionalInfoField.GENDER.ToName(), |
| | 134 | | filteredAdditionalValue)); |
| | 135 | | } |
| | 136 | |
|
| 0 | 137 | | if (!string.IsNullOrEmpty(userProfile.AdditionalInfo.Country)) |
| | 138 | | { |
| 0 | 139 | | filteredAdditionalValue = await FilterProfanityContentAsync(userProfile.AdditionalInfo.Count |
| | 140 | |
|
| 0 | 141 | | additionalFields.Add(( |
| | 142 | | additionalInfoFieldIconProvider.Get(AdditionalInfoField.COUNTRY), |
| | 143 | | AdditionalInfoField.COUNTRY.ToName(), |
| | 144 | | filteredAdditionalValue)); |
| | 145 | | } |
| | 146 | |
|
| 0 | 147 | | if (userProfile.AdditionalInfo.BirthDate != null && userProfile.AdditionalInfo.BirthDate != new |
| 0 | 148 | | additionalFields.Add(( |
| | 149 | | additionalInfoFieldIconProvider.Get(AdditionalInfoField.BIRTH_DATE), |
| | 150 | | AdditionalInfoField.BIRTH_DATE.ToName(), |
| | 151 | | userProfile.AdditionalInfo.BirthDate.Value.ToString("dd/MM/yyyy"))); |
| | 152 | |
|
| 0 | 153 | | if (!string.IsNullOrEmpty(userProfile.AdditionalInfo.Pronouns)) |
| | 154 | | { |
| 0 | 155 | | filteredAdditionalValue = await FilterProfanityContentAsync(userProfile.AdditionalInfo.Prono |
| | 156 | |
|
| 0 | 157 | | additionalFields.Add(( |
| | 158 | | additionalInfoFieldIconProvider.Get(AdditionalInfoField.PRONOUNS), |
| | 159 | | AdditionalInfoField.PRONOUNS.ToName(), |
| | 160 | | filteredAdditionalValue)); |
| | 161 | | } |
| | 162 | |
|
| 0 | 163 | | if (!string.IsNullOrEmpty(userProfile.AdditionalInfo.RelationshipStatus)) |
| | 164 | | { |
| 0 | 165 | | filteredAdditionalValue = await FilterProfanityContentAsync(userProfile.AdditionalInfo.Relat |
| | 166 | |
|
| 0 | 167 | | additionalFields.Add(( |
| | 168 | | additionalInfoFieldIconProvider.Get(AdditionalInfoField.RELATIONSHIP_STATUS), |
| | 169 | | AdditionalInfoField.RELATIONSHIP_STATUS.ToName(), |
| | 170 | | filteredAdditionalValue)); |
| | 171 | | } |
| | 172 | |
|
| 0 | 173 | | if (!string.IsNullOrEmpty(userProfile.AdditionalInfo.SexualOrientation)) |
| | 174 | | { |
| 0 | 175 | | filteredAdditionalValue = await FilterProfanityContentAsync(userProfile.AdditionalInfo.Sexua |
| | 176 | |
|
| 0 | 177 | | additionalFields.Add(( |
| | 178 | | additionalInfoFieldIconProvider.Get(AdditionalInfoField.SEXUAL_ORIENTATION), |
| | 179 | | AdditionalInfoField.SEXUAL_ORIENTATION.ToName(), |
| | 180 | | filteredAdditionalValue)); |
| | 181 | | } |
| | 182 | |
|
| 0 | 183 | | if (!string.IsNullOrEmpty(userProfile.AdditionalInfo.Language)) |
| | 184 | | { |
| 0 | 185 | | filteredAdditionalValue = await FilterProfanityContentAsync(userProfile.AdditionalInfo.Langu |
| | 186 | |
|
| 0 | 187 | | additionalFields.Add(( |
| | 188 | | additionalInfoFieldIconProvider.Get(AdditionalInfoField.LANGUAGE), |
| | 189 | | AdditionalInfoField.LANGUAGE.ToName(), |
| | 190 | | filteredAdditionalValue)); |
| | 191 | | } |
| | 192 | |
|
| 0 | 193 | | if (!string.IsNullOrEmpty(userProfile.AdditionalInfo.Profession)) |
| | 194 | | { |
| 0 | 195 | | filteredAdditionalValue = await FilterProfanityContentAsync(userProfile.AdditionalInfo.Profe |
| | 196 | |
|
| 0 | 197 | | additionalFields.Add(( |
| | 198 | | additionalInfoFieldIconProvider.Get(AdditionalInfoField.PROFESSION), |
| | 199 | | AdditionalInfoField.PROFESSION.ToName(), |
| | 200 | | filteredAdditionalValue)); |
| | 201 | | } |
| | 202 | |
|
| 0 | 203 | | if (!string.IsNullOrEmpty(userProfile.AdditionalInfo.EmploymentStatus)) |
| | 204 | | { |
| 0 | 205 | | filteredAdditionalValue = await FilterProfanityContentAsync(userProfile.AdditionalInfo.Emplo |
| | 206 | |
|
| 0 | 207 | | additionalFields.Add(( |
| | 208 | | additionalInfoFieldIconProvider.Get(AdditionalInfoField.EMPLOYMENT_STATUS), |
| | 209 | | AdditionalInfoField.EMPLOYMENT_STATUS.ToName(), |
| | 210 | | filteredAdditionalValue)); |
| | 211 | | } |
| | 212 | |
|
| 0 | 213 | | if (!string.IsNullOrEmpty(userProfile.AdditionalInfo.Hobbies)) |
| | 214 | | { |
| 0 | 215 | | filteredAdditionalValue = await FilterProfanityContentAsync(userProfile.AdditionalInfo.Hobbi |
| | 216 | |
|
| 0 | 217 | | additionalFields.Add(( |
| | 218 | | additionalInfoFieldIconProvider.Get(AdditionalInfoField.HOBBIES), |
| | 219 | | AdditionalInfoField.HOBBIES.ToName(), |
| | 220 | | filteredAdditionalValue)); |
| | 221 | | } |
| | 222 | |
|
| 0 | 223 | | if (!string.IsNullOrEmpty(userProfile.AdditionalInfo.RealName)) |
| | 224 | | { |
| 0 | 225 | | filteredAdditionalValue = await FilterProfanityContentAsync(userProfile.AdditionalInfo.RealN |
| | 226 | |
|
| 0 | 227 | | additionalFields.Add(( |
| | 228 | | additionalInfoFieldIconProvider.Get(AdditionalInfoField.REAL_NAME), |
| | 229 | | AdditionalInfoField.REAL_NAME.ToName(), |
| | 230 | | filteredAdditionalValue)); |
| | 231 | | } |
| | 232 | |
|
| 0 | 233 | | if (userProfile.Links != null) |
| 0 | 234 | | links.AddRange(userProfile.Links); |
| | 235 | | } |
| | 236 | | else |
| 0 | 237 | | filteredDescription = ExtractLinks(filteredDescription, links); |
| | 238 | |
|
| 0 | 239 | | view.SetDescription(filteredDescription); |
| 0 | 240 | | view.SetAdditionalInfo(additionalFields); |
| 0 | 241 | | view.SetLinks(links); |
| 0 | 242 | | view.SetHasBlockedOwnUser(userProfile.IsBlocked(ownUserProfile.userId)); |
| 0 | 243 | | LoadAndShowOwnedNamesAsync(userProfile, cancellationToken).Forget(); |
| 0 | 244 | | LoadAndShowOwnedLandsAsync(userProfile, cancellationToken).Forget(); |
| 0 | 245 | | LoadAndDisplayEquippedWearablesAsync(userProfile, cancellationToken).Forget(); |
| 0 | 246 | | } |
| 0 | 247 | | } |
| | 248 | |
|
| 0 | 249 | | cts?.Cancel(); |
| 0 | 250 | | cts?.Dispose(); |
| 0 | 251 | | cts = new CancellationTokenSource(); |
| 0 | 252 | | UpdateWithUserProfileAsync(cts.Token).Forget(); |
| 0 | 253 | | } |
| | 254 | |
|
| | 255 | | public void CloseAllNFTItemInfos() => |
| 0 | 256 | | view.CloseAllNFTItemInfos(); |
| | 257 | |
|
| | 258 | | public void ResetNavigationTab() |
| | 259 | | { |
| 0 | 260 | | view.SetInitialPage(); |
| 0 | 261 | | viewAllController.SetViewAllVisibility(false); |
| 0 | 262 | | } |
| | 263 | |
|
| | 264 | | public void Dispose() |
| | 265 | | { |
| 0 | 266 | | cts?.Cancel(); |
| 0 | 267 | | cts?.Dispose(); |
| 0 | 268 | | cts = null; |
| | 269 | |
|
| 0 | 270 | | wearablesPromise?.Dispose(); |
| 0 | 271 | | dataStore.HUDs.goToPanelConfirmed.OnChange -= CloseUIFromGoToPanel; |
| 0 | 272 | | } |
| | 273 | |
|
| | 274 | | private async UniTask LoadAndDisplayEquippedWearablesAsync(UserProfile userProfile, CancellationToken ct) |
| | 275 | | { |
| 0 | 276 | | foreach (var t in userProfile.avatar.wearables) |
| | 277 | | { |
| 0 | 278 | | if (!cachedAvatarEquippedWearables.Contains(t)) |
| | 279 | | { |
| 0 | 280 | | view.InitializeView(); |
| 0 | 281 | | cachedAvatarEquippedWearables = new HashSet<string>(userProfile.avatar.wearables); |
| 0 | 282 | | LoadAndShowOwnedWearables(userProfile); |
| 0 | 283 | | LoadAndShowOwnedEmotes(userProfile).Forget(); |
| | 284 | |
|
| 0 | 285 | | WearableItem[] wearableItems = await wearableItemResolver.Resolve(userProfile.avatar.wearables, ct); |
| 0 | 286 | | view.SetEquippedWearables(wearableItems, userProfile.avatar.bodyShape); |
| 0 | 287 | | return; |
| | 288 | | } |
| | 289 | | } |
| 0 | 290 | | } |
| | 291 | |
|
| | 292 | | private void LoadAndShowOwnedWearables(UserProfile userProfile) |
| | 293 | | { |
| | 294 | | async UniTaskVoid RequestOwnedWearablesAsync(CancellationToken ct) |
| | 295 | | { |
| 0 | 296 | | WearableItem[] containedWearables = Array.Empty<WearableItem>(); |
| | 297 | |
|
| | 298 | | try |
| | 299 | | { |
| 0 | 300 | | view.SetCollectibleWearablesLoadingActive(true); |
| 0 | 301 | | view.SetViewAllButtonActive(PassportSection.Wearables, false); |
| 0 | 302 | | var wearables = await wearablesCatalogService.RequestOwnedWearablesAsync( |
| | 303 | | userProfile.userId, |
| | 304 | | 1, |
| | 305 | | MAX_NFT_COUNT, |
| | 306 | | true, |
| | 307 | | ct); |
| | 308 | |
|
| 0 | 309 | | view.SetViewAllButtonActive(PassportSection.Wearables, wearables.totalAmount > MAX_NFT_COUNT); |
| 0 | 310 | | var wearableItems = wearables.wearables.GroupBy(i => i.id); |
| | 311 | |
|
| 0 | 312 | | containedWearables = wearableItems |
| 0 | 313 | | .Select(g => g.First()) |
| 0 | 314 | | .Where(wearable => wearablesCatalogService.IsValidWearable(wearable.id)) |
| | 315 | | .ToArray(); |
| 0 | 316 | | } |
| 0 | 317 | | catch (OperationCanceledException) { } |
| 0 | 318 | | catch (Exception e) { Debug.LogError(e.Message); } |
| | 319 | | finally |
| | 320 | | { |
| 0 | 321 | | view.SetCollectibleWearables(containedWearables); |
| 0 | 322 | | view.SetCollectibleWearablesLoadingActive(false); |
| | 323 | | } |
| 0 | 324 | | } |
| | 325 | |
|
| 0 | 326 | | RequestOwnedWearablesAsync(cts.Token).Forget(); |
| 0 | 327 | | } |
| | 328 | |
|
| | 329 | | private async UniTask LoadAndShowOwnedEmotes(UserProfile userProfile) |
| | 330 | | { |
| 0 | 331 | | view.SetCollectibleEmotesLoadingActive(true); |
| 0 | 332 | | var emotes = await emotesCatalogService.RequestOwnedEmotesAsync(userProfile.userId, cts.Token); |
| 0 | 333 | | WearableItem[] emoteItems = emotes.GroupBy(i => i.id).Select(g => g.First()).Take(MAX_NFT_COUNT).ToArray(); |
| 0 | 334 | | view.SetCollectibleEmotes(emoteItems); |
| 0 | 335 | | view.SetCollectibleEmotesLoadingActive(false); |
| 0 | 336 | | } |
| | 337 | |
|
| | 338 | | private async UniTask LoadAndShowOwnedNamesAsync(UserProfile userProfile, CancellationToken ct) |
| | 339 | | { |
| 0 | 340 | | NamesResponse.NameEntry[] namesResult = Array.Empty<NamesResponse.NameEntry>(); |
| 0 | 341 | | var showViewAllButton = false; |
| | 342 | |
|
| | 343 | | try |
| | 344 | | { |
| 0 | 345 | | view.SetCollectibleNamesLoadingActive(true); |
| 0 | 346 | | view.SetViewAllButtonActive(PassportSection.Names, false); |
| 0 | 347 | | var names = await namesService.RequestOwnedNamesAsync( |
| | 348 | | userProfile.userId, |
| | 349 | | 1, |
| | 350 | | MAX_NFT_COUNT, |
| | 351 | | true, |
| | 352 | | ct); |
| | 353 | |
|
| 0 | 354 | | namesResult = names.names.ToArray(); |
| 0 | 355 | | showViewAllButton = names.totalAmount > MAX_NFT_COUNT; |
| 0 | 356 | | } |
| 0 | 357 | | catch (OperationCanceledException) { } |
| 0 | 358 | | catch (Exception e) { Debug.LogException(e); } |
| | 359 | | finally |
| | 360 | | { |
| 0 | 361 | | view.SetCollectibleNames(namesResult); |
| 0 | 362 | | view.SetCollectibleNamesLoadingActive(false); |
| 0 | 363 | | view.SetViewAllButtonActive(PassportSection.Names, showViewAllButton); |
| | 364 | | } |
| 0 | 365 | | } |
| | 366 | |
|
| | 367 | | private async UniTask LoadAndShowOwnedLandsAsync(UserProfile userProfile, CancellationToken ct) |
| | 368 | | { |
| 0 | 369 | | LandsResponse.LandEntry[] landsResult = Array.Empty<LandsResponse.LandEntry>(); |
| 0 | 370 | | var showViewAllButton = false; |
| | 371 | |
|
| | 372 | | try |
| | 373 | | { |
| 0 | 374 | | view.SetCollectibleLandsLoadingActive(true); |
| 0 | 375 | | view.SetViewAllButtonActive(PassportSection.Lands, false); |
| 0 | 376 | | var lands = await landsService.RequestOwnedLandsAsync( |
| | 377 | | userProfile.userId, |
| | 378 | | 1, |
| | 379 | | MAX_NFT_COUNT, |
| | 380 | | true, |
| | 381 | | ct); |
| | 382 | |
|
| 0 | 383 | | landsResult = lands.lands.ToArray(); |
| 0 | 384 | | showViewAllButton = lands.totalAmount > MAX_NFT_COUNT; |
| 0 | 385 | | } |
| 0 | 386 | | catch (OperationCanceledException) { } |
| 0 | 387 | | catch (Exception e) { Debug.LogError(e.Message); } |
| | 388 | | finally |
| | 389 | | { |
| 0 | 390 | | view.SetCollectibleLands(landsResult); |
| 0 | 391 | | view.SetCollectibleLandsLoadingActive(false); |
| 0 | 392 | | view.SetViewAllButtonActive(PassportSection.Lands, showViewAllButton); |
| | 393 | | } |
| 0 | 394 | | } |
| | 395 | |
|
| | 396 | | private async UniTask<string> FilterProfanityContentAsync(string filterContent, CancellationToken cancellationTo |
| 0 | 397 | | IsProfanityFilteringEnabled() |
| | 398 | | ? await profanityFilter.Filter(filterContent, cancellationToken) |
| | 399 | | : filterContent; |
| | 400 | |
|
| | 401 | | private bool IsProfanityFilteringEnabled() => |
| 0 | 402 | | dataStore.settings.profanityChatFilteringEnabled.Get(); |
| | 403 | |
|
| | 404 | | private void OpenGoToPanel(ParcelCoordinates coordinates) |
| | 405 | | { |
| 0 | 406 | | dataStore.HUDs.gotoPanelVisible.Set(true, true); |
| 0 | 407 | | dataStore.HUDs.gotoPanelCoordinates.Set((coordinates, null, null), true); |
| | 408 | |
|
| 0 | 409 | | dataStore.HUDs.goToPanelConfirmed.OnChange -= CloseUIFromGoToPanel; |
| 0 | 410 | | dataStore.HUDs.goToPanelConfirmed.OnChange += CloseUIFromGoToPanel; |
| 0 | 411 | | } |
| | 412 | |
|
| | 413 | | private void CloseUIFromGoToPanel(bool confirmed, bool _) |
| | 414 | | { |
| 0 | 415 | | if (!confirmed) return; |
| 0 | 416 | | dataStore.HUDs.goToPanelConfirmed.OnChange -= CloseUIFromGoToPanel; |
| 0 | 417 | | dataStore.exploreV2.isOpen.Set(false, true); |
| 0 | 418 | | dataStore.HUDs.currentPlayerId.Set((null, null)); |
| 0 | 419 | | } |
| | 420 | |
|
| | 421 | | private string ExtractLinks(string description, ICollection<UserProfileModel.Link> linkBuffer = null) |
| | 422 | | { |
| 0 | 423 | | MatchCollection matches = linksRegex.Matches(description); |
| | 424 | |
|
| 0 | 425 | | if (matches.Count == 0) return description; |
| | 426 | |
|
| 0 | 427 | | foreach (Match match in matches) |
| | 428 | | { |
| 0 | 429 | | linkBuffer?.Add(new UserProfileModel.Link(match.Groups[1].Value, match.Groups[2].Value)); |
| 0 | 430 | | description = description.Replace(match.Value, ""); |
| | 431 | | } |
| | 432 | |
|
| 0 | 433 | | return description; |
| | 434 | | } |
| | 435 | |
|
| | 436 | | private void CopyDescriptionToClipboard() |
| | 437 | | { |
| 0 | 438 | | UserProfile userProfile = userProfileBridge.Get(currentUserId); |
| 0 | 439 | | if (userProfile == null) return; |
| 0 | 440 | | string description = userProfile.description; |
| 0 | 441 | | description = ExtractLinks(description); |
| 0 | 442 | | clipboard.WriteText(description); |
| 0 | 443 | | copyPasteAnalyticsService.Copy("player_data"); |
| 0 | 444 | | } |
| | 445 | | } |
| | 446 | | } |