From 358197db035e2f792f83a55bdf9a0e4984b0f594 Mon Sep 17 00:00:00 2001
From: ISO-B <3048685+ISO-B@users.noreply.github.com>
Date: Sun, 3 Nov 2024 21:45:05 +0200
Subject: [PATCH] iOS devices have always networkConnected status true
Capacitor Network plugin only shows ios device connected if internet access is available. This fix allows iOS users to use local server without internet access. Socket is used to detect if connection to server is availabe. networkConnected is only used for add server form and cellular permission check.
Cellular permissions for download and streaming wont work for iOS if device is connected to cellular, but without internet access to server that is used for connectivity check.
---
components/app/AudioPlayer.vue | 6 +++---
pages/item/_id/index.vue | 2 +-
store/index.js | 5 +++++
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/components/app/AudioPlayer.vue b/components/app/AudioPlayer.vue
index 4d9da9ca..cc34b698 100644
--- a/components/app/AudioPlayer.vue
+++ b/components/app/AudioPlayer.vue
@@ -50,7 +50,7 @@
- {{ bookmarks.length ? 'bookmark' : 'bookmark_border' }}
+ {{ bookmarks.length ? 'bookmark' : 'bookmark_border' }}
bookmark
@@ -375,8 +375,8 @@ export default {
return secondsRemaining + 's'
}
},
- networkConnected() {
- return this.$store.state.networkConnected
+ socketConnected() {
+ return this.$store.state.socketConnected
},
mediaId() {
if (this.isPodcast || !this.playbackSession) return null
diff --git a/pages/item/_id/index.vue b/pages/item/_id/index.vue
index 85a29cea..c2f27290 100644
--- a/pages/item/_id/index.vue
+++ b/pages/item/_id/index.vue
@@ -188,7 +188,7 @@ export default {
if (libraryItem?.libraryItemId?.startsWith('li_')) {
// Detect old library item id
console.error('Local library item has old server library item id', libraryItem.libraryItemId)
- } else if (query.noredirect !== '1' && libraryItem?.libraryItemId && libraryItem?.serverAddress === store.getters['user/getServerAddress'] && store.state.networkConnected) {
+ } else if (query.noredirect !== '1' && libraryItem?.libraryItemId && libraryItem?.serverAddress === store.getters['user/getServerAddress'] && store.state.socketConnected) {
const queryParams = new URLSearchParams()
queryParams.set('localLibraryItemId', libraryItemId)
if (libraryItem.mediaType === 'podcast') {
diff --git a/store/index.js b/store/index.js
index 2ea8341d..c641aa20 100644
--- a/store/index.js
+++ b/store/index.js
@@ -170,6 +170,11 @@ export const mutations = {
} else {
state.networkConnected = false
}
+ if (this.$platform === 'ios') {
+ // Capacitor Network plugin only shows ios device connected if internet access is available.
+ // This fix allows iOS users to use local servers without internet access.
+ state.networkConnected = true
+ }
state.networkConnectionType = val.connectionType
},
setIsNetworkUnmetered(state, val) {