| | 1 | | using DCL.NotificationModel; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | public class NotificationsController : MonoBehaviour |
| | 5 | | { |
| 0 | 6 | | public static NotificationsController i { get; private set; } |
| | 7 | | public static bool disableWelcomeNotification = false; |
| | 8 | |
|
| 0 | 9 | | public bool allowNotifications { get; set; } |
| | 10 | |
|
| 132 | 11 | | void Awake() { i = this; } |
| | 12 | |
|
| | 13 | | INotificationHUDController controller; |
| | 14 | |
|
| | 15 | | public void Initialize(INotificationHUDController controller) |
| | 16 | | { |
| 0 | 17 | | this.controller = controller; |
| 0 | 18 | | allowNotifications = true; |
| 0 | 19 | | } |
| | 20 | |
|
| 20 | 21 | | public void Dispose() { controller.Dispose(); } |
| | 22 | |
|
| | 23 | | public void ShowNotificationFromJson(string notificationJson) |
| | 24 | | { |
| 0 | 25 | | if (!allowNotifications) |
| 0 | 26 | | return; |
| | 27 | |
|
| 0 | 28 | | Model model = JsonUtility.FromJson<Model>(notificationJson); |
| 0 | 29 | | ShowNotification(model); |
| 0 | 30 | | } |
| | 31 | |
|
| | 32 | | public void ShowNotification(Model notification) |
| | 33 | | { |
| 13 | 34 | | if (!allowNotifications) |
| 13 | 35 | | return; |
| | 36 | |
|
| 0 | 37 | | controller?.ShowNotification(notification); |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | public void ShowNotification(INotification notification) |
| | 41 | | { |
| 2 | 42 | | if (!allowNotifications) |
| 0 | 43 | | return; |
| | 44 | |
|
| 2 | 45 | | controller?.ShowNotification(notification); |
| 2 | 46 | | } |
| | 47 | |
|
| 14 | 48 | | public void DismissAllNotifications(string groupID) { controller?.DismissAllNotifications(groupID); } |
| | 49 | |
|
| | 50 | | public void ShowWelcomeNotification() |
| | 51 | | { |
| 0 | 52 | | if (!allowNotifications || disableWelcomeNotification) |
| 0 | 53 | | return; |
| | 54 | |
|
| | 55 | | //TODO(Brian): This should be triggered entirely by kernel |
| 0 | 56 | | controller?.ShowWelcomeNotification(); |
| 0 | 57 | | } |
| | 58 | | } |