mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-07-02 18:14:47 +02:00
Fix:iOS offline reading and initialization
This commit is contained in:
parent
147f89f870
commit
48342e5bd3
6 changed files with 19 additions and 12 deletions
|
@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
// Override point for customization after application launch.
|
// Override point for customization after application launch.
|
||||||
|
|
||||||
let configuration = Realm.Configuration(
|
let configuration = Realm.Configuration(
|
||||||
schemaVersion: 11,
|
schemaVersion: 12,
|
||||||
migrationBlock: { [weak self] migration, oldSchemaVersion in
|
migrationBlock: { [weak self] migration, oldSchemaVersion in
|
||||||
if (oldSchemaVersion < 1) {
|
if (oldSchemaVersion < 1) {
|
||||||
self?.logger.log("Realm schema version was \(oldSchemaVersion)")
|
self?.logger.log("Realm schema version was \(oldSchemaVersion)")
|
||||||
|
|
|
@ -12,9 +12,17 @@ class EBookFile: EmbeddedObject, Codable {
|
||||||
@Persisted var ino: String = ""
|
@Persisted var ino: String = ""
|
||||||
@Persisted var metadata: FileMetadata?
|
@Persisted var metadata: FileMetadata?
|
||||||
@Persisted var ebookFormat: String
|
@Persisted var ebookFormat: String
|
||||||
@Persisted var contentUrl: String?
|
@Persisted var _contentUrl: String?
|
||||||
@Persisted var localFileId: 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 {
|
private enum CodingKeys : String, CodingKey {
|
||||||
case ino, metadata, ebookFormat, contentUrl, localFileId
|
case ino, metadata, ebookFormat, contentUrl, localFileId
|
||||||
}
|
}
|
||||||
|
@ -29,7 +37,6 @@ class EBookFile: EmbeddedObject, Codable {
|
||||||
ino = try values.decode(String.self, forKey: .ino)
|
ino = try values.decode(String.self, forKey: .ino)
|
||||||
metadata = try values.decode(FileMetadata.self, forKey: .metadata)
|
metadata = try values.decode(FileMetadata.self, forKey: .metadata)
|
||||||
ebookFormat = try values.decode(String.self, forKey: .ebookFormat)
|
ebookFormat = try values.decode(String.self, forKey: .ebookFormat)
|
||||||
contentUrl = try? values.decode(String.self, forKey: .contentUrl)
|
|
||||||
localFileId = try? values.decodeIfPresent(String.self, forKey: .localFileId)
|
localFileId = try? values.decodeIfPresent(String.self, forKey: .localFileId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +53,7 @@ class EBookFile: EmbeddedObject, Codable {
|
||||||
extension EBookFile {
|
extension EBookFile {
|
||||||
func setLocalInfo(localFile: LocalFile) -> Bool {
|
func setLocalInfo(localFile: LocalFile) -> Bool {
|
||||||
self.localFileId = localFile.id
|
self.localFileId = localFile.id
|
||||||
self.contentUrl = localFile.contentUrl
|
self._contentUrl = localFile._contentUrl
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -307,6 +307,7 @@ export default {
|
||||||
|
|
||||||
const deviceData = await this.$db.getDeviceData()
|
const deviceData = await this.$db.getDeviceData()
|
||||||
this.$store.commit('setDeviceData', deviceData)
|
this.$store.commit('setDeviceData', deviceData)
|
||||||
|
|
||||||
this.$setOrientationLock(this.$store.getters['getOrientationLockSetting'])
|
this.$setOrientationLock(this.$store.getters['getOrientationLockSetting'])
|
||||||
|
|
||||||
await this.$store.dispatch('setupNetworkListener')
|
await this.$store.dispatch('setupNetworkListener')
|
||||||
|
@ -314,10 +315,8 @@ export default {
|
||||||
await this.$store.dispatch('globals/loadLocalMediaProgress')
|
await this.$store.dispatch('globals/loadLocalMediaProgress')
|
||||||
|
|
||||||
if (this.$store.state.user.serverConnectionConfig) {
|
if (this.$store.state.user.serverConnectionConfig) {
|
||||||
console.log(`[default] server connection config set - call init libraries`)
|
|
||||||
await this.initLibraries()
|
await this.initLibraries()
|
||||||
} else {
|
} else {
|
||||||
console.log(`[default] no server connection config - call attempt connection`)
|
|
||||||
await this.attemptConnection()
|
await this.attemptConnection()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -370,7 +370,7 @@ export default {
|
||||||
this.saveSettings()
|
this.saveSettings()
|
||||||
},
|
},
|
||||||
getCurrentOrientation() {
|
getCurrentOrientation() {
|
||||||
const orientation = window.screen ? window.screen.orientation || {} : {}
|
const orientation = window.screen?.orientation || {}
|
||||||
const type = orientation.type || ''
|
const type = orientation.type || ''
|
||||||
|
|
||||||
if (type.includes('landscape')) return 'LANDSCAPE'
|
if (type.includes('landscape')) return 'LANDSCAPE'
|
||||||
|
|
|
@ -188,12 +188,14 @@ const decode = (text) => Buffer.from(decodeURIComponent(text), 'base64').toStrin
|
||||||
Vue.prototype.$decode = decode
|
Vue.prototype.$decode = decode
|
||||||
|
|
||||||
Vue.prototype.$setOrientationLock = (orientationLockSetting) => {
|
Vue.prototype.$setOrientationLock = (orientationLockSetting) => {
|
||||||
|
if (!window.screen?.orientation) return
|
||||||
|
|
||||||
if (orientationLockSetting == 'PORTRAIT') {
|
if (orientationLockSetting == 'PORTRAIT') {
|
||||||
window.screen.orientation.lock('portrait')
|
window.screen.orientation.lock?.('portrait')
|
||||||
} else if (orientationLockSetting == 'LANDSCAPE') {
|
} else if (orientationLockSetting == 'LANDSCAPE') {
|
||||||
window.screen.orientation.lock('landscape')
|
window.screen.orientation.lock?.('landscape')
|
||||||
} else {
|
} else {
|
||||||
window.screen.orientation.unlock()
|
window.screen.orientation.unlock?.()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,7 @@ export const getters = {
|
||||||
return state.deviceData.deviceSettings.enableAltView
|
return state.deviceData.deviceSettings.enableAltView
|
||||||
},
|
},
|
||||||
getOrientationLockSetting: state => {
|
getOrientationLockSetting: state => {
|
||||||
if (!state.deviceData || !state.deviceData.deviceSettings) return false
|
return state.deviceData?.deviceSettings?.lockOrientation
|
||||||
return state.deviceData.deviceSettings.lockOrientation
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue