mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-08 12:58:38 +02:00
Refactor capacitor plugins, clean up and organize android plugin classes
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { registerPlugin, WebPlugin } from '@capacitor/core';
|
||||
|
||||
class AbsAudioPlayerWeb extends WebPlugin {
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
}
|
||||
|
||||
const AbsAudioPlayer = registerPlugin('AbsAudioPlayer', {
|
||||
web: () => new AbsAudioPlayerWeb()
|
||||
})
|
||||
|
||||
export { AbsAudioPlayer }
|
||||
@@ -1,11 +1,11 @@
|
||||
import { registerPlugin, Capacitor, WebPlugin } from '@capacitor/core';
|
||||
|
||||
class DbWeb extends WebPlugin {
|
||||
class AbsDatabaseWeb extends WebPlugin {
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
async getDeviceData_WV() {
|
||||
async getDeviceData() {
|
||||
var dd = localStorage.getItem('device')
|
||||
if (dd) {
|
||||
return JSON.parse(dd)
|
||||
@@ -18,8 +18,8 @@ class DbWeb extends WebPlugin {
|
||||
return deviceData
|
||||
}
|
||||
|
||||
async setCurrentServerConnectionConfig_WV(serverConnectionConfig) {
|
||||
var deviceData = await this.getDeviceData_WV()
|
||||
async setCurrentServerConnectionConfig(serverConnectionConfig) {
|
||||
var deviceData = await this.getDeviceData()
|
||||
|
||||
var ssc = deviceData.serverConnectionConfigs.find(_ssc => _ssc.id == serverConnectionConfig.id)
|
||||
if (ssc) {
|
||||
@@ -44,20 +44,22 @@ class DbWeb extends WebPlugin {
|
||||
return ssc
|
||||
}
|
||||
|
||||
async removeServerConnectionConfig_WV(serverConnectionConfigCallObject) {
|
||||
async removeServerConnectionConfig(serverConnectionConfigCallObject) {
|
||||
var serverConnectionConfigId = serverConnectionConfigCallObject.serverConnectionConfigId
|
||||
var deviceData = await this.getDeviceData_WV()
|
||||
var deviceData = await this.getDeviceData()
|
||||
deviceData.serverConnectionConfigs = deviceData.serverConnectionConfigs.filter(ssc => ssc.id == serverConnectionConfigId)
|
||||
localStorage.setItem('device', JSON.stringify(deviceData))
|
||||
}
|
||||
|
||||
logout_WV() {
|
||||
// Nothing to do on web
|
||||
async logout() {
|
||||
var deviceData = await this.getDeviceData()
|
||||
deviceData.lastServerConnectionConfigId = null
|
||||
localStorage.setItem('device', JSON.stringify(deviceData))
|
||||
}
|
||||
}
|
||||
|
||||
const DbManager = registerPlugin('DbManager', {
|
||||
web: () => new DbWeb()
|
||||
const AbsDatabase = registerPlugin('AbsDatabase', {
|
||||
web: () => new AbsDatabaseWeb()
|
||||
})
|
||||
|
||||
export { DbManager }
|
||||
export { AbsDatabase }
|
||||
@@ -0,0 +1,13 @@
|
||||
import { registerPlugin, WebPlugin } from '@capacitor/core';
|
||||
|
||||
class AbsDownloaderWeb extends WebPlugin {
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
}
|
||||
|
||||
const AbsDownloader = registerPlugin('AbsDownloader', {
|
||||
web: () => new AbsDownloaderWeb()
|
||||
})
|
||||
|
||||
export { AbsDownloader }
|
||||
@@ -0,0 +1,13 @@
|
||||
import { registerPlugin, WebPlugin } from '@capacitor/core';
|
||||
|
||||
class AbsFileSystemWeb extends WebPlugin {
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
}
|
||||
|
||||
const AbsFileSystem = registerPlugin('AbsFileSystem', {
|
||||
web: () => new AbsFileSystemWeb()
|
||||
})
|
||||
|
||||
export { AbsFileSystem }
|
||||
@@ -0,0 +1,13 @@
|
||||
import Vue from 'vue'
|
||||
import { AbsAudioPlayer } from './AbsAudioPlayer'
|
||||
import { AbsDownloader } from './AbsDownloader'
|
||||
import { AbsFileSystem } from './AbsFileSystem'
|
||||
import { Capacitor } from '@capacitor/core'
|
||||
|
||||
Vue.prototype.$platform = Capacitor.getPlatform()
|
||||
|
||||
export {
|
||||
AbsAudioPlayer,
|
||||
AbsDownloader,
|
||||
AbsFileSystem
|
||||
}
|
||||
Reference in New Issue
Block a user