refactor: Decouple grouping logic from core worker
This commit is contained in:
@@ -39,7 +39,8 @@ namespace Cryville.EEW.Unity {
|
||||
[SerializeField] EventGroupListView m_historyEventGroupList;
|
||||
[SerializeField] GameObject m_connectingHint;
|
||||
|
||||
GroupingCoreWorker _worker;
|
||||
CoreWorker _worker;
|
||||
ReportGrouper _grouper;
|
||||
CancellationTokenSource _cancellationTokenSource;
|
||||
|
||||
void Awake() {
|
||||
@@ -52,6 +53,7 @@ namespace Cryville.EEW.Unity {
|
||||
App.Init();
|
||||
|
||||
_worker = new(new TTSWorker());
|
||||
_grouper = new ReportGrouper();
|
||||
_cancellationTokenSource = new();
|
||||
}
|
||||
|
||||
@@ -64,8 +66,8 @@ namespace Cryville.EEW.Unity {
|
||||
_worker.TTSMessageGeneratorContext = SharedSettings.Instance;
|
||||
_ongoingReportManager.Changed += OnOngoingReported;
|
||||
_worker.Reported += OnReported;
|
||||
_worker.GroupUpdated += OnGroupUpdated;
|
||||
_worker.GroupRemoved += OnGroupRemoved;
|
||||
_grouper.GroupUpdated += OnGroupUpdated;
|
||||
_grouper.GroupRemoved += OnGroupRemoved;
|
||||
Task.Run(() => GatewayVerify(_cancellationTokenSource.Token)).ContinueWith(task => {
|
||||
if (task.IsFaulted) {
|
||||
OnReported(this, new() { Title = task.Exception.Message });
|
||||
@@ -189,6 +191,7 @@ namespace Cryville.EEW.Unity {
|
||||
void OnReported(object sender, ReportViewModel e) {
|
||||
if (e.Model is Exception && e.Model is not SourceWorkerNetworkException)
|
||||
Debug.LogError(e);
|
||||
_grouper.Report(e);
|
||||
_ongoingReportManager.Report(e);
|
||||
_uiActionQueue.Enqueue(() => {
|
||||
if (m_mapElementManager.OngoingCount == 0) {
|
||||
|
Reference in New Issue
Block a user