Skip to content

Commit

Permalink
Fix WiFi Connection Status not Replicating Properly (#3)
Browse files Browse the repository at this point in the history
* fix: forApps not being passable through postMessage

* fix: WiFi state not being replicated properly
  • Loading branch information
gamenew09 authored Oct 14, 2024
1 parent c631159 commit 621b3ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions web/src/apps/settings/WifiTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ const connect = async (ssid: string, password?: string) => {
const { success, error } = data.value as ConnectionResponse
bus.emit('updated')
isConnecting.value = false
if (!success) {
bus.emit('updated')
return notif.show({
summary: locale.t('settings_wifi_connection_error'),
detail: error!
Expand All @@ -57,6 +56,7 @@ const connect = async (ssid: string, password?: string) => {
connection.markAsConnected(ssid)
bus.emit('updated')
notif.show({
summary: locale.t('settings_wifi_connection_succ'),
detail: `${locale.t('settings_wifi_connected_to')}${ssid}`
Expand Down Expand Up @@ -122,11 +122,10 @@ const disconnect = async () => {
const { success, error } = data.value as ConnectionResponse
bus.emit('updated')
isConnecting.value = false
if (!success) {
bus.emit('updated')
notif.show({
summary: locale.t('settings_wifi_connection_error'),
detail: error!
Expand All @@ -136,6 +135,7 @@ const disconnect = async () => {
connection.markAsDisconnected()
connection.connectedToVpn = false
bus.emit('updated')
notif.show({
summary: locale.t('settings_wifi_disconnect_succ'),
detail: locale.t('settings_wifi_disconnect_succ_detail')
Expand All @@ -160,14 +160,15 @@ const toggleVpn = async (status: boolean) => {
const { success } = data.value as ConnectionResponse
bus.emit('updated')
if (!success) {
connection.connectedToVpn = false
bus.emit('updated')
return
}
bus.emit('updated')
notif.show({
summary: 'VPN connection',
detail: status ? locale.t('settings_wifi_vpn_enabled') : locale.t('settings_wifi_vpn_disabled')
Expand All @@ -185,6 +186,8 @@ watchDebounced(
watchDebounced(
() => connection.airplaneMode,
(value) => {
bus.emit('updated')
if (value) {
disconnect()
Expand Down
2 changes: 1 addition & 1 deletion web/src/stores/connection.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const useConnection = defineStore('wifi', () => {

const forApps = computed<ConnectionStatus>(() => ({
isConnected: isConnected.value,
connectedTo: connectedTo.value,
connectedTo: connectedTo.value !== undefined ? JSON.parse(JSON.stringify(connectedTo.value)) : undefined,
airplaneMode: airplaneMode.value,
connectedToVpn: connectedToVpn.value
}))
Expand Down

0 comments on commit 621b3ce

Please sign in to comment.