Added default application (widget)

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
This commit is contained in:
Marino Faggiana 2022-10-12 17:57:34 +02:00
Родитель 744cdfb36f
Коммит 7a7098c1c1
2 изменённых файлов: 15 добавлений и 4 удалений

Просмотреть файл

@ -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)

Просмотреть файл

@ -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
}
}