metatext/Model/Timeline.swift

43 lines
889 B
Swift
Raw Normal View History

2020-08-18 05:13:37 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
2020-08-29 03:50:58 +00:00
enum Timeline: Hashable {
2020-08-18 05:13:37 +00:00
case home
case local
case federated
case list(MastodonList)
}
extension Timeline {
2020-08-29 03:50:58 +00:00
static let nonLists: [Timeline] = [.home, .local, .federated]
var endpoint: TimelinesEndpoint {
2020-08-18 05:13:37 +00:00
switch self {
case .home:
2020-08-29 03:50:58 +00:00
return .home
2020-08-18 05:13:37 +00:00
case .local:
2020-08-29 03:50:58 +00:00
return .public(local: true)
2020-08-18 05:13:37 +00:00
case .federated:
2020-08-29 03:50:58 +00:00
return .public(local: false)
2020-08-18 05:13:37 +00:00
case let .list(list):
2020-08-29 03:50:58 +00:00
return .list(id: list.id)
2020-08-18 05:13:37 +00:00
}
}
2020-08-29 03:50:58 +00:00
}
2020-08-18 05:13:37 +00:00
2020-08-29 03:50:58 +00:00
extension Timeline: Identifiable {
var id: String {
2020-08-18 05:13:37 +00:00
switch self {
case .home:
2020-08-29 03:50:58 +00:00
return "home"
2020-08-18 05:13:37 +00:00
case .local:
2020-08-29 03:50:58 +00:00
return "local"
2020-08-18 05:13:37 +00:00
case .federated:
2020-08-29 03:50:58 +00:00
return "federated"
2020-08-18 05:13:37 +00:00
case let .list(list):
2020-08-29 03:50:58 +00:00
return list.id
2020-08-18 05:13:37 +00:00
}
}
}