| | 1 | | using DCL.ProfanityFiltering; |
| | 2 | | using DCL.Providers; |
| | 3 | | using DCL.SettingsCommon; |
| | 4 | | using DCL.Social.Chat; |
| | 5 | | using DCL.Social.Friends; |
| | 6 | | using System.Threading; |
| | 7 | | using UnityEngine; |
| | 8 | |
|
| | 9 | | namespace DCL.Chat.Notifications |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Plugin feature that initialize the chat notifications feature. |
| | 13 | | /// </summary> |
| | 14 | | public class ChatNotificationsFeature : IPlugin |
| | 15 | | { |
| 0 | 16 | | private readonly CancellationTokenSource cts = new (); |
| | 17 | |
|
| | 18 | | private ChatNotificationController chatNotificationController; |
| | 19 | |
|
| 0 | 20 | | public ChatNotificationsFeature() |
| | 21 | | { |
| 0 | 22 | | Initialize(cts.Token); |
| 0 | 23 | | } |
| | 24 | |
|
| | 25 | | private async void Initialize(CancellationToken ct) |
| | 26 | | { |
| 0 | 27 | | ServiceLocator serviceLocator = Environment.i.serviceLocator; |
| | 28 | |
|
| 0 | 29 | | var chatView = await Environment.i.serviceLocator.Get<IAddressableResourceProvider>() |
| | 30 | | .Instantiate<MainChatNotificationsComponentView>("ChatNotificationHUD", cancella |
| | 31 | |
|
| 0 | 32 | | var notificationView = await Environment.i.serviceLocator.Get<IAddressableResourceProvider>() |
| | 33 | | .Instantiate<TopNotificationComponentView>("TopNotificationHUD", cancellationTo |
| | 34 | |
|
| 0 | 35 | | chatNotificationController = new ChatNotificationController(DataStore.i, |
| | 36 | | chatView, |
| | 37 | | notificationView, |
| | 38 | | serviceLocator.Get<IChatController>(), |
| | 39 | | serviceLocator.Get<IFriendsController>(), |
| | 40 | | new UserProfileWebInterfaceBridge(), |
| | 41 | | serviceLocator.Get<IProfanityFilter>(), |
| | 42 | | Settings.i.audioSettings); |
| 0 | 43 | | } |
| | 44 | |
|
| | 45 | | public void Dispose() |
| | 46 | | { |
| 0 | 47 | | cts.Cancel(); |
| 0 | 48 | | cts.Dispose(); |
| 0 | 49 | | chatNotificationController.Dispose(); |
| 0 | 50 | | } |
| | 51 | | } |
| | 52 | | } |