mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-07-10 22:14:48 +02:00
Connect: Check if audiobookshelf and check for version
This commit is contained in:
parent
30d4e709f0
commit
945baa24f0
1 changed files with 27 additions and 1 deletions
|
@ -82,6 +82,8 @@ import { Browser } from '@capacitor/browser'
|
||||||
import { CapacitorHttp } from '@capacitor/core'
|
import { CapacitorHttp } from '@capacitor/core'
|
||||||
import { Dialog } from '@capacitor/dialog'
|
import { Dialog } from '@capacitor/dialog'
|
||||||
|
|
||||||
|
const requiredServerVersion = '2.5.0'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -587,10 +589,14 @@ export default {
|
||||||
this.error = 'Response from server was empty' // Usually some kind of config error on server side
|
this.error = 'Response from server was empty' // Usually some kind of config error on server side
|
||||||
console.error('[ServerConnectForm] Received empty response')
|
console.error('[ServerConnectForm] Received empty response')
|
||||||
return false
|
return false
|
||||||
} else if (!('isInit' in statusData.data) || !('language' in statusData.data)) { // TODO
|
} else if (!('app' in statusData.data) || statusData.data.app.toLowerCase() !== 'audiobookshelf') {
|
||||||
this.error = 'This does not seem to be a Audiobookshelf server'
|
this.error = 'This does not seem to be a Audiobookshelf server'
|
||||||
console.error('[ServerConnectForm] Received as response from Server:\n', statusData)
|
console.error('[ServerConnectForm] Received as response from Server:\n', statusData)
|
||||||
return false
|
return false
|
||||||
|
} else if (!this.isValidVersion(statusData.data.serverVersion, requiredServerVersion)) {
|
||||||
|
this.error = `Server version is below minimum required version of ${requiredServerVersion} (${statusData.data.serverVersion})`;
|
||||||
|
console.error('[ServerConnectForm] Server version is too low: ', statusData.data.serverVersion);
|
||||||
|
return false;
|
||||||
} else if (!statusData.data.isInit) {
|
} else if (!statusData.data.isInit) {
|
||||||
this.error = 'Server is not initialized'
|
this.error = 'Server is not initialized'
|
||||||
return false
|
return false
|
||||||
|
@ -666,6 +672,26 @@ export default {
|
||||||
? address
|
? address
|
||||||
: `https://${address}`
|
: `https://${address}`
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Compares two semantic versioning strings to determine if the current version meets
|
||||||
|
* or exceeds the minimum version requirement.
|
||||||
|
*
|
||||||
|
* @param {string} currentVersion - The current version string to compare, e.g., "1.2.3".
|
||||||
|
* @param {string} minVersion - The minimum version string required, e.g., "1.0.0".
|
||||||
|
* @returns {boolean} - Returns true if the current version is greater than or equal
|
||||||
|
* to the minimum version, false otherwise.
|
||||||
|
*/
|
||||||
|
isValidVersion(currentVersion, minVersion) {
|
||||||
|
const currentParts = currentVersion.split('.').map(Number);
|
||||||
|
const minParts = minVersion.split('.').map(Number);
|
||||||
|
|
||||||
|
for (let i = 0; i < minParts.length; i++) {
|
||||||
|
if (currentParts[i] > minParts[i]) return true;
|
||||||
|
if (currentParts[i] < minParts[i]) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
async submitAuth() {
|
async submitAuth() {
|
||||||
if (!this.networkConnected) return
|
if (!this.networkConnected) return
|
||||||
if (!this.serverConfig.username) {
|
if (!this.serverConfig.username) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue