浏览代码

refresh sdwebimage cache when choosing a new background image

cyberta 3 年之前
父节点
当前提交
65baaf100e
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      deltachat-ios/Controller/SettingsBackgroundSelectionController.swift

+ 4 - 2
deltachat-ios/Controller/SettingsBackgroundSelectionController.swift

@@ -63,7 +63,7 @@ class SettingsBackgroundSelectionController: UIViewController, MediaPickerDelega
         view.translatesAutoresizingMaskIntoConstraints = false
         view.clipsToBounds = true
         if let backgroundImageURL = UserDefaults.standard.string(forKey: Constants.Keys.backgroundImageUrl) {
-            view.sd_setImage(with: URL(fileURLWithPath: backgroundImageURL), completed: nil)
+            view.sd_setImage(with: URL(fileURLWithPath: backgroundImageURL), placeholderImage: nil, options: .refreshCached, completed: nil)
         } else {
             setDefault(view)
         }
@@ -148,7 +148,9 @@ class SettingsBackgroundSelectionController: UIViewController, MediaPickerDelega
         if let pathInDocDir = ImageFormat.saveImage(image: image, name: Constants.backgroundImageName) {
             UserDefaults.standard.set(pathInDocDir, forKey: Constants.Keys.backgroundImageUrl)
             UserDefaults.standard.synchronize()
-            backgroundContainer.image = image
+            backgroundContainer.sd_setImage(with: URL(fileURLWithPath: pathInDocDir), placeholderImage: nil, options: .refreshCached, completed: nil)
+        } else {
+            logger.error("failed to save background image")
         }
     }
 }