mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-07-21 19:25:00 +02:00
Remove old code for downloads, user progress, sql, server config. Add web plugin for DbManager
This commit is contained in:
parent
9fd3dc6978
commit
4b834cb5c1
25 changed files with 106 additions and 2901 deletions
63
plugins/capacitor/DbManager.js
Normal file
63
plugins/capacitor/DbManager.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
import { registerPlugin, Capacitor, WebPlugin } from '@capacitor/core';
|
||||
|
||||
class DbWeb extends WebPlugin {
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
async getDeviceData_WV() {
|
||||
var dd = localStorage.getItem('device')
|
||||
if (dd) {
|
||||
return JSON.parse(dd)
|
||||
}
|
||||
const deviceData = {
|
||||
serverConnectionConfigs: [],
|
||||
lastServerConnectionConfigId: null,
|
||||
localLibraryItemIdPlaying: null
|
||||
}
|
||||
return deviceData
|
||||
}
|
||||
|
||||
async setCurrentServerConnectionConfig_WV(serverConnectionConfig) {
|
||||
var deviceData = await this.getDeviceData_WV()
|
||||
|
||||
var ssc = deviceData.serverConnectionConfigs.find(_ssc => _ssc.id == serverConnectionConfig.id)
|
||||
if (ssc) {
|
||||
deviceData.lastServerConnectionConfigId = ssc.id
|
||||
ssc.name = `${ssc.address} (${serverConnectionConfig.username})`
|
||||
ssc.token = serverConnectionConfig.token
|
||||
ssc.username = serverConnectionConfig.username
|
||||
localStorage.setItem('device', JSON.stringify(deviceData))
|
||||
} else {
|
||||
ssc = {
|
||||
id: encodeURIComponent(Buffer.from(`${serverConnectionConfig.address}@${serverConnectionConfig.username}`).toString('base64')),
|
||||
index: deviceData.serverConnectionConfigs.length,
|
||||
name: `${serverConnectionConfig.address} (${serverConnectionConfig.username})`,
|
||||
username: serverConnectionConfig.username,
|
||||
address: serverConnectionConfig.address,
|
||||
token: serverConnectionConfig.token
|
||||
}
|
||||
deviceData.serverConnectionConfigs.push(ssc)
|
||||
deviceData.lastServerConnectionConfigId = ssc.id
|
||||
localStorage.setItem('device', JSON.stringify(deviceData))
|
||||
}
|
||||
return ssc
|
||||
}
|
||||
|
||||
async removeServerConnectionConfig_WV(serverConnectionConfigCallObject) {
|
||||
var serverConnectionConfigId = serverConnectionConfigCallObject.serverConnectionConfigId
|
||||
var deviceData = await this.getDeviceData_WV()
|
||||
deviceData.serverConnectionConfigs = deviceData.serverConnectionConfigs.filter(ssc => ssc.id == serverConnectionConfigId)
|
||||
localStorage.setItem('device', JSON.stringify(deviceData))
|
||||
}
|
||||
|
||||
logout_WV() {
|
||||
// Nothing to do on web
|
||||
}
|
||||
}
|
||||
|
||||
const DbManager = registerPlugin('DbManager', {
|
||||
web: () => new DbWeb()
|
||||
})
|
||||
|
||||
export { DbManager }
|
Loading…
Add table
Add a link
Reference in a new issue