Skip to content

Commit c0b3b48

Browse files
authored
Merge pull request #502 from Piwigo/v2.9.5
Merge v2.9.5 bug fixes into master
2 parents 24140f1 + a2ec8b0 commit c0b3b48

30 files changed

+440
-270
lines changed

Supporting Targets/piwigoKit/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
<key>CFBundleShortVersionString</key>
1818
<string>$(MARKETING_VERSION)</string>
1919
<key>CFBundleVersion</key>
20-
<string>443</string>
20+
<string>449</string>
2121
</dict>
2222
</plist>

piwigo.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,7 @@
30553055
"$(inherited)",
30563056
"@executable_path/Frameworks",
30573057
);
3058-
MARKETING_VERSION = 2.9.4;
3058+
MARKETING_VERSION = 2.9.5;
30593059
OTHER_LDFLAGS = (
30603060
"$(inherited)",
30613061
"-all_load",
@@ -3117,7 +3117,7 @@
31173117
"$(inherited)",
31183118
"@executable_path/Frameworks",
31193119
);
3120-
MARKETING_VERSION = 2.9.4;
3120+
MARKETING_VERSION = 2.9.5;
31213121
OTHER_LDFLAGS = (
31223122
"$(inherited)",
31233123
"-all_load",

piwigo/Album/Cells/ImageCollectionViewCell.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,23 +272,19 @@ class ImageCollectionViewCell: UICollectionViewCell {
272272
self.size.width / displayedImage.size.width, self.size.height / displayedImage.size.height))
273273
if UIDevice.current.userInterfaceIdiom == .pad {
274274
// Case of an iPad: respect aspect ratio
275-
// Image width
275+
// Image width smaller than collection view cell?
276276
let imageWidth = displayedImage.size.width * imageScale
277-
self.darkImgWidth?.constant = imageWidth
278-
279-
// Horizontal correction?
280277
if imageWidth < self.size.width {
281278
// The image does not fill the cell horizontally
279+
self.darkImgWidth?.constant = imageWidth
282280
self.deltaX += (self.size.width - imageWidth) / 2.0
283281
}
284282

285-
// Image height
283+
// Image height smaller than collection view cell?
286284
let imageHeight = displayedImage.size.height * imageScale
287-
self.darkImgHeight?.constant = imageHeight
288-
289-
// Vertical correction?
290285
if imageHeight < self.size.height {
291286
// The image does not fill the cell vertically
287+
self.darkImgHeight?.constant = imageHeight
292288
self.deltaY += (self.size.height - imageHeight) / 2.0
293289
}
294290
}

piwigo/Data Cache/ClearCache.swift

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,54 @@ import piwigoKit
1313
class ClearCache: NSObject {
1414

1515
@objc
16+
class func closeSessionAndClearCache(completion: @escaping () -> Void) {
17+
// Session closed
18+
NetworkVarsObjc.sessionManager?.invalidateSessionCancelingTasks(true, resetSession: true)
19+
NetworkVarsObjc.imagesSessionManager?.invalidateSessionCancelingTasks(true, resetSession: true)
20+
NetworkVarsObjc.imageCache?.removeAllCachedResponses()
21+
22+
// Back to default values
23+
AlbumVars.shared.defaultCategory = 0
24+
AlbumVars.shared.recentCategories = "0"
25+
NetworkVars.usesCommunityPluginV29 = false
26+
NetworkVars.hasAdminRights = false
27+
28+
// Disable Auto-Uploading and clear settings
29+
UploadVars.isAutoUploadActive = false
30+
UploadVars.autoUploadCategoryId = NSNotFound
31+
UploadVars.autoUploadAlbumId = ""
32+
UploadVars.autoUploadTagIds = ""
33+
UploadVars.autoUploadComments = ""
34+
35+
// Erase cache
36+
self.clearAllCache(exceptCategories: false) {
37+
if #available(iOS 13.0, *) {
38+
guard let window = (UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate)?.window else {
39+
return
40+
}
41+
42+
let loginVC: LoginViewController
43+
if UIDevice.current.userInterfaceIdiom == .phone {
44+
loginVC = LoginViewController_iPhone()
45+
} else {
46+
loginVC = LoginViewController_iPad()
47+
}
48+
let nav = LoginNavigationController(rootViewController: loginVC)
49+
nav.isNavigationBarHidden = true
50+
window.rootViewController = nav
51+
UIView.transition(with: window, duration: 0.5,
52+
options: .transitionCrossDissolve,
53+
animations: nil, completion: { _ in completion() })
54+
} else {
55+
// Fallback on earlier versions
56+
let appDelegate = UIApplication.shared.delegate as? AppDelegate
57+
appDelegate?.loadLoginView()
58+
}
59+
}
60+
}
61+
1662
class func clearAllCache(exceptCategories: Bool,
17-
completionHandler: @escaping () -> Void) {
63+
completion: @escaping () -> Void) {
1864

1965
// Tags
2066
TagsProvider().clearTags()
@@ -35,6 +81,6 @@ class ClearCache: NSObject {
3581
appDelegate?.cleanUpTemporaryDirectory(immediately: true)
3682

3783
// Job done
38-
completionHandler()
84+
completion()
3985
}
4086
}

