Renamed the Model and ModelIdentifiable protocols for the Browse module as FileSystemItem and FileSystemItemIdentifiable respectively.

This commit is contained in:
Javier Cicchelli 2022-12-14 01:12:27 +01:00
parent 627698e1bf
commit 9a3b9049c7
4 changed files with 13 additions and 10 deletions

View File

@ -25,9 +25,9 @@ public struct Folder {
}
// MARK: - ModelIdentifiable
// MARK: - FileSystemIdIdentifiable
extension Folder: ModelIdentifiable {}
extension Folder: FileSystemIdIdentifiable {}
// MARK: - Equatable

View File

@ -1,16 +1,16 @@
//
// Model.swift
// FileSystemItem.swift
// Browse
//
// Created by Javier Cicchelli on 13/12/2022.
// Copyright © 2022 Röck+Cöde. All rights reserved.
//
protocol Model {
protocol FileSystemItem {
var id: String { get }
var name: String { get }
}
// MARK: - Type aliases
typealias ModelIdentifiable = Model & Identifiable
typealias FileSystemIdIdentifiable = FileSystemItem & Identifiable

View File

@ -22,7 +22,7 @@ struct GetItemsUseCase {
id: String,
username: String,
password: String
) async throws -> [any ModelIdentifiable] {
) async throws -> [any FileSystemIdIdentifiable] {
let items = try await apiService.getItems(
id: id,
credentials: .init(
@ -32,16 +32,19 @@ struct GetItemsUseCase {
)
return items
.compactMap { item -> any ModelIdentifiable in
.compactMap { item -> any FileSystemIdIdentifiable in
if item.isDirectory {
return Folder(
id: item.id,
name: item.name
)
} else {
return File(
return Document(
id: item.id,
name: item.name
name: item.name,
contentType: item.contentType ?? "-",
size: item.size ?? 0,
lastModifiedAt: item.lastModifiedAt
)
}
}

View File

@ -12,7 +12,7 @@ struct FolderItem: View {
// MARK: Properties
let item: Model
let item: FileSystemItem
let delete: ItemIdClosure
// MARK: Body