mirror of
https://github.com/yattee/yattee.git
synced 2024-11-09 15:58:20 +00:00
Code style changes
This commit is contained in:
parent
afa0049333
commit
a9e9fa3a6d
@ -13,7 +13,7 @@ struct AccountsBridge: Defaults.Bridge {
|
|||||||
return [
|
return [
|
||||||
"id": value.id,
|
"id": value.id,
|
||||||
"instanceID": value.instanceID ?? "",
|
"instanceID": value.instanceID ?? "",
|
||||||
"name": value.name ?? "",
|
"name": value.name,
|
||||||
"apiURL": value.urlString,
|
"apiURL": value.urlString,
|
||||||
"username": value.username,
|
"username": value.username,
|
||||||
"password": value.password ?? ""
|
"password": value.password ?? ""
|
||||||
|
@ -24,7 +24,7 @@ final class AccountsModel: ObservableObject {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return AccountsModel.find(id)
|
return Self.find(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
var any: Account? {
|
var any: Account? {
|
||||||
|
@ -13,7 +13,7 @@ final class InstancesModel: ObservableObject {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return InstancesModel.shared.find(id)
|
return Self.shared.find(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastUsed: Instance? {
|
var lastUsed: Instance? {
|
||||||
@ -21,7 +21,7 @@ final class InstancesModel: ObservableObject {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return InstancesModel.shared.find(id)
|
return Self.shared.find(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func find(_ id: Instance.ID?) -> Instance? {
|
func find(_ id: Instance.ID?) -> Instance? {
|
||||||
|
@ -579,8 +579,6 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
|
|||||||
let nextPage = json.dictionaryValue["continuation"]?.string
|
let nextPage = json.dictionaryValue["continuation"]?.string
|
||||||
var contentItems = [ContentItem]()
|
var contentItems = [ContentItem]()
|
||||||
|
|
||||||
var items = [ContentItem]()
|
|
||||||
|
|
||||||
if let key = Self.contentItemsKeys.first(where: { json.dictionaryValue.keys.contains($0) }),
|
if let key = Self.contentItemsKeys.first(where: { json.dictionaryValue.keys.contains($0) }),
|
||||||
let items = json.dictionaryValue[key]
|
let items = json.dictionaryValue[key]
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ import Logging
|
|||||||
import SwiftyJSON
|
import SwiftyJSON
|
||||||
|
|
||||||
struct BaseCacheModel {
|
struct BaseCacheModel {
|
||||||
static var shared = BaseCacheModel()
|
static var shared = Self()
|
||||||
|
|
||||||
static let jsonToDataTransformer: (JSON) -> Data = { try! $0.rawData() }
|
static let jsonToDataTransformer: (JSON) -> Data = { try! $0.rawData() }
|
||||||
static let jsonFromDataTransformer: (Data) -> JSON = { try! JSON(data: $0) }
|
static let jsonFromDataTransformer: (Data) -> JSON = { try! JSON(data: $0) }
|
||||||
|
@ -4,7 +4,7 @@ import Logging
|
|||||||
import SwiftyJSON
|
import SwiftyJSON
|
||||||
|
|
||||||
struct BookmarksCacheModel {
|
struct BookmarksCacheModel {
|
||||||
static var shared = BookmarksCacheModel()
|
static var shared = Self()
|
||||||
let logger = Logger(label: "stream.yattee.cache")
|
let logger = Logger(label: "stream.yattee.cache")
|
||||||
|
|
||||||
static let bookmarksGroup = "group.stream.yattee.app.bookmarks"
|
static let bookmarksGroup = "group.stream.yattee.app.bookmarks"
|
||||||
|
@ -4,7 +4,7 @@ import Logging
|
|||||||
import SwiftyJSON
|
import SwiftyJSON
|
||||||
|
|
||||||
struct ChannelPlaylistsCacheModel: CacheModel {
|
struct ChannelPlaylistsCacheModel: CacheModel {
|
||||||
static let shared = ChannelPlaylistsCacheModel()
|
static let shared = Self()
|
||||||
let logger = Logger(label: "stream.yattee.cache.channel-playlists")
|
let logger = Logger(label: "stream.yattee.cache.channel-playlists")
|
||||||
|
|
||||||
static let diskConfig = DiskConfig(name: "channel-playlists")
|
static let diskConfig = DiskConfig(name: "channel-playlists")
|
||||||
|
@ -4,7 +4,7 @@ import Logging
|
|||||||
import SwiftyJSON
|
import SwiftyJSON
|
||||||
|
|
||||||
struct ChannelsCacheModel: CacheModel {
|
struct ChannelsCacheModel: CacheModel {
|
||||||
static let shared = ChannelsCacheModel()
|
static let shared = Self()
|
||||||
let logger = Logger(label: "stream.yattee.cache.channels")
|
let logger = Logger(label: "stream.yattee.cache.channels")
|
||||||
|
|
||||||
static let diskConfig = DiskConfig(name: "channels")
|
static let diskConfig = DiskConfig(name: "channels")
|
||||||
|
@ -5,7 +5,7 @@ import Logging
|
|||||||
import SwiftyJSON
|
import SwiftyJSON
|
||||||
|
|
||||||
struct FeedCacheModel: CacheModel {
|
struct FeedCacheModel: CacheModel {
|
||||||
static let shared = FeedCacheModel()
|
static let shared = Self()
|
||||||
let logger = Logger(label: "stream.yattee.cache.feed")
|
let logger = Logger(label: "stream.yattee.cache.feed")
|
||||||
|
|
||||||
static let diskConfig = DiskConfig(name: "feed")
|
static let diskConfig = DiskConfig(name: "feed")
|
||||||
|
@ -4,7 +4,7 @@ import Logging
|
|||||||
import SwiftyJSON
|
import SwiftyJSON
|
||||||
|
|
||||||
struct PlaylistsCacheModel: CacheModel {
|
struct PlaylistsCacheModel: CacheModel {
|
||||||
static let shared = PlaylistsCacheModel()
|
static let shared = Self()
|
||||||
static let limit = 30
|
static let limit = 30
|
||||||
let logger = Logger(label: "stream.yattee.cache.playlists")
|
let logger = Logger(label: "stream.yattee.cache.playlists")
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import Logging
|
|||||||
import SwiftyJSON
|
import SwiftyJSON
|
||||||
|
|
||||||
struct VideosCacheModel: CacheModel {
|
struct VideosCacheModel: CacheModel {
|
||||||
static let shared = VideosCacheModel()
|
static let shared = Self()
|
||||||
let logger = Logger(label: "stream.yattee.cache.videos")
|
let logger = Logger(label: "stream.yattee.cache.videos")
|
||||||
|
|
||||||
static let diskConfig = DiskConfig(name: "videos")
|
static let diskConfig = DiskConfig(name: "videos")
|
||||||
|
@ -91,7 +91,9 @@ struct Channel: Identifiable, Hashable {
|
|||||||
var subscriptionsText: String?
|
var subscriptionsText: String?
|
||||||
|
|
||||||
var totalViews: Int?
|
var totalViews: Int?
|
||||||
var verified: Bool? // swiftlint:disable discouraged_optional_boolean
|
// swiftlint:disable discouraged_optional_boolean
|
||||||
|
var verified: Bool?
|
||||||
|
// swiftlint:enable discouraged_optional_boolean
|
||||||
|
|
||||||
var videos = [Video]()
|
var videos = [Video]()
|
||||||
var tabs = [Tab]()
|
var tabs = [Tab]()
|
||||||
|
@ -25,7 +25,7 @@ struct ChannelPlaylist: Identifiable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static func from(_ json: JSON) -> Self {
|
static func from(_ json: JSON) -> Self {
|
||||||
ChannelPlaylist(
|
Self(
|
||||||
id: json["id"].stringValue,
|
id: json["id"].stringValue,
|
||||||
title: json["title"].stringValue,
|
title: json["title"].stringValue,
|
||||||
thumbnailURL: json["thumbnailURL"].url,
|
thumbnailURL: json["thumbnailURL"].url,
|
||||||
|
@ -42,7 +42,9 @@ final class CommentsModel: ObservableObject {
|
|||||||
|
|
||||||
firstPage = page.isNil || page!.isEmpty
|
firstPage = page.isNil || page!.isEmpty
|
||||||
|
|
||||||
player.playerAPI(video)?.comments(video.videoID, page: page)?
|
player
|
||||||
|
.playerAPI(video)?
|
||||||
|
.comments(video.videoID, page: page)?
|
||||||
.load()
|
.load()
|
||||||
.onSuccess { [weak self] response in
|
.onSuccess { [weak self] response in
|
||||||
if let page: CommentsPage = response.typedContent() {
|
if let page: CommentsPage = response.typedContent() {
|
||||||
|
@ -31,15 +31,15 @@ struct ContentItem: Identifiable {
|
|||||||
var id: String = UUID().uuidString
|
var id: String = UUID().uuidString
|
||||||
|
|
||||||
static func array(of videos: [Video]) -> [ContentItem] {
|
static func array(of videos: [Video]) -> [ContentItem] {
|
||||||
videos.map { ContentItem(video: $0) }
|
videos.map { Self(video: $0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
static func array(of playlists: [ChannelPlaylist]) -> [ContentItem] {
|
static func array(of playlists: [ChannelPlaylist]) -> [ContentItem] {
|
||||||
playlists.map { ContentItem(playlist: $0) }
|
playlists.map { Self(playlist: $0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
static func array(of channels: [Channel]) -> [ContentItem] {
|
static func array(of channels: [Channel]) -> [ContentItem] {
|
||||||
channels.map { ContentItem(channel: $0) }
|
channels.map { Self(channel: $0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
static func < (lhs: ContentItem, rhs: ContentItem) -> Bool {
|
static func < (lhs: ContentItem, rhs: ContentItem) -> Bool {
|
||||||
|
@ -234,6 +234,8 @@ extension Country {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// swiftlint:enable switch_case_on_newline
|
||||||
|
|
||||||
var flag: String {
|
var flag: String {
|
||||||
let unicodeScalars = rawValue
|
let unicodeScalars = rawValue
|
||||||
.unicodeScalars
|
.unicodeScalars
|
||||||
|
@ -2,7 +2,7 @@ import Defaults
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
struct FavoritesModel {
|
struct FavoritesModel {
|
||||||
static let shared = FavoritesModel()
|
static let shared = Self()
|
||||||
|
|
||||||
@Default(.showFavoritesInHome) var showFavoritesInHome
|
@Default(.showFavoritesInHome) var showFavoritesInHome
|
||||||
@Default(.favorites) var all
|
@Default(.favorites) var all
|
||||||
|
@ -2,7 +2,7 @@ import Foundation
|
|||||||
import KeychainAccess
|
import KeychainAccess
|
||||||
|
|
||||||
struct KeychainModel {
|
struct KeychainModel {
|
||||||
static var shared = KeychainModel()
|
static var shared = Self()
|
||||||
|
|
||||||
var keychain = Keychain(service: "stream.yattee.app")
|
var keychain = Keychain(service: "stream.yattee.app")
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ final class NavigationModel: ObservableObject {
|
|||||||
case .search:
|
case .search:
|
||||||
return "search"
|
return "search"
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
case .settings: // swiftlint:disable:this switch_case_alignment
|
case .settings:
|
||||||
return "settings"
|
return "settings"
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
|
@ -37,7 +37,7 @@ struct OpenVideosModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static let shared = OpenVideosModel()
|
static let shared = Self()
|
||||||
var player: PlayerModel! = .shared
|
var player: PlayerModel! = .shared
|
||||||
var logger = Logger(label: "stream.yattee.open-videos")
|
var logger = Logger(label: "stream.yattee.open-videos")
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
struct PersistenceController {
|
struct PersistenceController {
|
||||||
static let shared = PersistenceController()
|
static let shared = Self()
|
||||||
|
|
||||||
static var preview: PersistenceController = {
|
static var preview: PersistenceController = {
|
||||||
let result = PersistenceController(inMemory: true)
|
let result = Self(inMemory: true)
|
||||||
let viewContext = result.container.viewContext
|
let viewContext = result.container.viewContext
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -2,7 +2,7 @@ import Foundation
|
|||||||
import IOKit.pwr_mgt
|
import IOKit.pwr_mgt
|
||||||
|
|
||||||
struct ScreenSaverManager {
|
struct ScreenSaverManager {
|
||||||
static var shared = ScreenSaverManager()
|
static var shared = Self()
|
||||||
|
|
||||||
var noSleepAssertion: IOPMAssertionID = 0
|
var noSleepAssertion: IOPMAssertionID = 0
|
||||||
var noSleepReturn: IOReturn?
|
var noSleepReturn: IOReturn?
|
||||||
|
@ -6,7 +6,7 @@ import Foundation
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct QualityProfilesModel {
|
struct QualityProfilesModel {
|
||||||
static let shared = QualityProfilesModel()
|
static let shared = Self()
|
||||||
|
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
var tvOSProfile: QualityProfile? {
|
var tvOSProfile: QualityProfile? {
|
||||||
|
@ -3,7 +3,7 @@ import Logging
|
|||||||
|
|
||||||
struct URLBookmarkModel {
|
struct URLBookmarkModel {
|
||||||
static let bookmarkPrefix = "urlbookmark-"
|
static let bookmarkPrefix = "urlbookmark-"
|
||||||
static var shared = URLBookmarkModel()
|
static var shared = Self()
|
||||||
|
|
||||||
var logger = Logger(label: "stream.yattee.url-bookmark")
|
var logger = Logger(label: "stream.yattee.url-bookmark")
|
||||||
|
|
||||||
|
@ -32,4 +32,5 @@ final class UnwatchedFeedCountModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
// swiftlint:enable empty_count
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ struct Video: Identifiable, Equatable, Hashable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static func local(_ url: URL) -> Video {
|
static func local(_ url: URL) -> Video {
|
||||||
Video(
|
Self(
|
||||||
app: .local,
|
app: .local,
|
||||||
videoID: url.absoluteString,
|
videoID: url.absoluteString,
|
||||||
streams: [.init(localURL: url)]
|
streams: [.init(localURL: url)]
|
||||||
@ -167,7 +167,7 @@ struct Video: Identifiable, Equatable, Hashable {
|
|||||||
static func from(_ json: JSON) -> Self {
|
static func from(_ json: JSON) -> Self {
|
||||||
let dateFormatter = ISO8601DateFormatter()
|
let dateFormatter = ISO8601DateFormatter()
|
||||||
|
|
||||||
return Video(
|
return Self(
|
||||||
instanceID: json["instanceID"].stringValue,
|
instanceID: json["instanceID"].stringValue,
|
||||||
app: .init(rawValue: json["app"].stringValue) ?? AccountsModel.shared.current.app ?? .local,
|
app: .init(rawValue: json["app"].stringValue) ?? AccountsModel.shared.current.app ?? .local,
|
||||||
instanceURL: URL(string: json["instanceURL"].stringValue) ?? AccountsModel.shared.current.instance.apiURL,
|
instanceURL: URL(string: json["instanceURL"].stringValue) ?? AccountsModel.shared.current.instance.apiURL,
|
||||||
|
@ -327,7 +327,7 @@ struct ChannelVideosView: View {
|
|||||||
|
|
||||||
private var contentTypePicker: some View {
|
private var contentTypePicker: some View {
|
||||||
Picker("Content type", selection: $contentType) {
|
Picker("Content type", selection: $contentType) {
|
||||||
if let channel = presentedChannel {
|
if presentedChannel != nil {
|
||||||
ForEach(Channel.ContentType.allCases, id: \.self) { type in
|
ForEach(Channel.ContentType.allCases, id: \.self) { type in
|
||||||
if typeAvailable(type) {
|
if typeAvailable(type) {
|
||||||
Label(type.description, systemImage: type.systemImage).tag(type)
|
Label(type.description, systemImage: type.systemImage).tag(type)
|
||||||
@ -432,7 +432,9 @@ struct ChannelVideosView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func load() {
|
func load() {
|
||||||
resource?.load().onSuccess { response in
|
resource?
|
||||||
|
.load()
|
||||||
|
.onSuccess { response in
|
||||||
if let page: ChannelPage = response.typedContent() {
|
if let page: ChannelPage = response.typedContent() {
|
||||||
if let channel = page.channel {
|
if let channel = page.channel {
|
||||||
ChannelsCacheModel.shared.store(channel)
|
ChannelsCacheModel.shared.store(channel)
|
||||||
|
@ -16,7 +16,7 @@ struct DocumentsView: View {
|
|||||||
|
|
||||||
Group {
|
Group {
|
||||||
if model.isDirectory(standardizedURL) {
|
if model.isDirectory(standardizedURL) {
|
||||||
NavigationLink(destination: DocumentsView(directoryURL: url)) {
|
NavigationLink(destination: Self(directoryURL: url)) {
|
||||||
VideoBanner(video: video)
|
VideoBanner(video: video)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,7 +4,7 @@ import Siesta
|
|||||||
|
|
||||||
struct OpenURLHandler {
|
struct OpenURLHandler {
|
||||||
static var firstHandle = true
|
static var firstHandle = true
|
||||||
static var shared = OpenURLHandler()
|
static var shared = Self()
|
||||||
static let yatteeProtocol = "yattee://"
|
static let yatteeProtocol = "yattee://"
|
||||||
|
|
||||||
var accounts: AccountsModel { .shared }
|
var accounts: AccountsModel { .shared }
|
||||||
|
@ -5,8 +5,7 @@ import SwiftUI
|
|||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
struct AppleAVPlayerView: UIViewRepresentable {
|
struct AppleAVPlayerView: UIViewRepresentable {
|
||||||
func makeUIView(context _: Context) -> some UIView {
|
func makeUIView(context _: Context) -> some UIView {
|
||||||
let playerLayerView = PlayerLayerView(frame: .zero)
|
PlayerLayerView(frame: .zero)
|
||||||
return playerLayerView
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUIView(_: UIViewType, context _: Context) {}
|
func updateUIView(_: UIViewType, context _: Context) {}
|
||||||
|
@ -204,7 +204,7 @@ struct CommentView: View {
|
|||||||
Group {
|
Group {
|
||||||
let last = comments.replies.last
|
let last = comments.replies.last
|
||||||
ForEach(comments.replies) { comment in
|
ForEach(comments.replies) { comment in
|
||||||
CommentView(comment: comment, repliesID: $repliesID)
|
Self(comment: comment, repliesID: $repliesID)
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
.focusable()
|
.focusable()
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user