perf: Add hook to repaint piece state canvas on update (#869)

This commit is contained in:
Rémi Marseault 2023-06-23 07:52:39 +02:00 committed by GitHub
parent 194f568036
commit 87038f48b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View file

@ -326,7 +326,6 @@ export default defineComponent({
name: 'Info',
mixins: [FullScreenModal],
props: {
hash: String,
torrent: Torrent,
isActive: Boolean
},
@ -361,9 +360,14 @@ export default defineComponent({
return this.torrent?.state ? this.torrent.state.toLowerCase() : ''
}
},
watch: {
torrent() {
this.renderTorrentPieceStates()
}
},
methods: {
async getTorrentProperties() {
const props = await qbit.getTorrentProperties(this.hash as string)
const props = await qbit.getTorrentProperties(this.torrent?.hash as string)
this.comment = props.comment
this.createdBy = props.created_by
// @ts-expect-error: TS2339: Property 'dateFormat' does not exist on type 'never'.
@ -380,8 +384,8 @@ export default defineComponent({
const canvas: HTMLCanvasElement | null = document.querySelector('#pieceStates canvas')
if (canvas === null) return
const files = await qbit.getTorrentFiles(this.hash as string)
const pieces = await qbit.getTorrentPieceStates(this.hash as string)
const files = await qbit.getTorrentFiles(this.torrent?.hash as string)
const pieces = await qbit.getTorrentPieceStates(this.torrent?.hash as string)
if (!pieces) return
// Source: https://github.com/qbittorrent/qBittorrent/blob/6229b817300344759139d2fedbd59651065a561d/src/webui/www/private/scripts/prop-general.js#L230

View file

@ -38,7 +38,7 @@
<v-card-text class="pa-0">
<v-tabs-items v-model="tab" touchless>
<v-tab-item eager value="info">
<Info v-if="torrent" :torrent="torrent" :hash="hash" />
<Info v-if="torrent" :is-active="tab === 'info'" :torrent="torrent" />
</v-tab-item>
<v-tab-item eager value="trackers">
<Trackers :is-active="tab === 'trackers'" :hash="hash" />