This commit is contained in:
Aiden Vigue 2021-06-13 00:48:54 -04:00
parent 5b3fc5425f
commit 5a2a0f06a4
No known key found for this signature in database
GPG Key ID: B9A09843AB079D5B
6 changed files with 42 additions and 26 deletions

View File

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<string>43</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchScreen</key>

View File

@ -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;

View File

@ -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<NSFetchRequestResult> = 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")

View File

@ -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<Server>
@FetchRequest(entity: SignedInUser.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \SignedInUser.username, ascending: true)])
private var savedUsers: FetchedResults<SignedInUser>
@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<Server>
@FetchRequest(entity: SignedInUser.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \SignedInUser.username, ascending: true)])
var savedUsers: FetchedResults<SignedInUser>
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 {

View File

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<string>43</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>

View File

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<string>43</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>