piwigo/Image/Details/ImageDetailViewController.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ import piwigoKit
331331
}
332332

333333
deinit {
334+
debugPrint("••> ImageDetailViewController of image \(imageData.imageId) is being deinitialized.")
334335
// Unregister palette changes
335336
NotificationCenter.default.removeObserver(self, name: PwgNotifications.paletteChanged, object: nil)
336337
}
@@ -638,9 +639,9 @@ import piwigoKit
638639
if error.code == 401 {
639640
// Try relogin
640641
let appDelegate = UIApplication.shared.delegate as? AppDelegate
641-
appDelegate?.reloginAndRetry(completion: { [unowned self] in
642+
appDelegate?.reloginAndRetry() { [unowned self] in
642643
self.retrieveCompleteImageDataOfImage(self.imageData)
643-
})
644+
}
644645
} else {
645646
self.retrieveCompleteImageDataOfImage(self.imageData)
646647
}
@@ -832,9 +833,9 @@ import piwigoKit
832833
if error.code == 401 {
833834
// Try relogin
834835
let appDelegate = UIApplication.shared.delegate as? AppDelegate
835-
appDelegate?.reloginAndRetry(completion: { [unowned self] in
836+
appDelegate?.reloginAndRetry() { [unowned self] in
836837
self.removeImageFromCategory()
837-
})
838+
}
838839
} else {
839840
self.removeImageFromCategory()
840841
}
@@ -867,9 +868,9 @@ import piwigoKit
867868
if error.code == 401 {
868869
// Try relogin
869870
let appDelegate = UIApplication.shared.delegate as? AppDelegate
870-
appDelegate?.reloginAndRetry(completion: { [unowned self] in
871+
appDelegate?.reloginAndRetry() { [unowned self] in
871872
self.deleteImageFromDatabase()
872-
})
873+
}
873874
} else {
874875
self.deleteImageFromDatabase()
875876
}
@@ -1134,7 +1135,7 @@ import piwigoKit
11341135
} else {
11351136
// Update favorite button
11361137
self.favoriteBarButton?.setFavoriteImage(for: false)
1137-
self.favoriteBarButton?.action = #selector(addToFavorites)
1138+
self.favoriteBarButton?.action = #selector(self.addToFavorites)
11381139
self.favoriteBarButton?.isEnabled = true
11391140
}
11401141
}
@@ -1253,11 +1254,10 @@ extension ImageDetailViewController: UIPageViewControllerDataSource
12531254
}
12541255

12551256
// Should we load more images?
1256-
let downloadedImageCount = CategoriesData.sharedInstance()
1257-
.getCategoryById(categoryId).imageList.count
1258-
let totalImageCount = CategoriesData.sharedInstance()
1259-
.getCategoryById(categoryId).numberOfImages
1260-
if downloadedImageCount < totalImageCount,
1257+
let albumData = CategoriesData.sharedInstance().getCategoryById(categoryId)
1258+
let totalImageCount = albumData?.numberOfImages ?? 0
1259+
let downloadedImageCount = albumData?.imageList?.count ?? 0
1260+
if totalImageCount > 0, downloadedImageCount < totalImageCount,
12611261
imgDetailDelegate?.responds(to: #selector(ImageDetailDelegate.needToLoadMoreImages)) ?? false {
12621262
imgDetailDelegate?.needToLoadMoreImages()
12631263
}

piwigo/Image/Parameters/EditImageParamsViewController.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ class EditImageParamsViewController: UIViewController
244244
}
245245

246246
deinit {
247+
debugPrint("EditImageParamsViewController of \(images.count) image(s) is being deinitialized.")
247248
// Unregister palette changes
248249
NotificationCenter.default.removeObserver(self, name: PwgNotifications.paletteChanged, object: nil)
249250
}
@@ -400,11 +401,11 @@ class EditImageParamsViewController: UIViewController
400401
if error.code == 401 {
401402
// Try relogin
402403
let appDelegate = UIApplication.shared.delegate as? AppDelegate
403-
appDelegate?.reloginAndRetry(completion: { [unowned self] in
404+
appDelegate?.reloginAndRetry() { [unowned self] in
404405
self.updateImageProperties()
405-
})
406+
}
406407
} else {
407-
updateImageProperties()
408+
self.updateImageProperties()
408409
}
409410
})
410411
} else {
@@ -414,11 +415,11 @@ class EditImageParamsViewController: UIViewController
414415
if error.code == 401 {
415416
// Try relogin
416417
let appDelegate = UIApplication.shared.delegate as? AppDelegate
417-
appDelegate?.reloginAndRetry(completion: { [unowned self] in
418+
appDelegate?.reloginAndRetry() { [unowned self] in
418419
self.updateImageProperties()
419-
})
420+
}
420421
} else {
421-
updateImageProperties()
422+
self.updateImageProperties()
422423
}
423424
})
424425
}

piwigo/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<key>CFBundleShortVersionString</key>
2626
<string>$(MARKETING_VERSION)</string>
2727
<key>CFBundleVersion</key>
28-
<string>443</string>
28+
<string>449</string>
2929
<key>INIntentsSupported</key>
3030
<array>
3131
<string>AutoUploadIntent</string>

0 commit comments

Comments
 (0)