wxr
2021-11-23 ccd5b1c8dc2d0399745779fb4f9a261d24d75a6d
HDL-ON_iOS/Other/Siri/VoiceShortcutDataManager.cs
@@ -8,6 +8,7 @@
using System;
using Intents;
using System.Linq;
using HDLSceneSiri;
namespace Other.Siri
{
@@ -20,11 +21,16 @@
            UpdateVoiceShortcuts(null);
        }
        public VoiceShortcutDataManager(Action action)
        {
            UpdateVoiceShortcuts(action);
        }
        public INVoiceShortcut VoiceShortcutForOrder(SiriScene ss)
        {
            var voiceShortcut = VoiceShortcuts.FirstOrDefault((shortcut) =>
            {
                var intent = shortcut.Shortcut.Intent as HdlSiri.HDLRunSceneIntent;
                var intent = shortcut.Shortcut.Intent as HDLRunSceneIntent;
                if (intent is null) { return false; }
                var orderFromIntent = SiriScene.FromOrderSoupIntent(intent);
                if (orderFromIntent is null) { return false; }
@@ -33,6 +39,36 @@
            return voiceShortcut;
        }
        public INVoiceShortcut VoiceShortcutForOrder2(SiriScene ss)
        {
            var voiceShortcut = VoiceShortcuts.FirstOrDefault((shortcut) =>
            {
                var intent = shortcut.Shortcut.Intent as HDLRunSceneIntent;
                if (intent is null) { return false; }
                var orderFromIntent = SiriScene.FromOrderSoupIntent(intent);
                if (orderFromIntent is null) { return false; }
                return ss.IsEqual(orderFromIntent);
            });
            return voiceShortcut;
        }
        public INVoiceShortcut FirstTemp ()
        {
            try
            {
                if(VoiceShortcuts == null)
                {
                    UpdateVoiceShortcuts(null);
                }
                return VoiceShortcuts[0];
            }
            catch
            {
                return null;
            }
        }
        public void UpdateVoiceShortcuts(Action completion)
        {
            INVoiceShortcutCenter.SharedCenter.GetAllVoiceShortcuts((voiceShortcutsFromCenter, error) =>