diff --git a/JellyfinPlayer tvOS/Info.plist b/JellyfinPlayer tvOS/Info.plist
index 34b9158f..6d37a895 100644
--- a/JellyfinPlayer tvOS/Info.plist
+++ b/JellyfinPlayer tvOS/Info.plist
@@ -19,7 +19,7 @@
CFBundleShortVersionString
$(MARKETING_VERSION)
CFBundleVersion
- $(CURRENT_PROJECT_VERSION)
+ 43
LSRequiresIPhoneOS
UILaunchScreen
diff --git a/JellyfinPlayer.xcodeproj/project.pbxproj b/JellyfinPlayer.xcodeproj/project.pbxproj
index 1e837a33..7295069a 100644
--- a/JellyfinPlayer.xcodeproj/project.pbxproj
+++ b/JellyfinPlayer.xcodeproj/project.pbxproj
@@ -677,7 +677,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image";
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 41;
+ CURRENT_PROJECT_VERSION = 43;
DEVELOPMENT_ASSET_PATHS = "\"JellyfinPlayer tvOS/Preview Content\"";
DEVELOPMENT_TEAM = 9R8RREG67J;
ENABLE_PREVIEWS = YES;
@@ -706,7 +706,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image";
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 41;
+ CURRENT_PROJECT_VERSION = 43;
DEVELOPMENT_ASSET_PATHS = "\"JellyfinPlayer tvOS/Preview Content\"";
DEVELOPMENT_TEAM = 9R8RREG67J;
ENABLE_PREVIEWS = YES;
@@ -857,7 +857,7 @@
CODE_SIGN_ENTITLEMENTS = JellyfinPlayer/JellyfinPlayer.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 41;
+ CURRENT_PROJECT_VERSION = 43;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 9R8RREG67J;
ENABLE_BITCODE = NO;
@@ -893,7 +893,7 @@
CODE_SIGN_ENTITLEMENTS = JellyfinPlayer/JellyfinPlayer.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 41;
+ CURRENT_PROJECT_VERSION = 43;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 9R8RREG67J;
@@ -928,7 +928,7 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_ENTITLEMENTS = WidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 41;
+ CURRENT_PROJECT_VERSION = 43;
DEVELOPMENT_TEAM = 9R8RREG67J;
INFOPLIST_FILE = WidgetExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
@@ -953,7 +953,7 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_ENTITLEMENTS = WidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 41;
+ CURRENT_PROJECT_VERSION = 43;
DEVELOPMENT_TEAM = 9R8RREG67J;
INFOPLIST_FILE = WidgetExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
diff --git a/JellyfinPlayer/ConnectToServerView.swift b/JellyfinPlayer/ConnectToServerView.swift
index cc0178e3..518bdb56 100644
--- a/JellyfinPlayer/ConnectToServerView.swift
+++ b/JellyfinPlayer/ConnectToServerView.swift
@@ -93,10 +93,22 @@ struct ConnectToServerView: View {
UserAPI.authenticateUserByName(authenticateUserByName: x)
.sink(receiveCompletion: { completion in
- isWorking = false
- HandleAPIRequestCompletion(globalData: globalData, completion: completion)
+ switch completion {
+ case .finished:
+ break
+ case .failure(let error):
+ isWorking = false
+ if let err = error as? ErrorResponse {
+ switch err {
+ case .error(401, _, _, _):
+ isSignInErrored = true
+ case .error:
+ globalData.networkError = true
+ }
+ }
+ break
+ }
}, receiveValue: { response in
- isWorking = true
let fetchRequest: NSFetchRequest = NSFetchRequest(entityName: "Server")
let deleteRequest = NSBatchDeleteRequest(fetchRequest: fetchRequest)
@@ -128,17 +140,19 @@ struct ConnectToServerView: View {
let keychain = KeychainSwift()
keychain.set(response.accessToken!, forKey: "AccessToken_\(newUser.user_id!)")
- globalData.expiredCredentials = false
- globalData.networkError = false
-
do {
try viewContext.save()
DispatchQueue.main.async { [self] in
globalData.authHeader = authHeader
_rootIsActive.wrappedValue = false
+
+ globalData.expiredCredentials = false
+ globalData.networkError = false
+ globalData.user = newUser
+ globalData.server = newServer
+
jsi.did = true
print("logged in")
- isWorking = false
}
} catch {
print("Couldn't store objects to CoreData")
diff --git a/JellyfinPlayer/ContentView.swift b/JellyfinPlayer/ContentView.swift
index 2c8da660..daecfaed 100644
--- a/JellyfinPlayer/ContentView.swift
+++ b/JellyfinPlayer/ContentView.swift
@@ -19,12 +19,6 @@ struct ContentView: View {
@StateObject private var globalData = GlobalData()
- @FetchRequest(entity: Server.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \Server.name, ascending: true)])
- private var servers: FetchedResults
-
- @FetchRequest(entity: SignedInUser.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \SignedInUser.username, ascending: true)])
- private var savedUsers: FetchedResults
-
@State private var needsToSelectServer = false
@State private var isLoading = false
@State private var tabSelection: String = "Home"
@@ -35,6 +29,12 @@ struct ContentView: View {
@State private var showSettingsPopover: Bool = false
@State private var viewDidLoad: Bool = false
@State private var loadState: Int = 2
+
+ @FetchRequest(entity: Server.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \Server.name, ascending: true)])
+ var servers: FetchedResults
+
+ @FetchRequest(entity: SignedInUser.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \SignedInUser.username, ascending: true)])
+ var savedUsers: FetchedResults
private var recentFilterSet: LibraryFilters = LibraryFilters(filters: [], sortOrder: [.descending], sortBy: ["DateCreated"])
@@ -43,15 +43,13 @@ struct ContentView: View {
return
}
- viewDidLoad = true
-
let size = UIScreen.main.bounds.size
if size.width < size.height {
orientationInfo.orientation = .portrait
} else {
orientationInfo.orientation = .landscape
}
-
+
ImageCache.shared.costLimit = 125 * 1024 * 1024 // 125MB memory
DataLoader.sharedUrlCache.diskCapacity = 1000 * 1024 * 1024 // 1000MB disk
@@ -99,6 +97,7 @@ struct ContentView: View {
if loadState == 1 {
isLoading = false
+ viewDidLoad = true
}
})
.store(in: &globalData.pendingAPIRequests)
@@ -114,6 +113,7 @@ struct ContentView: View {
if loadState == 1 {
isLoading = false
+ viewDidLoad = true
}
})
.store(in: &globalData.pendingAPIRequests)
@@ -131,12 +131,13 @@ struct ContentView: View {
}
var body: some View {
- if needsToSelectServer == true {
+ if needsToSelectServer == true || globalData.user == nil || globalData.server == nil {
NavigationView {
ConnectToServerView(isActive: $needsToSelectServer)
}
.navigationViewStyle(StackNavigationViewStyle())
.environmentObject(globalData)
+ .onAppear(perform: startup)
} else if globalData.expiredCredentials == true {
NavigationView {
ConnectToServerView(skip_server: true, skip_server_prefill: globalData.server,
@@ -144,6 +145,7 @@ struct ContentView: View {
}
.navigationViewStyle(StackNavigationViewStyle())
.environmentObject(globalData)
+ .onAppear(perform: startup)
} else {
if !jsi.did {
if isLoading || globalData.user == nil || globalData.user.user_id == nil {
diff --git a/JellyfinPlayer/Info.plist b/JellyfinPlayer/Info.plist
index c4597a3f..3d9ef88a 100644
--- a/JellyfinPlayer/Info.plist
+++ b/JellyfinPlayer/Info.plist
@@ -19,7 +19,7 @@
CFBundleShortVersionString
$(MARKETING_VERSION)
CFBundleVersion
- $(CURRENT_PROJECT_VERSION)
+ 43
ITSAppUsesNonExemptEncryption
LSRequiresIPhoneOS
diff --git a/WidgetExtension/Info.plist b/WidgetExtension/Info.plist
index a98e4afd..2f4d5aeb 100644
--- a/WidgetExtension/Info.plist
+++ b/WidgetExtension/Info.plist
@@ -19,7 +19,7 @@
CFBundleShortVersionString
$(MARKETING_VERSION)
CFBundleVersion
- $(CURRENT_PROJECT_VERSION)
+ 43
NSExtension
NSExtensionPointIdentifier