Skip to content

Commit

Permalink
fix(filters): Don't count offline torrent in "Not working" tracker fi…
Browse files Browse the repository at this point in the history
…lter (#2051)
  • Loading branch information
Larsluph authored Nov 18, 2024
1 parent 0928458 commit d59cae7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/stores/categories.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { comparators } from '@/helpers'
import qbit from '@/services/qbit'
import { useTorrentStore } from '@/stores/torrents.ts'
import { Category } from '@/types/qbit/models'
import { useSorted } from '@vueuse/core'
import { acceptHMRUpdate, defineStore, storeToRefs } from 'pinia'
import { computed, shallowRef, triggerRef } from 'vue'
import { useTorrentStore } from './torrents'

export const useCategoryStore = defineStore('categories', () => {
/** Key: Category name */
Expand Down
4 changes: 2 additions & 2 deletions src/stores/content.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { useI18nUtils, useSearchQuery, useTreeBuilder } from '@/composables'
import { FilePriority } from '@/constants/qbit'
import qbit from '@/services/qbit'
import { useDialogStore } from '@/stores/dialog'
import { useVueTorrentStore } from '@/stores/vuetorrent'
import { TorrentFile } from '@/types/qbit/models'
import { RightClickMenuEntryType, RightClickProperties, TreeFolder, TreeNode } from '@/types/vuetorrent'
import { useIntervalFn } from '@vueuse/core'
import { acceptHMRUpdate, defineStore, storeToRefs } from 'pinia'
import { computed, nextTick, reactive, shallowRef, toRaw, triggerRef } from 'vue'
import { useTask } from 'vue-concurrency'
import { useRoute } from 'vue-router'
import { useDialogStore } from './dialog'
import { useVueTorrentStore } from './vuetorrent'

export const useContentStore = defineStore('content', () => {
const { t } = useI18nUtils()
Expand Down
2 changes: 1 addition & 1 deletion src/stores/tags.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { comparators } from '@/helpers'
import qbit from '@/services/qbit'
import { useTorrentStore } from '@/stores/torrents.ts'
import { useSorted } from '@vueuse/core'
import { acceptHMRUpdate, defineStore, storeToRefs } from 'pinia'
import { computed, shallowRef, triggerRef } from 'vue'
import { useTorrentStore } from './torrents'

export const useTagStore = defineStore('tags', () => {
const _tags = shallowRef<Set<string>>(new Set())
Expand Down
17 changes: 15 additions & 2 deletions src/stores/torrents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ import { useTrackerStore } from './trackers'
export const useTorrentStore = defineStore(
'torrents',
() => {
const torrentStateNotAnnounced = [
TorrentState.UNKNOWN,
TorrentState.ERROR,
TorrentState.MISSING_FILES,
TorrentState.DL_STOPPED,
TorrentState.UL_STOPPED,
TorrentState.UL_QUEUED,
TorrentState.DL_QUEUED,
TorrentState.CHECKING_DISK,
TorrentState.CHECKING_RESUME_DATA,
TorrentState.MOVING
]

const appStore = useAppStore()
const { buildFromQbit } = useTorrentBuilder()
const trackerStore = useTrackerStore()
Expand Down Expand Up @@ -81,7 +94,7 @@ export const useTorrentStore = defineStore(
if (trackers.length === 0) {
acc[TrackerSpecialFilter.UNTRACKED] = (acc[TrackerSpecialFilter.UNTRACKED] ?? 0) + 1
return acc
} else if (torrent.tracker === '') {
} else if (torrent.tracker === '' && !torrentStateNotAnnounced.includes(torrent.state)) {
acc[TrackerSpecialFilter.NOT_WORKING] = (acc[TrackerSpecialFilter.NOT_WORKING] ?? 0) + 1
return acc
}
Expand Down Expand Up @@ -130,7 +143,7 @@ export const useTorrentStore = defineStore(
case TrackerSpecialFilter.UNTRACKED:
return torrentTrackers.length === 0
case TrackerSpecialFilter.NOT_WORKING:
return torrentTrackers.length > 0 && t.tracker === ''
return torrentTrackers.length > 0 && t.tracker === '' && !torrentStateNotAnnounced.includes(t.state)
default:
return torrentTrackers.includes(tracker)
}
Expand Down

0 comments on commit d59cae7

Please sign in to comment.