1
0
Fork 0
mirror of https://github.com/VueTorrent/VueTorrent.git synced 2025-03-26 11:30:37 +03:00

chore: add ability to inject fake torrents

This commit is contained in:
Daan Wijns 2023-10-21 13:55:56 +02:00
parent c50f1df4d6
commit 35849b3346
2 changed files with 12 additions and 7 deletions

View file

@ -1,2 +1,5 @@
VITE_QBITTORRENT_TARGET='http://127.0.0.1' VITE_QBITTORRENT_TARGET='http://127.0.0.1'
VITE_QBITTORRENT_PORT=8080 VITE_QBITTORRENT_PORT=8080
VITE_USE_FAKE_TORRENTS=true
VITE_FAKE_TORRENT_COUNT=10

View file

@ -10,8 +10,11 @@ import { useVueTorrentStore } from '@/stores/vuetorrent'
import { Category, ServerState } from '@/types/qbit/models' import { Category, ServerState } from '@/types/qbit/models'
import { AddTorrentPayload } from '@/types/qbit/payloads' import { AddTorrentPayload } from '@/types/qbit/payloads'
import { Torrent } from '@/types/vuetorrent' import { Torrent } from '@/types/vuetorrent'
import { generateMultiple } from '@/utils/faker'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { MaybeRefOrGetter, ref, toValue } from 'vue' import { MaybeRefOrGetter, computed, ref, toValue } from 'vue'
const isProduction = computed(() => process.env.NODE_ENV === 'production')
export const useMaindataStore = defineStore('maindata', () => { export const useMaindataStore = defineStore('maindata', () => {
const categories = ref<Category[]>([]) const categories = ref<Category[]>([])
@ -158,12 +161,11 @@ export const useMaindataStore = defineStore('maindata', () => {
// update torrents // update torrents
torrents.value = data.map(t => torrentBuilder.buildFromQbit(t)) torrents.value = data.map(t => torrentBuilder.buildFromQbit(t))
// TODO: load fake torrents if enabled if (!isProduction.value) {
// if (!isProduction()) { if (import.meta.env.VITE_USE_FAKE_TORRENTS === 'false') return
// if (import.meta.env.VITE_USE_FAKE_TORRENTS === 'false') return const count = import.meta.env.VITE_FAKE_TORRENT_COUNT
// const count = import.meta.env.VITE_FAKE_TORRENT_COUNT torrents.value.push(...generateMultiple(count).map(t => torrentBuilder.buildFromQbit(t)))
// store.state.torrents.push(...generateMultiple(count)) }
// }
// filter out deleted torrents from selection // filter out deleted torrents from selection
const hash_index = torrents.value.map(torrent => torrent.hash) const hash_index = torrents.value.map(torrent => torrent.hash)