Skip to content

Commit

Permalink
perf: ♻️ Improved device connection stability
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Nov 27, 2024
1 parent 88a0356 commit 1d603ab
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/components/Device/components/WirelessAction/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export default {
type: Function,
default: () => () => false,
},
handleRefresh: {
type: Function,
default: () => () => false,
},
},
data() {
return {
Expand Down Expand Up @@ -90,6 +94,8 @@ export default {
this.$message.warning(error.message)
}
this.handleRefresh()
this.stopLoading = false
},
},
Expand Down
8 changes: 6 additions & 2 deletions src/components/Device/components/WirelessGroup/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,15 @@
</template>

<script>
import { sleep } from '$/utils'
import PairDialog from './PairDialog/index.vue'
export default {
components: {
PairDialog,
},
props: {
reload: {
handleRefresh: {
type: Function,
default: () => () => false,
},
Expand All @@ -117,7 +118,7 @@ export default {
const autoConnect = this.$store.preference.data.autoConnect
if (autoConnect) {
await this.handleBatch()
this.reload()
this.handleRefresh()
}
},
methods: {
Expand Down Expand Up @@ -237,6 +238,7 @@ export default {
try {
await this.$adb.connect(params.host, params.port || 5555)
await sleep()
this.$message.success(this.$t('device.wireless.connect.success'))
Expand All @@ -248,6 +250,8 @@ export default {
}
}
this.handleRefresh()
this.loading = false
},
handleSave(params) {
Expand Down
15 changes: 10 additions & 5 deletions src/components/Device/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="h-full flex flex-col">
<div class="flex-none flex items-center py-1 overflow-x-auto">
<div class="flex-none">
<WirelessGroup ref="wirelessGroupRef" :reload="getDeviceData" />
<WirelessGroup ref="wirelessGroupRef" v-bind="{ handleRefresh }" />
</div>

<div class="w-px h-7 !mx-4 bg-gray-200 dark:bg-gray-600 flex-none"></div>
Expand Down Expand Up @@ -96,7 +96,7 @@

<MoreDropdown v-bind="{ row, toggleRowExpansion, handleReset }" />

<WirelessAction v-bind="{ row, handleConnect }" />
<WirelessAction v-bind="{ row, handleConnect, handleRefresh }" />
</el-table-column>
<el-table-column type="expand">
<template #header>
Expand Down Expand Up @@ -215,7 +215,7 @@ export default {
async handleRefresh() {
this.loading = true
await sleep(500)
await sleep()
this.getDeviceData({ resetResolve: true, unloading: true })
},
Expand Down Expand Up @@ -262,11 +262,16 @@ export default {
this.deviceList = data
}
catch (error) {
const message = error?.message || error?.cause?.message
const message = error?.message || error?.cause?.message || ''
console.warn(message)
if (message && !message.includes('daemon not running')) {
if (message.includes('daemon not running')) {
this.getDeviceData()
return false
}
if (message) {
this.$message.warning(message)
}
Expand Down

0 comments on commit 1d603ab

Please sign in to comment.