Skip to content

Commit

Permalink
Merge pull request #126 from nohana/feature/avoid_crash
Browse files Browse the repository at this point in the history
Avoid crash.
  • Loading branch information
tyokujin authored Dec 1, 2021
2 parents cf0fedf + 7d03dfe commit f288809
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions NohanaImagePicker/AssetDateSectionCreater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ final class AssetDateSectionCreater {
var assetsByDateIndex = 0
for asset in allAssets {
if assetsByDateIndex > 0 {
if assetsByDate[assetsByDateIndex - 1].0 == calender.dateComponents([.day, .year, .month], from: (asset.creationDate)!) {
if assetsByDate[assetsByDateIndex - 1].0 == calender.dateComponents([.day, .year, .month], from: (asset.creationDate ?? Date(timeIntervalSince1970: 0))) {
assetsByDate[assetsByDateIndex - 1].1.append(asset)
} else {
let value = (calender.dateComponents([.day, .year, .month], from: (asset.creationDate)!), [asset])
let value = (calender.dateComponents([.day, .year, .month], from: (asset.creationDate ?? Date(timeIntervalSince1970: 0))), [asset])
assetsByDate.append(value)
assetsByDateIndex += 1
}
} else if assetsByDate.count == assetsByDateIndex {
let value = (calender.dateComponents([.day, .year, .month], from: (asset.creationDate)!), [asset])
let value = (calender.dateComponents([.day, .year, .month], from: (asset.creationDate ?? Date(timeIntervalSince1970: 0))), [asset])
assetsByDate.append(value)
assetsByDateIndex += 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ class AssetListSelectableDateSectionController: UICollectionViewController, UICo
assetListDetailCurrentRow += dateSectionList[section].assetResult.count
}
}
if assetListDetailCurrentRow >= photoKitAssetList.count {
assetListDetailCurrentRow = photoKitAssetList.count - 1
}

let assetListDetailViewController = segue.destination as! AssetDetailListViewController
assetListDetailViewController.photoKitAssetList = photoKitAssetList
Expand Down

0 comments on commit f288809

Please sign in to comment.