Skip to content

Commit

Permalink
feat: auto refresh peers
Browse files Browse the repository at this point in the history
auto refresh peers
  • Loading branch information
m4ximuel committed Apr 4, 2021
1 parent 664e4db commit dfd10be
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/components/Modals/TorrentDetailModal/Tabs/Peers.vue
Expand Up @@ -2,11 +2,12 @@
<perfect-scrollbar>
<v-data-table
v-if="peers"
dense
:headers="headers"
:items="peers"
:items-per-page="-1"
:hide-default-footer="true"
:style="{ minHeight: phoneLayout ? '' : '75vh', maxHeight: '75vh'}"
mobile-breakpoint="0"
>
<template #item="row">
<tr>
Expand Down Expand Up @@ -56,6 +57,7 @@ export default {
mixins: [FullScreenModal],
props: { hash: String, isActive: Boolean },
data: () => ({
refreshTimer: '',
headers: [
{ text: 'IP', value: 'ip' },
{ text: 'Connection', value: 'connection' },
Expand Down Expand Up @@ -93,6 +95,9 @@ export default {
},
created() {
this.getTorrentPeers()
this.refreshTimer = setInterval(function(){
this.getTorrentPeers()
}.bind(this), 2000)
},
methods: {
codeToFlag(val) {
Expand All @@ -111,6 +116,9 @@ export default {
this.peersObj = data.peers
}
},
beforeDestroy() {
clearTimeout(this.refreshTimer)
}
}
</script>
Expand All @@ -131,16 +139,20 @@ export default {
::v-deep .v-data-table thead th,
::v-deep .v-data-table tbody td {
padding: 0 2px !important;
padding: 0 3px !important;
height: auto;
white-space: nowrap;
&:first-child {
padding: 0 0 0 8px !important;
}
&:last-child {
padding-right: 8px !important;
}
}
::v-deep .v-data-table-header {
white-space: nowrap;
}
::v-deep td {
white-space: nowrap;
}
</style>

0 comments on commit dfd10be

Please sign in to comment.