瀏覽代碼

Fixed Notifications Indicator Refresh
Removed Alert from Warehousing and Stores Modules

Frank van den Bos 2 年之前
父節點
當前提交
dbf26017ee
共有 2 個文件被更改,包括 15 次插入22 次删除
  1. 0 2
      prs.mobile.new/PRS.Mobile/MainPage.xaml
  2. 15 20
      prs.mobile.new/PRS.Mobile/MainPage.xaml.cs

+ 0 - 2
prs.mobile.new/PRS.Mobile/MainPage.xaml

@@ -159,7 +159,6 @@
                         x:Name="StoreRequis"
                         Text="Stores"
                         Image="trolley"
-                        Indicator="!"
                         Tapped="StoreRequis_OnTapped"/>  
                                 
                     <mobile:MobileMobileToolItem
@@ -172,7 +171,6 @@
                         x:Name="Warehousing"
                         Text="Warehouse"
                         Image="warehouse.png"
-                        Indicator="!"
                         Tapped="Warehousing_OnTapped"/>  
      
                 </mobile:MobileToolGrid.Items>

+ 15 - 20
prs.mobile.new/PRS.Mobile/MainPage.xaml.cs

@@ -93,6 +93,8 @@ namespace PRS.Mobile
             MobileLogging.Log("MainPage.Appearing");
             if (_selectionpage == null)
             {
+                _notificationsToken = new CancellationTokenSource();
+                
                 BackButtonEnabled = App.IsSharedDevice;
 
                 EnableModules();
@@ -108,12 +110,6 @@ namespace PRS.Mobile
 
                 CheckTimeSheet();
             }
-
-            App.Data.Notifications.Refresh(false, () => Device.BeginInvokeOnMainThread(() =>
-            {
-                var count = App.Data.Notifications.Items.Count(x => x.Closed.IsEmpty());
-                Notifications.Indicator = count > 0 ? count.ToString() : "";
-            }));
             
             _selectionpage = null;
 
@@ -132,7 +128,7 @@ namespace PRS.Mobile
             //App.Data.GPSLocationUpdated -= OnGPSLocationUpdated;
             //App.Data.BluetoothScanFinished -= OnBluetothScanFinished;
             
-            _canceltasks.Cancel();
+            _notificationsToken.Cancel();
         }
         
         private void OnBluetothScanFinished(BluetoothEventArgs args)
@@ -177,7 +173,7 @@ namespace PRS.Mobile
             RefreshScreen();
         }
         
-        private CancellationTokenSource _canceltasks = new CancellationTokenSource();
+        private CancellationTokenSource _notificationsToken = new CancellationTokenSource();
         private int _notificationcount = 0;
         
         private void StartMonitoringNotifications()
@@ -185,22 +181,21 @@ namespace PRS.Mobile
             //notifications are allowed to upload once every 30 seconds
             // This will eventually be replaced with websocket pushes
             // but we're not ready for that yet :-(
-            var token = _canceltasks.Token;
+            var token = _notificationsToken.Token;
             Task.Run(
                 () =>
                 {
-                    while (!_canceltasks.Token.IsCancellationRequested)
+                    while (!_notificationsToken.Token.IsCancellationRequested)
                     {
                         App.Data.Notifications.Refresh(true);
-                        if (App.Data.Notifications.Items.Count != _notificationcount)
+                        _notificationcount = App.Data.Notifications.Items.Where(x=>x.Closed.IsEmpty()).ToList().Count;
+                        Dispatcher.BeginInvokeOnMainThread(() =>
                         {
-                            Dispatcher.BeginInvokeOnMainThread(() =>
-                            {
-                                _notificationcount = App.Data.Notifications.Items.Count;
-                                Notifications.Indicator = _notificationcount.ToString();
-                            });
-                        }
-
+                            Notifications.Indicator = _notificationcount > 0
+                                ? _notificationcount.ToString()
+                                : "";
+                        });
+                        
                         Task.Delay(TimeSpan.FromSeconds(30), token)
                             .Wait(token);
                     }
@@ -211,7 +206,7 @@ namespace PRS.Mobile
         
         private void StartPromptingForUpdates()
         {
-            var token = _canceltasks.Token;
+            var token = _notificationsToken.Token;
             Task.Run(
                 () =>
                 {
@@ -309,7 +304,7 @@ namespace PRS.Mobile
                 _currenttimesheet = table.Rows.FirstOrDefault()?.ToObject<TimeSheet>();
             }
 
-            var token = _canceltasks.Token;
+            var token = _notificationsToken.Token;
             Task.Run(
                 () =>
                 {