Skip to content

Commit

Permalink
rename protocol Asset
Browse files Browse the repository at this point in the history
  • Loading branch information
billypchan committed May 31, 2021
1 parent 167e9a8 commit c6b519d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions Source/Model/Message/ZMAssetClientMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ extension ZMAssetClientMessage {
case uploading
}

struct CacheAsset: Asset {
struct CacheAsset: AssetType {

enum AssetType {
case image, file, thumbnail
Expand Down Expand Up @@ -482,10 +482,10 @@ struct CacheAsset: Asset {

extension ZMAssetClientMessage: AssetMessage {

public var assets: [Asset] {
public var assets: [AssetType] {
guard let cache = managedObjectContext?.zm_fileAssetCache else { return [] }

var assets: [Asset] = []
var assets: [AssetType] = []

if isFile {
if cache.hasDataOnDisk(self, encrypted: false) {
Expand Down Expand Up @@ -527,15 +527,16 @@ public protocol AssetMessage {
/// List of assets which the message contains.
///
/// NOTE: The order of this list needs to be stable.
var assets: [Asset] { get }
var assets: [AssetType] { get }

/// Summary of the processing state for the assets
var processingState: AssetProcessingState { get }

}

/// Represent a single asset like file, thumbnail, image and image preview.
public protocol Asset {
/// rename to AssetType to prevent build error due to name conflict with Proto.Asset struct
public protocol AssetType {

/// True if the original unprocessed data is available on disk
var hasOriginal: Bool { get }
Expand Down
4 changes: 2 additions & 2 deletions Source/Model/User/ZMSearchUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fileprivate enum AssetSize: String {
case complete
}

fileprivate enum AssetType: String {
fileprivate enum AssetKind: String {
case image
}

Expand All @@ -61,7 +61,7 @@ public struct SearchUserAssetKeys {
for asset in assetsPayload {
guard let size = (asset[ResponseKey.assetSize.rawValue] as? String).flatMap(AssetSize.init),
let key = asset[ResponseKey.assetKey.rawValue] as? String,
let type = (asset[ResponseKey.assetType.rawValue] as? String).flatMap(AssetType.init),
let type = (asset[ResponseKey.assetType.rawValue] as? String).flatMap(AssetKind.init),
type == .image else { continue }

switch size {
Expand Down

0 comments on commit c6b519d

Please sign in to comment.