Browse Source

Add message

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 3 years ago
parent
commit
b78e97b176

+ 5 - 9
iOSClient/Data/NCManageDatabase+Metadata.swift

@@ -808,22 +808,18 @@ extension NCManageDatabase {
         return getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView == %@", account, serverUrl, fileNameConflict))
     }
 
-    func getSubtitles(account: String, serverUrl: String, fileName: String, exists: Bool) -> [tableMetadata] {
+    func getSubtitles(account: String, serverUrl: String, fileName: String) -> (all:[tableMetadata], exists:[tableMetadata]) {
 
         let realm = try! Realm()
         let nameOnly = (fileName as NSString).deletingPathExtension + "."
         var metadatas: [tableMetadata] = []
 
         let results = realm.objects(tableMetadata.self).filter("account == %@ AND serverUrl == %@ AND fileName BEGINSWITH[c] %@ AND fileName ENDSWITH[c] '.srt'", account, serverUrl, nameOnly)
-        if exists {
-            for result in results {
-                if CCUtility.fileProviderStorageExists(result) {
-                    metadatas.append(result)
-                }
+        for result in results {
+            if CCUtility.fileProviderStorageExists(result) {
+                metadatas.append(result)
             }
-            return Array(metadatas.map { tableMetadata.init(value: $0) })
-        } else {
-            return Array(results.map { tableMetadata.init(value: $0) })
         }
+        return(Array(results.map { tableMetadata.init(value: $0) }), Array(metadatas.map { tableMetadata.init(value: $0) }))
     }
 }

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

@@ -848,4 +848,5 @@
 "_video_tap_for_close_"     = "A slight pressure to close the processing";
 "_subtitle_not_found_"      = "Subtitle not found";
 "_disable_"                 = "Disable";
+"_subtitle_not_dowloaded_"  = "There are subtitles not downloaded locally";
 

+ 6 - 3
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCSubtitle/NCSubtitlePlayer.swift

@@ -126,13 +126,16 @@ extension NCPlayer {
                 }
             }
         }
-        let subtitles = NCManageDatabase.shared.getSubtitles(account: metadata.account, serverUrl: metadata.serverUrl, fileName: metadata.fileName, exists: true)
-        if !subtitles.isEmpty {
-            for subtitle in subtitles {
+        let results = NCManageDatabase.shared.getSubtitles(account: metadata.account, serverUrl: metadata.serverUrl, fileName: metadata.fileName)
+        if !results.exists.isEmpty {
+            for subtitle in results.exists {
                 let subtitleUrl = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(subtitle.ocId, fileNameView: subtitle.fileName))
                 self.subtitleUrls.append(subtitleUrl)
             }
         }
+        if results.all.count != results.exists.count {
+            NCContentPresenter.shared.messageNotification("_info_", description: "_subtitle_not_dowloaded_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorNoError)
+        }
         self.setSubtitleToolbarIcon(subtitleUrls: subtitleUrls)
         self.hideSubtitle()
     }