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