fix: state glitching #724

This commit is contained in:
Daan Wijns 2023-03-21 09:09:36 +01:00
parent 0415752623
commit 260c1c6960
12 changed files with 41 additions and 58 deletions

View file

@ -2,21 +2,24 @@
## [1.5.1](https://github.com/WDaan/VueTorrent/compare/v1.5.0...v1.5.1) (2023-03-19)
### Bug Fixes
* cmd select torrent ([#702](https://github.com/WDaan/VueTorrent/issues/702)) ([97f7705](https://github.com/WDaan/VueTorrent/commit/97f77050f0b9926fd2c40da0fd2e6d8c5e930fe9))
* Ctrl key not being handled on Windows ([#715](https://github.com/WDaan/VueTorrent/issues/715)) ([ba77afb](https://github.com/WDaan/VueTorrent/commit/ba77afb35dcddc658de778da61b233ed113e9e0c))
* Trackers view ([#700](https://github.com/WDaan/VueTorrent/issues/700)) ([ee4cb7e](https://github.com/WDaan/VueTorrent/commit/ee4cb7ec1f6de1f362962f1545e2d361c0baab46))
- cmd select torrent ([#702](https://github.com/WDaan/VueTorrent/issues/702)) ([97f7705](https://github.com/WDaan/VueTorrent/commit/97f77050f0b9926fd2c40da0fd2e6d8c5e930fe9))
- Ctrl key not being handled on Windows ([#715](https://github.com/WDaan/VueTorrent/issues/715))
([ba77afb](https://github.com/WDaan/VueTorrent/commit/ba77afb35dcddc658de778da61b233ed113e9e0c))
- Trackers view ([#700](https://github.com/WDaan/VueTorrent/issues/700)) ([ee4cb7e](https://github.com/WDaan/VueTorrent/commit/ee4cb7ec1f6de1f362962f1545e2d361c0baab46))
### Improvements
* Add missing fields in dashboard / sortOptions ([#713](https://github.com/WDaan/VueTorrent/issues/713)) @Larsluph ([57b9aca](https://github.com/WDaan/VueTorrent/commit/57b9acaeef407e16853103593a440a725b6f3964))
* add refresh icon to RSS feeds ([#709](https://github.com/WDaan/VueTorrent/issues/709)) ([a583b42](https://github.com/WDaan/VueTorrent/commit/a583b42d68864c7280d6667706a7902b9b4e9fd1))
* Add seeds sort options ([#711](https://github.com/WDaan/VueTorrent/issues/711)) ([2c3afa5](https://github.com/WDaan/VueTorrent/commit/2c3afa57994f651457b1aa29ee4205583eb72d44))
* reset selected torrents when changing filters ([#712](https://github.com/WDaan/VueTorrent/issues/712)) ([b1b3212](https://github.com/WDaan/VueTorrent/commit/b1b32127e8fb811d01ec376e42694761a48ba23c))
* Sort files alphabetically in Content tab ([#714](https://github.com/WDaan/VueTorrent/issues/714)) ([baf17c7](https://github.com/WDaan/VueTorrent/commit/baf17c769544c7dba62ae504d4e8f57932c0ebf1))
- Add missing fields in dashboard / sortOptions ([#713](https://github.com/WDaan/VueTorrent/issues/713)) @Larsluph
([57b9aca](https://github.com/WDaan/VueTorrent/commit/57b9acaeef407e16853103593a440a725b6f3964))
- add refresh icon to RSS feeds ([#709](https://github.com/WDaan/VueTorrent/issues/709))
([a583b42](https://github.com/WDaan/VueTorrent/commit/a583b42d68864c7280d6667706a7902b9b4e9fd1))
- Add seeds sort options ([#711](https://github.com/WDaan/VueTorrent/issues/711)) ([2c3afa5](https://github.com/WDaan/VueTorrent/commit/2c3afa57994f651457b1aa29ee4205583eb72d44))
- reset selected torrents when changing filters ([#712](https://github.com/WDaan/VueTorrent/issues/712))
([b1b3212](https://github.com/WDaan/VueTorrent/commit/b1b32127e8fb811d01ec376e42694761a48ba23c))
- Sort files alphabetically in Content tab ([#714](https://github.com/WDaan/VueTorrent/issues/714))
([baf17c7](https://github.com/WDaan/VueTorrent/commit/baf17c769544c7dba62ae504d4e8f57932c0ebf1))
## [1.5.0](https://github.com/WDaan/VueTorrent/compare/v1.4.0...v1.5.0) (2023-03-05)

View file

@ -77,9 +77,7 @@ export default {
injectLocalization(properties) {
properties.forEach(property => {
// convert component name from PascalCase to snake_case to match locale key
const value = property.name
.replace(/\.?([A-Z]+)/g, (x, y) => "_" + y.toLowerCase())
.replace(/^_/, "")
const value = property.name.replace(/\.?([A-Z]+)/g, (x, y) => '_' + y.toLowerCase()).replace(/^_/, '')
property.label = i18n.t(`torrent.properties.${value}`)
})
return properties

View file

@ -62,9 +62,7 @@ export default {
methods: {
injectLocalization(properties) {
properties.forEach(property => {
const value = property.name
.replace(/\.?([A-Z]+)/g, (x, y) => "_" + y.toLowerCase())
.replace(/^_/, "")
const value = property.name.replace(/\.?([A-Z]+)/g, (x, y) => '_' + y.toLowerCase()).replace(/^_/, '')
property.label = i18n.t(`torrent.properties.${value}`)
})
return properties

View file

@ -105,7 +105,7 @@ function createFile(data, name, children) {
}
function createFolder(parent, name, children) {
children.sort((a,b) => a.name.localeCompare(b.name))
children.sort((a, b) => a.name.localeCompare(b.name))
return {
name: name,
fullName: parent === undefined ? name : `${parent.fullName}/${name}`,

View file

@ -616,4 +616,4 @@
"export": "Export Torrent | Export Torrents",
"info": "Show Info"
}
}
}

View file

@ -64,10 +64,10 @@
},
"torrent": {
"properties": {
"added_on": "Додано",
"amount_left": "Залишилось",
"availability": "Доступність",
"category": "Категорія",
"added_on": "Додано",
"amount_left": "Залишилось",
"availability": "Доступність",
"category": "Категорія",
"completed_on": "Виконано о",
"content_path": "Зберегти в",
"download_limit": "Ліміт завантаження",

View file

@ -19,28 +19,17 @@ export default class Status {
constructor(in_state?: Optional<ServerState>) {
const previous = store.state.status
if (!in_state) {
this.alltimeDownloaded = previous.alltimeDownloaded
this.alltimeUploaded = previous.alltimeUploaded
this.freeDiskSpace = previous.freeDiskSpace
this.sessionDownloaded = previous.sessionDownloaded
this.sessionUploaded = previous.sessionUploaded
Object.freeze(this)
return
}
this.alltimeDownloaded = in_state.alltime_dl || previous.alltimeDownloaded
this.alltimeUploaded = in_state.alltime_ul || previous.alltimeUploaded
this.altSpeed = in_state.use_alt_speed_limits !== undefined ? in_state.use_alt_speed_limits : previous.altSpeed
this.dlspeed = in_state.dl_info_speed || 0
this.dlspeedRaw = this.formatSpeed(in_state.dl_info_speed) || 0
this.freeDiskSpace = in_state.free_space_on_disk || previous.freeDiskSpace
this.sessionDownloaded = in_state.dl_info_data || previous.sessionDownloaded
this.sessionUploaded = in_state.up_info_data || previous.sessionUploaded
this.status = in_state.connection_status || previous.status
this.upspeed = in_state.up_info_speed || 0
this.upspeedRaw = this.formatSpeed(in_state.up_info_speed) || 0
this.alltimeDownloaded = in_state?.alltime_dl || previous.alltimeDownloaded
this.alltimeUploaded = in_state?.alltime_ul || previous.alltimeUploaded
this.altSpeed = in_state?.use_alt_speed_limits !== undefined ? in_state.use_alt_speed_limits : previous.altSpeed
this.dlspeed = in_state?.dl_info_speed || 0
this.dlspeedRaw = this.formatSpeed(in_state?.dl_info_speed || 0)
this.freeDiskSpace = in_state?.free_space_on_disk || previous.freeDiskSpace
this.sessionDownloaded = in_state?.dl_info_data || previous.sessionDownloaded
this.sessionUploaded = in_state?.up_info_data || previous.sessionUploaded
this.status = in_state?.connection_status || previous.status
this.upspeed = in_state?.up_info_speed || 0
this.upspeedRaw = this.formatSpeed(in_state?.up_info_speed || 0)
Object.freeze(this)
}

View file

@ -1,10 +1,10 @@
import dayjs from 'dayjs'
import duration from 'dayjs/plugin/duration'
import relativeTime from 'dayjs/plugin/relativeTime'
import {Priority, TorrentState as QbitTorrentState} from '@/enums/qbit'
import { Priority, TorrentState as QbitTorrentState } from '@/enums/qbit'
import { TorrentState as VtTorrentState } from '@/enums/vuetorrent'
import type { Torrent as QbitTorrent } from '@/types/qbit/models'
import i18n from "@/plugins/i18n";
import i18n from '@/plugins/i18n'
dayjs.extend(duration)
dayjs.extend(relativeTime)
@ -27,7 +27,7 @@ export default class Torrent {
dlspeed: number
download_path: string
downloaded: number
downloaded_session : number
downloaded_session: number
eta: string
f_l_piece_prio: boolean
forced: boolean
@ -70,9 +70,7 @@ export default class Torrent {
this.available_peers = data.num_incomplete
this.available_seeds = data.num_complete
this.category = data.category
this.completed_on = data.completion_on > 0
? dayjs(data.completion_on * 1000).format(format)
: i18n.t('dashboard.not_complete').toString()
this.completed_on = data.completion_on > 0 ? dayjs(data.completion_on * 1000).format(format) : i18n.t('dashboard.not_complete').toString()
this.content_path = data.content_path
this.dl_limit = data.dl_limit
this.dlspeed = data.dlspeed

View file

@ -1,5 +1,5 @@
import type { TorrentState } from '@/enums/qbit'
import {Priority} from "@/enums/qbit";
import { Priority } from '@/enums/qbit'
export default interface Torrent {
/** Time (Unix Epoch) when the torrent was added to the client */

View file

@ -212,7 +212,7 @@ export default {
{ value: 'uploaded_session', text: this.$t('modals.sort.sortBy.uploaded_session') },
{ value: 'upspeed', text: this.$t('modals.sort.sortBy.upspeed') }
]
sortOptions.sort((a,b) => a.text.localeCompare(b.text))
sortOptions.sort((a, b) => a.text.localeCompare(b.text))
return {
data: null,
@ -230,10 +230,7 @@ export default {
trcMoveTick: 0,
searchFilterEnabled: false,
sortEnabled: false,
sortOptions: [
{ value: '', text: this.$t('modals.sort.sortBy.default') },
...sortOptions
],
sortOptions: [{ value: '', text: this.$t('modals.sort.sortBy.default') }, ...sortOptions],
mdiTextBoxSearch,
mdiChevronLeftCircle,
mdiMagnify,

View file

@ -2,7 +2,7 @@ import { describe, beforeEach, it, expect, vi } from 'vitest'
import { shallowMount } from '@vue/test-utils'
import DesktopCard from '@/components/Settings/Tabs/VueTorrent/VDesktopCard.vue'
import {DashboardProperty} from "@/enums/vuetorrent";
import { DashboardProperty } from '@/enums/vuetorrent'
let wrapper

View file

@ -2,7 +2,7 @@ import { describe, beforeEach, it, expect, vi } from 'vitest'
import { shallowMount } from '@vue/test-utils'
import MobileCard from '@/components/Settings/Tabs/VueTorrent/VMobileCard.vue'
import {DashboardProperty} from '@/enums/vuetorrent'
import { DashboardProperty } from '@/enums/vuetorrent'
let wrapper