Browse Source

add comments, free memory when leaving gallery

B. Petersen 2 years ago
parent
commit
1ebf291963
1 changed files with 7 additions and 0 deletions
  1. 7 0
      deltachat-ios/Controller/GalleryViewController.swift

+ 7 - 0
deltachat-ios/Controller/GalleryViewController.swift

@@ -94,11 +94,18 @@ class GalleryViewController: UIViewController {
     }
     }
 
 
     override func viewWillAppear(_ animated: Bool) {
     override func viewWillAppear(_ animated: Bool) {
+        // if would be better to reload on the corresponding events, see #1846
         galleryItemCache = [:]
         galleryItemCache = [:]
         grid.reloadData()
         grid.reloadData()
+
         setupContextMenuIfNeeded()
         setupContextMenuIfNeeded()
     }
     }
 
 
+    override func viewDidDisappear(_ animated: Bool) {
+        // user leaves view and may not come back soon: clearing cache may free a significant amount of memory
+        galleryItemCache = [:]
+    }
+
     override func viewWillLayoutSubviews() {
     override func viewWillLayoutSubviews() {
         super.viewWillLayoutSubviews()
         super.viewWillLayoutSubviews()
         self.reloadCollectionViewLayout()
         self.reloadCollectionViewLayout()