Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed network connection check logic #1359

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions components/app/Appbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<a v-if="showBack" @click="back" class="rounded-full h-10 w-10 flex items-center justify-center mr-2 cursor-pointer">
<span class="material-icons text-3xl text-fg">arrow_back</span>
</a>
<div v-if="user && currentLibrary && networkConnected">
<div v-if="user && currentLibrary && socketConnected">
<div class="pl-1.5 pr-2.5 py-2 bg-bg bg-opacity-30 rounded-md flex items-center" @click="clickShowLibraryModal">
<ui-library-icon :icon="currentLibraryIcon" :size="4" font-size="base" />
<p class="text-sm leading-4 ml-2 mt-0.5 max-w-24 truncate">{{ currentLibraryName }}</p>
Expand Down Expand Up @@ -54,8 +54,8 @@ export default {
this.$store.commit('setCastAvailable', val)
}
},
networkConnected() {
return this.$store.state.networkConnected
socketConnected() {
return this.$store.state.socketConnected
},
currentLibrary() {
return this.$store.getters['libraries/getCurrentLibrary']
Expand Down Expand Up @@ -160,4 +160,4 @@ export default {
transform: translate(10px, 0);
}
}
</style>
</style>
8 changes: 4 additions & 4 deletions components/tables/podcast/EpisodesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export default {
isAdminOrUp() {
return this.$store.getters['user/getIsAdminOrUp']
},
networkConnected() {
return this.$store.state.networkConnected
socketConnected() {
return this.$store.state.socketConnected
},
libraryItemId() {
return this.libraryItem?.id || null
Expand Down Expand Up @@ -233,7 +233,7 @@ export default {
}
},
async searchEpisodes() {
if (!this.networkConnected) {
if (!this.socketConnected) {
return this.$toast.error(this.$strings.MessageNoNetworkConnection)
}

Expand Down Expand Up @@ -314,4 +314,4 @@ export default {
this.$socket.$off('episode_download_finished', this.episodeDownloadFinished)
}
}
</script>
</script>
8 changes: 4 additions & 4 deletions pages/bookshelf/add-podcast.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<template v-if="!showSelectedFeed">
<div class="w-full mx-auto h-20 flex items-center px-2">
<form class="w-full" @submit.prevent="submit">
<ui-text-input v-model="searchInput" :disabled="processing || !networkConnected" placeholder="Enter search term or RSS feed URL" text-size="sm" />
<ui-text-input v-model="searchInput" :disabled="processing || !socketConnected" placeholder="Enter search term or RSS feed URL" text-size="sm" />
</form>
</div>

<div v-if="!networkConnected" class="w-full text-center py-6">
<div v-if="!socketConnected" class="w-full text-center py-6">
<p class="text-lg text-error">{{ $strings.MessageNoNetworkConnection }}</p>
</div>
<div v-else class="w-full mx-auto pb-2 overflow-y-auto overflow-x-hidden h-[calc(100%-85px)]">
Expand Down Expand Up @@ -65,8 +65,8 @@ export default {
}
},
computed: {
networkConnected() {
return this.$store.state.networkConnected
socketConnected() {
return this.$store.state.socketConnected
}
},
methods: {
Expand Down
30 changes: 17 additions & 13 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ export const state = () => ({
})

export const getters = {
getCurrentPlaybackSessionId: state => {
getCurrentPlaybackSessionId: (state) => {
return state.currentPlaybackSession?.id || null
},
getIsPlayerOpen: state => {
getIsPlayerOpen: (state) => {
return !!state.currentPlaybackSession
},
getIsCurrentSessionLocal: state => {
getIsCurrentSessionLocal: (state) => {
return state.currentPlaybackSession?.playMethod == PlayMethod.LOCAL
},
getIsMediaStreaming: state => (libraryItemId, episodeId) => {
getIsMediaStreaming: (state) => (libraryItemId, episodeId) => {
if (!state.currentPlaybackSession || !libraryItemId) return false

// Check using local library item id and local episode id
Expand All @@ -59,30 +59,30 @@ export const getters = {
if (!episodeId) return true
return state.currentPlaybackSession.episodeId === episodeId
},
getServerSetting: state => key => {
getServerSetting: (state) => (key) => {
if (!state.serverSettings) return null
return state.serverSettings[key]
},
getJumpForwardTime: state => {
getJumpForwardTime: (state) => {
if (!state.deviceData?.deviceSettings) return 10
return state.deviceData.deviceSettings.jumpForwardTime || 10
},
getJumpBackwardsTime: state => {
getJumpBackwardsTime: (state) => {
if (!state.deviceData?.deviceSettings) return 10
return state.deviceData.deviceSettings.jumpBackwardsTime || 10
},
getAltViewEnabled: state => {
getAltViewEnabled: (state) => {
if (!state.deviceData?.deviceSettings) return true
return state.deviceData.deviceSettings.enableAltView
},
getOrientationLockSetting: state => {
getOrientationLockSetting: (state) => {
return state.deviceData?.deviceSettings?.lockOrientation
},
getCanDownloadUsingCellular: state => {
getCanDownloadUsingCellular: (state) => {
if (!state.deviceData?.deviceSettings?.downloadUsingCellular) return 'ALWAYS'
return state.deviceData.deviceSettings.downloadUsingCellular || 'ALWAYS'
},
getCanStreamingUsingCellular: state => {
getCanStreamingUsingCellular: (state) => {
if (!state.deviceData?.deviceSettings?.streamingUsingCellular) return 'ALWAYS'
return state.deviceData.deviceSettings.streamingUsingCellular || 'ALWAYS'
}
Expand Down Expand Up @@ -124,7 +124,7 @@ export const mutations = {
setPlaybackSession(state, playbackSession) {
state.currentPlaybackSession = playbackSession

state.isCasting = playbackSession?.mediaPlayer === "cast-player"
state.isCasting = playbackSession?.mediaPlayer === 'cast-player'
},
setMediaPlayer(state, mediaPlayer) {
state.isCasting = mediaPlayer === 'cast-player'
Expand Down Expand Up @@ -165,7 +165,11 @@ export const mutations = {
state.isNetworkListenerInit = val
},
setNetworkStatus(state, val) {
state.networkConnected = val.connected
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about this change actually. Was val.connected false in your testing when connectionType was not none?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely ignored val.connected value based on assumption that if connectionType is none there can't be usable connection. I assume that wifi, cellular and unkown values for connectionType indicate that device is connected to some kind of network. That network might or might not have connection to internet which is indicated by val.connected. This should let app to work without internet connection, like with lan server. Like wise it should let app to work as offline if your server is on internet and you don't have internet connection.

if (val.connectionType !== 'none') {
state.networkConnected = true
} else {
state.networkConnected = false
}
state.networkConnectionType = val.connectionType
},
setIsNetworkUnmetered(state, val) {
Expand Down
Loading