Skip to content

Commit

Permalink
Some More Cleanup, Reset User Settings (#1060)
Browse files Browse the repository at this point in the history
  • Loading branch information
LePips authored May 17, 2024
1 parent 66c2655 commit 8d6167c
Show file tree
Hide file tree
Showing 26 changed files with 116 additions and 93 deletions.
4 changes: 2 additions & 2 deletions Shared/Objects/CaseIterablePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct CaseIterablePicker<Element: CaseIterable & Displayable & Hashable>: View

extension CaseIterablePicker {

init(title: String, selection: Binding<Element?>) {
init(_ title: String, selection: Binding<Element?>) {
self.init(
selection: selection,
label: { Text($0.displayTitle) },
Expand All @@ -75,7 +75,7 @@ extension CaseIterablePicker {
)
}

init(title: String, selection: Binding<Element>) {
init(_ title: String, selection: Binding<Element>) {
let binding = Binding<Element?> {
selection.wrappedValue
} set: { newValue, _ in
Expand Down
6 changes: 3 additions & 3 deletions Shared/Services/SwiftfinDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ extension Defaults.Keys {

enum Library {

static let cinematicBackground: Key<Bool> = UserKey("Customization.Library.cinematicBackground", default: true)
static let cinematicBackground: Key<Bool> = UserKey("libraryCinematicBackground", default: true)
static let enabledDrawerFilters: Key<[ItemFilterType]> = UserKey(
"Library.enabledDrawerFilters",
"libraryEnabledDrawerFilters",
default: ItemFilterType.allCases
)
static let displayType: Key<LibraryDisplayType> = UserKey("libraryViewType", default: .grid)
Expand All @@ -158,7 +158,7 @@ extension Defaults.Keys {
enum Search {

static let enabledDrawerFilters: Key<[ItemFilterType]> = UserKey(
"Search.enabledDrawerFilters",
"searchEnabledDrawerFilters",
default: ItemFilterType.allCases
)
}
Expand Down
5 changes: 3 additions & 2 deletions Shared/SwiftfinStore/StoredValue/StoredValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import CoreStore
import Foundation
import SwiftUI

// TODO: observation

/// A property wrapper for a stored `AnyData` object.
@propertyWrapper
struct StoredValue<Value: Codable>: DynamicProperty {
Expand Down Expand Up @@ -116,6 +114,9 @@ extension StoredValue {
// Stored value doesn't exist but we want to observe it.
// Create default and get new publisher

// TODO: this still store unnecessary data if never changed,
// observe if changes were made and delete on deinit

do {
try AnyStoredData.store(
value: key.defaultValue(),
Expand Down
2 changes: 1 addition & 1 deletion Shared/SwiftfinStore/StoredValue/StoredValues+Temp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import JellyfinAPI
// Note: Temporary values to avoid refactoring or
// reduce complexity at local sites.
//
// Values can be cleaned up at any time so and are
// Values can be cleaned up at any time and are
// meant to have a short lifetime.

extension StoredValues.Keys {
Expand Down
8 changes: 4 additions & 4 deletions Shared/SwiftfinStore/StoredValue/StoredValues+User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,23 @@ extension StoredValues.Keys {
static func libraryDisplayType(parentID: String?) -> Key<LibraryDisplayType> {
CurrentUserKey(
parentID,
domain: "libraryDisplayType",
domain: "setting-libraryDisplayType",
default: Defaults[.Customization.Library.displayType]
)
}

static func libraryListColumnCount(parentID: String?) -> Key<Int> {
CurrentUserKey(
parentID,
domain: "libraryListColumnCount",
domain: "setting-libraryListColumnCount",
default: Defaults[.Customization.Library.listColumnCount]
)
}

static func libraryPosterType(parentID: String?) -> Key<PosterDisplayType> {
CurrentUserKey(
parentID,
domain: "libraryPosterType",
domain: "setting-libraryPosterType",
default: Defaults[.Customization.Library.posterType]
)
}
Expand All @@ -119,7 +119,7 @@ extension StoredValues.Keys {
static func libraryFilters(parentID: String?) -> Key<ItemFilterCollection> {
CurrentUserKey(
parentID,
domain: "libraryFilters",
domain: "setting-libraryFilters",
default: ItemFilterCollection.default
)
}
Expand Down
2 changes: 1 addition & 1 deletion Shared/SwiftfinStore/SwiftinStore+UserState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ extension UserState {
try SwiftfinStore.dataStack.perform { transaction in
let userData = try transaction.fetchAll(
From<AnyStoredData>()
.where(\.$ownerID == id)
.where(combineByAnd: Where(\.$ownerID == id), Where("%K BEGINSWITH %@", "domain", "setting"))
)

transaction.delete(userData)
Expand Down
2 changes: 1 addition & 1 deletion Swiftfin tvOS/Components/ChevronButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct ChevronButton: View {

extension ChevronButton {

init(title: String, subtitle: String? = nil) {
init(_ title: String, subtitle: String? = nil) {
self.init(
title: title,
subtitle: subtitle,
Expand Down
2 changes: 1 addition & 1 deletion Swiftfin tvOS/Views/BasicAppSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct AppSettingsView: View {
// )
// }
//
// ChevronButton(title: "Logs")
// ChevronButton("Logs")
// .onSelect {
// router.route(to: \.log)
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct CustomizeViewsSettings: View {

Section {

ChevronButton(title: "Indicators")
ChevronButton("Indicators")
.onSelect {
router.route(to: \.indicatorSettings)
}
Expand Down
10 changes: 5 additions & 5 deletions Swiftfin tvOS/Views/SettingsView/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct SettingsView: View {
}

ChevronButton(
title: L10n.server,
L10n.server,
subtitle: viewModel.userSession.server.name
)
.onSelect {
Expand All @@ -60,7 +60,7 @@ struct SettingsView: View {

InlineEnumToggle(title: "Video Player Type", selection: $videoPlayerType)

ChevronButton(title: L10n.videoPlayer)
ChevronButton(L10n.videoPlayer)
.onSelect {
router.route(to: \.videoPlayerSettings)
}
Expand All @@ -70,12 +70,12 @@ struct SettingsView: View {

Section {

ChevronButton(title: L10n.customize)
ChevronButton(L10n.customize)
.onSelect {
router.route(to: \.customizeViewsSettings)
}

ChevronButton(title: L10n.experimental)
ChevronButton(L10n.experimental)
.onSelect {
router.route(to: \.experimentalSettings)
}
Expand All @@ -86,7 +86,7 @@ struct SettingsView: View {

Section {

ChevronButton(title: "Logs")
ChevronButton("Logs")
.onSelect {
router.route(to: \.log)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct VideoPlayerSettingsView: View {

Section {
ChevronButton(
title: "Resume Offset",
"Resume Offset",
subtitle: resumeOffset.secondLabel
)
.onSelect {
Expand All @@ -55,7 +55,7 @@ struct VideoPlayerSettingsView: View {
}

Section {
ChevronButton(title: L10n.subtitleFont, subtitle: subtitleFontName)
ChevronButton(L10n.subtitleFont, subtitle: subtitleFontName)
.onSelect {
router.route(to: \.fontPicker, $subtitleFontName)
}
Expand Down
3 changes: 0 additions & 3 deletions Swiftfin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3773,13 +3773,11 @@
E18E021E2887492B0022598C /* RowDivider.swift in Sources */,
E1DC983E296DEB9B00982F06 /* UnwatchedIndicator.swift in Sources */,
E107BB9427880A8F00354E07 /* CollectionItemViewModel.swift in Sources */,
E1575E7E293E77B5001665B1 /* ItemFilterCollection.swift in Sources */,
E1D37F592B9CEF4B00343D2B /* DeviceProfile+SwiftfinProfile.swift in Sources */,
53ABFDE9267974EF00886593 /* HomeViewModel.swift in Sources */,
E1575E99293E7B1E001665B1 /* UIColor.swift in Sources */,
E1575E92293E7B1E001665B1 /* CGSize.swift in Sources */,
E1575E7E293E77B5001665B1 /* ItemFilterCollection.swift in Sources */,
E1575E7E293E77B5001665B1 /* ItemFilterCollection.swift in Sources */,
C46DD8EF2A8FB56E0046A504 /* LiveBottomBarView.swift in Sources */,
C46DD8EA2A8FB45C0046A504 /* LiveOverlay.swift in Sources */,
E11E376D293E9CC1009EF240 /* VideoPlayerCoordinator.swift in Sources */,
Expand Down Expand Up @@ -4307,7 +4305,6 @@
E1D3044428D1991900587289 /* LibraryViewTypeToggle.swift in Sources */,
C45C36542A8B1F2C003DAE46 /* LiveVideoPlayerManager.swift in Sources */,
E148128B28C15526003B8787 /* ItemSortBy.swift in Sources */,
E148128B28C15526003B8787 /* ItemSortBy.swift in Sources */,
E10231412BCF8A3C009D71FC /* ChannelLibraryView.swift in Sources */,
E1F0204E26CCCA74001C1C3B /* VideoPlayerJumpLength.swift in Sources */,
E1A3E4CB2BB74EFD005C59F8 /* EpisodeHStack.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "558c2e760c073dbad0a2bfbade5ccfa1b2962fdd8ab5f658d9bbfc4310623441",
"originHash" : "68a42015b2d42a14d418b6e13427443de55c970d5b3764bbc969e1b3f8c3a78b",
"pins" : [
{
"identity" : "blurhashkit",
Expand Down Expand Up @@ -34,7 +34,7 @@
"location" : "https://github.com/LePips/CollectionVGrid",
"state" : {
"branch" : "main",
"revision" : "b50b5241df5fc1d71e5a09f6a87731c67c2a79e5"
"revision" : "7204e5f717ea571efb4600ecb71c2412e0dec921"
}
},
{
Expand Down Expand Up @@ -114,17 +114,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/kean/Nuke",
"state" : {
"revision" : "4625c73ea00a9fb4b4f3e28d95d0021a44af7e59",
"version" : "12.5.0"
"revision" : "8e431251dea0081b6ab154dab61a6ec74e4b6577",
"version" : "12.6.0"
}
},
{
"identity" : "pulse",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kean/Pulse",
"state" : {
"revision" : "d647e99f06abc94d63579e335ad4ce368195c149",
"version" : "4.0.5"
"revision" : "4f34c4f91cda623a7627e6d5e35dbbbb514b8daa",
"version" : "4.1.1"
}
},
{
Expand Down Expand Up @@ -195,8 +195,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/SwiftUI-Introspect",
"state" : {
"revision" : "0cd2a5a5895306bc21d54a2254302d24a9a571e4",
"version" : "1.1.3"
"revision" : "7dc5b287f8040e4ad5038739850b758e78f77808",
"version" : "1.1.4"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Swiftfin/Components/ChevronButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct ChevronButton: View {

extension ChevronButton {

init(title: String, subtitle: String? = nil) {
init(_ title: String, subtitle: String? = nil) {
self.init(
title: title,
subtitle: subtitle,
Expand Down
6 changes: 3 additions & 3 deletions Swiftfin/Views/AboutAppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct AboutAppView: View {
trailing: "\(UIApplication.appVersion ?? .emptyDash) (\(UIApplication.bundleVersion ?? .emptyDash))"
)

ChevronButton(title: L10n.sourceCode)
ChevronButton(L10n.sourceCode)
.leadingView {
Image(.logoGithub)
.resizable()
Expand All @@ -51,7 +51,7 @@ struct AboutAppView: View {
UIApplication.shared.open(.swiftfinGithub)
}

ChevronButton(title: L10n.bugsAndFeatures)
ChevronButton(L10n.bugsAndFeatures)
.leadingView {
Image(systemName: "plus.circle.fill")
.resizable()
Expand All @@ -65,7 +65,7 @@ struct AboutAppView: View {
UIApplication.shared.open(.swiftfinGithubIssues)
}

ChevronButton(title: L10n.settings)
ChevronButton(L10n.settings)
.leadingView {
Image(systemName: "gearshape.fill")
.resizable()
Expand Down
8 changes: 4 additions & 4 deletions Swiftfin/Views/AppSettingsView/AppSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ struct AppSettingsView: View {
var body: some View {
Form {

ChevronButton(title: L10n.about)
ChevronButton(L10n.about)
.onSelect {
router.route(to: \.about, viewModel)
}

Section(L10n.accessibility) {

ChevronButton(title: L10n.appIcon)
ChevronButton(L10n.appIcon)
.onSelect {
router.route(to: \.appIconSelector, viewModel)
}

if !selectUserUseSplashscreen {
CaseIterablePicker(
title: L10n.appearance,
L10n.appearance,
selection: $appearance
)
}
Expand Down Expand Up @@ -85,7 +85,7 @@ struct AppSettingsView: View {

SignOutIntervalSection()

ChevronButton(title: L10n.logs)
ChevronButton(L10n.logs)
.onSelect {
router.route(to: \.log)
}
Expand Down
6 changes: 3 additions & 3 deletions Swiftfin/Views/MediaSourceInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct MediaSourceInfoView: View {
{
Section(L10n.video) {
ForEach(videoStreams, id: \.self) { stream in
ChevronButton(title: stream.displayTitle ?? .emptyDash)
ChevronButton(stream.displayTitle ?? .emptyDash)
.onSelect {
router.route(to: \.mediaStreamInfo, stream)
}
Expand All @@ -37,7 +37,7 @@ struct MediaSourceInfoView: View {
{
Section(L10n.audio) {
ForEach(audioStreams, id: \.self) { stream in
ChevronButton(title: stream.displayTitle ?? .emptyDash)
ChevronButton(stream.displayTitle ?? .emptyDash)
.onSelect {
router.route(to: \.mediaStreamInfo, stream)
}
Expand All @@ -50,7 +50,7 @@ struct MediaSourceInfoView: View {
{
Section(L10n.subtitle) {
ForEach(subtitleStreams, id: \.self) { stream in
ChevronButton(title: stream.displayTitle ?? .emptyDash)
ChevronButton(stream.displayTitle ?? .emptyDash)
.onSelect {
router.route(to: \.mediaStreamInfo, stream)
}
Expand Down
Loading

0 comments on commit 8d6167c

Please sign in to comment.