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

coding

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

+ 6 - 1
Widget/Nextcloud/NextcloudData.swift

@@ -221,7 +221,12 @@ func getNextcloudDataEntry(isPreview: Bool, displaySize: CGSize, completion: @es
         if error != .success {
         if error != .success {
             completion(NextcloudDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, tile: title, footerImage: "xmark.icloud", footerText: error.errorDescription))
             completion(NextcloudDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, tile: title, footerImage: "xmark.icloud", footerText: error.errorDescription))
         } else if datas.isEmpty {
         } else if datas.isEmpty {
-            completion(NextcloudDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, tile: title, footerImage: "checkmark.icloud", footerText: NSLocalizedString("_no_data_available_", comment: "")))
+            var footerText = NSLocalizedString("_no_data_available_", comment: "")
+            let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
+            if serverVersionMajor < NCGlobal.shared.nextcloudVersion25 {
+                footerText = NSLocalizedString("_widget_available_nc25_", comment: "")
+            }
+            completion(NextcloudDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, tile: title, footerImage: "checkmark.icloud", footerText: footerText))
         } else {
         } else {
             completion(NextcloudDataEntry(date: Date(), datas: datas, isPlaceholder: false, tile: title, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " widget"))
             completion(NextcloudDataEntry(date: Date(), datas: datas, isPlaceholder: false, tile: title, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " widget"))
         }
         }

+ 9 - 6
iOSClient/Networking/NCService.swift

@@ -270,14 +270,17 @@ class NCService: NSObject {
 
 
     private func requestDashboardWidget() {
     private func requestDashboardWidget() {
         
         
+        let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
         let options = NKRequestOptions(queue: NKCommon.shared.backgroundQueue)
         let options = NKRequestOptions(queue: NKCommon.shared.backgroundQueue)
 
 
-        NextcloudKit.shared.getDashboardWidget(options: options) { account, dashboardWidgets, data, error in
-            if error == .success, let dashboardWidgets = dashboardWidgets  {
-                NCManageDatabase.shared.addDashboardWidget(account: account, dashboardWidgets: dashboardWidgets)
-                for widget in dashboardWidgets {
-                    if let url = URL(string: widget.iconUrl), let fileName = widget.iconClass {
-                        NCUtility.shared.getImageUserData(url: url, fileName: fileName, size: 128)
+        if serverVersionMajor >= NCGlobal.shared.nextcloudVersion25 {
+            NextcloudKit.shared.getDashboardWidget(options: options) { account, dashboardWidgets, data, error in
+                if error == .success, let dashboardWidgets = dashboardWidgets  {
+                    NCManageDatabase.shared.addDashboardWidget(account: account, dashboardWidgets: dashboardWidgets)
+                    for widget in dashboardWidgets {
+                        if let url = URL(string: widget.iconUrl), let fileName = widget.iconClass {
+                            NCUtility.shared.getImageUserData(url: url, fileName: fileName, size: 128)
+                        }
                     }
                     }
                 }
                 }
             }
             }

+ 1 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -888,6 +888,7 @@
 "_description_nextcloudwidget_" = "View your recent files and use the toolbar to speed up your operations.";
 "_description_nextcloudwidget_" = "View your recent files and use the toolbar to speed up your operations.";
 "_description_toolbarwidget_"   = "A the toolbar to speed up your operations.";
 "_description_toolbarwidget_"   = "A the toolbar to speed up your operations.";
 "_no_data_available_"       = "no data available";
 "_no_data_available_"       = "no data available";
+"_widget_available_nc25_"   = "Widget only available starting with Nextcloud 25";
 
 
 // Video
 // Video
 "_select_trace_"            = "Select the trace";
 "_select_trace_"            = "Select the trace";