Skip to content

Commit

Permalink
feat: downloader auto-refresh downloadURL
Browse files Browse the repository at this point in the history
  • Loading branch information
wzxha committed Dec 12, 2023
1 parent 54c1563 commit 58417d6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Demo/Demo/DisplayItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ extension AliyunpanFile: Hashable {
}
}

extension DownloadResult: Hashable {
extension AliyunpanDownloadResult: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(progress)
hasher.combine(url)
}

public static func == (lhs: DownloadResult, rhs: DownloadResult) -> Bool {
public static func == (lhs: AliyunpanDownloadResult, rhs: AliyunpanDownloadResult) -> Bool {
lhs.hashValue == rhs.hashValue
}
}

struct DisplayItem: Hashable {
let file: AliyunpanFile
let downloadResult: DownloadResult?
let downloadResult: AliyunpanDownloadResult?

public func hash(into hasher: inout Hasher) {
hasher.combine(file)
Expand All @@ -42,7 +42,7 @@ struct DisplayItem: Hashable {
lhs.hashValue == rhs.hashValue
}

init(file: AliyunpanFile, downloadResult: DownloadResult?) {
init(file: AliyunpanFile, downloadResult: AliyunpanDownloadResult?) {
self.file = file
self.downloadResult = downloadResult
}
Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo/FileCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import AliyunpanSDK
protocol FileCellDelegate: AnyObject {
func getDownloader(for item: DisplayItem) -> AliyunpanDownloader?

func fileCell(_ cell: FileCell, didUpdateDownloadResult result: DownloadResult, for item: DisplayItem)
func fileCell(_ cell: FileCell, didUpdateDownloadResult result: AliyunpanDownloadResult, for item: DisplayItem)
func fileCell(_ cell: FileCell, willOpen item: DisplayItem)
}

Expand Down
4 changes: 2 additions & 2 deletions Demo/Demo/FileListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class FileListViewController: UIViewController {
dataSource.apply(snapshot)
}

private func updateDownloadResult(_ result: DownloadResult, for item: DisplayItem) {
private func updateDownloadResult(_ result: AliyunpanDownloadResult, for item: DisplayItem) {
guard let index = displayItems.firstIndex(where: { $0.file == item.file }) else {
return
}
Expand Down Expand Up @@ -210,7 +210,7 @@ extension FileListViewController: FileCellDelegate {
}
}

func fileCell(_ cell: FileCell, didUpdateDownloadResult result: DownloadResult, for item: DisplayItem) {
func fileCell(_ cell: FileCell, didUpdateDownloadResult result: AliyunpanDownloadResult, for item: DisplayItem) {
updateDownloadResult(result, for: item)
}
}
Expand Down

0 comments on commit 58417d6

Please sign in to comment.