mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-06-26 23:28:42 +02:00
Fix:Socket reconnection on disconnect, Add:Connection indicator icon showing socket/cellular
This commit is contained in:
parent
e07e7f70d6
commit
cb2aaede67
7 changed files with 95 additions and 21 deletions
73
components/widgets/ConnectionIndicator.vue
Normal file
73
components/widgets/ConnectionIndicator.vue
Normal file
|
@ -0,0 +1,73 @@
|
|||
<template>
|
||||
<div v-if="icon" class="flex h-full items-center px-2">
|
||||
<span class="material-icons-outlined text-lg" :class="iconClass" @click="showAlertDialog">{{ icon }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { Dialog } from '@capacitor/dialog'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
computed: {
|
||||
user() {
|
||||
return this.$store.state.user.user
|
||||
},
|
||||
socketConnected() {
|
||||
return this.$store.state.socketConnected
|
||||
},
|
||||
networkConnected() {
|
||||
return this.$store.state.networkConnected
|
||||
},
|
||||
networkConnectionType() {
|
||||
return this.$store.state.networkConnectionType
|
||||
},
|
||||
isCellular() {
|
||||
return this.networkConnectionType === 'cellular'
|
||||
},
|
||||
icon() {
|
||||
if (!this.networkConnected) {
|
||||
return 'wifi_off'
|
||||
} else if (!this.socketConnected) {
|
||||
return 'cloud_off'
|
||||
} else if (this.user) {
|
||||
if (this.isCellular) {
|
||||
return 'signal_cellular_alt'
|
||||
} else {
|
||||
return 'cloud_done'
|
||||
}
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
},
|
||||
iconClass() {
|
||||
if (!this.networkConnected) return 'text-error'
|
||||
else if (!this.socketConnected) return 'text-warning'
|
||||
else if (this.isCellular) return 'text-gray-200'
|
||||
else return 'text-success'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
showAlertDialog() {
|
||||
var msg = ''
|
||||
if (!this.networkConnected) {
|
||||
msg = 'No internet'
|
||||
} else if (!this.socketConnected) {
|
||||
msg = 'Socket not connected'
|
||||
} else if (this.isCellular) {
|
||||
msg = 'Socket connected over cellular'
|
||||
} else {
|
||||
msg = 'Socket connected over wifi'
|
||||
}
|
||||
Dialog.alert({
|
||||
title: 'Connection Status',
|
||||
message: msg
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted() {},
|
||||
beforeDestroy() {}
|
||||
}
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue