| | 1 | | using Cysharp.Threading.Tasks; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | namespace DCL.Social.Passports |
| | 7 | | { |
| | 8 | | public class PassportNavigationComponentController |
| | 9 | | { |
| | 10 | | private readonly IProfanityFilter profanityFilter; |
| | 11 | | private readonly DataStore dataStore; |
| | 12 | |
|
| | 13 | | private IPassportNavigationComponentView view; |
| | 14 | |
|
| 2 | 15 | | public PassportNavigationComponentController(IPassportNavigationComponentView view, IProfanityFilter profanityFi |
| | 16 | | { |
| 2 | 17 | | this.view = view; |
| 2 | 18 | | this.profanityFilter = profanityFilter; |
| 2 | 19 | | this.dataStore = dataStore; |
| 2 | 20 | | } |
| | 21 | |
|
| 0 | 22 | | public void UpdateWithUserProfile(UserProfile userProfile) => UpdateWithUserProfileAsync(userProfile); |
| | 23 | |
|
| | 24 | | private async UniTask UpdateWithUserProfileAsync(UserProfile userProfile) |
| | 25 | | { |
| 0 | 26 | | string filteredName = await FilterName(userProfile); |
| 0 | 27 | | view.SetName(filteredName); |
| 0 | 28 | | view.SetGuestUser(userProfile.isGuest); |
| 0 | 29 | | } |
| | 30 | |
|
| | 31 | | private async UniTask<string> FilterName(UserProfile userProfile) |
| | 32 | | { |
| 0 | 33 | | return IsProfanityFilteringEnabled() |
| | 34 | | ? await profanityFilter.Filter(userProfile.userName) |
| | 35 | | : userProfile.userName; |
| 0 | 36 | | } |
| | 37 | |
|
| | 38 | | private bool IsProfanityFilteringEnabled() |
| | 39 | | { |
| 0 | 40 | | return dataStore.settings.profanityChatFilteringEnabled.Get(); |
| | 41 | | } |
| | 42 | | } |
| | 43 | | } |