Эх сурвалжийг харах

Added default application (widget)

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 жил өмнө
parent
commit
7a7098c1c1

+ 3 - 2
Widget/Dashboard/DashboardData.swift

@@ -91,8 +91,9 @@ func getDashboardDataEntry(intent: Applications?, isPreview: Bool, displaySize:
         return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, tableDashboard: nil, tableButton: nil, isPlaceholder: true, titleImage: UIImage(named: "widget")!, title: "Dashboard", footerImage: "xmark.icloud", footerText: NSLocalizedString("_no_active_account_", comment: "")))
     }
 
-    // Default widget: recommendations
-    let id: String = intent?.identifier ?? "recommendations"
+    // Default widget
+    let result = NCManageDatabase.shared.getDashboardWidgetApplications(account: account.account).first
+    let id: String = intent?.identifier ?? (result?.id ?? "recommendations")
 
     let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
 

+ 12 - 2
WidgetDashboardIntentHandler/IntentHandler.swift

@@ -26,7 +26,17 @@ class IntentHandler: INExtension, DashboardIntentHandling {
             applications.append(application)
         }
 
-        let collection = INObjectCollection(items: applications)
-        completion(collection, nil)
+        completion(INObjectCollection(items: applications), nil)
+    }
+
+    func defaultApplications(for intent: DashboardIntent) -> Applications? {
+
+        guard let account = NCManageDatabase.shared.getActiveAccount() else {
+            return nil
+        }
+        if let result = NCManageDatabase.shared.getDashboardWidgetApplications(account: account.account).first {
+            return Applications(identifier: result.id, display: result.title)
+        }
+        return nil
     }
 }