diff --git a/ios/App/App/AppDelegate.swift b/ios/App/App/AppDelegate.swift index 8831fabc..64c8ec83 100644 --- a/ios/App/App/AppDelegate.swift +++ b/ios/App/App/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Override point for customization after application launch. let configuration = Realm.Configuration( - schemaVersion: 11, + schemaVersion: 12, migrationBlock: { [weak self] migration, oldSchemaVersion in if (oldSchemaVersion < 1) { self?.logger.log("Realm schema version was \(oldSchemaVersion)") diff --git a/ios/App/Shared/models/server/EBookFile.swift b/ios/App/Shared/models/server/EBookFile.swift index 7280aa45..07637314 100644 --- a/ios/App/Shared/models/server/EBookFile.swift +++ b/ios/App/Shared/models/server/EBookFile.swift @@ -12,9 +12,17 @@ class EBookFile: EmbeddedObject, Codable { @Persisted var ino: String = "" @Persisted var metadata: FileMetadata? @Persisted var ebookFormat: String - @Persisted var contentUrl: String? + @Persisted var _contentUrl: String? @Persisted var localFileId: String? + var contentUrl: String? { + if let path = _contentUrl { + return AbsDownloader.itemDownloadFolder(path: path)!.absoluteString + } else { + return nil + } + } + private enum CodingKeys : String, CodingKey { case ino, metadata, ebookFormat, contentUrl, localFileId } @@ -29,7 +37,6 @@ class EBookFile: EmbeddedObject, Codable { ino = try values.decode(String.self, forKey: .ino) metadata = try values.decode(FileMetadata.self, forKey: .metadata) ebookFormat = try values.decode(String.self, forKey: .ebookFormat) - contentUrl = try? values.decode(String.self, forKey: .contentUrl) localFileId = try? values.decodeIfPresent(String.self, forKey: .localFileId) } @@ -46,7 +53,7 @@ class EBookFile: EmbeddedObject, Codable { extension EBookFile { func setLocalInfo(localFile: LocalFile) -> Bool { self.localFileId = localFile.id - self.contentUrl = localFile.contentUrl + self._contentUrl = localFile._contentUrl return false } diff --git a/layouts/default.vue b/layouts/default.vue index 42aa7223..31cd7596 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -307,6 +307,7 @@ export default { const deviceData = await this.$db.getDeviceData() this.$store.commit('setDeviceData', deviceData) + this.$setOrientationLock(this.$store.getters['getOrientationLockSetting']) await this.$store.dispatch('setupNetworkListener') @@ -314,10 +315,8 @@ export default { await this.$store.dispatch('globals/loadLocalMediaProgress') if (this.$store.state.user.serverConnectionConfig) { - console.log(`[default] server connection config set - call init libraries`) await this.initLibraries() } else { - console.log(`[default] no server connection config - call attempt connection`) await this.attemptConnection() } diff --git a/pages/settings.vue b/pages/settings.vue index 89596965..99abd9b7 100644 --- a/pages/settings.vue +++ b/pages/settings.vue @@ -370,7 +370,7 @@ export default { this.saveSettings() }, getCurrentOrientation() { - const orientation = window.screen ? window.screen.orientation || {} : {} + const orientation = window.screen?.orientation || {} const type = orientation.type || '' if (type.includes('landscape')) return 'LANDSCAPE' diff --git a/plugins/init.client.js b/plugins/init.client.js index 26063b9e..2d017d65 100644 --- a/plugins/init.client.js +++ b/plugins/init.client.js @@ -188,12 +188,14 @@ const decode = (text) => Buffer.from(decodeURIComponent(text), 'base64').toStrin Vue.prototype.$decode = decode Vue.prototype.$setOrientationLock = (orientationLockSetting) => { + if (!window.screen?.orientation) return + if (orientationLockSetting == 'PORTRAIT') { - window.screen.orientation.lock('portrait') + window.screen.orientation.lock?.('portrait') } else if (orientationLockSetting == 'LANDSCAPE') { - window.screen.orientation.lock('landscape') + window.screen.orientation.lock?.('landscape') } else { - window.screen.orientation.unlock() + window.screen.orientation.unlock?.() } } diff --git a/store/index.js b/store/index.js index 11366668..847c23f2 100644 --- a/store/index.js +++ b/store/index.js @@ -74,8 +74,7 @@ export const getters = { return state.deviceData.deviceSettings.enableAltView }, getOrientationLockSetting: state => { - if (!state.deviceData || !state.deviceData.deviceSettings) return false - return state.deviceData.deviceSettings.lockOrientation + return state.deviceData?.deviceSettings?.lockOrientation } }