Fix:iOS offline reading and initialization

This commit is contained in:
advplyr 2023-06-20 16:29:56 -05:00
parent 147f89f870
commit 48342e5bd3
6 changed files with 19 additions and 12 deletions

View file

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

View file

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

View file

@ -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()
}

View file

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

View file

@ -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?.()
}
}

View file

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