mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2026-09-27 15:15:48 +00:00
add private league support (#464)
Co-authored-by: Alexander Drozdov <snosme@gmail.com>
This commit is contained in:
co-authored by
Alexander Drozdov
parent
ff9fcff699
commit
8cbd0489d4
@@ -16,6 +16,13 @@ export const selected = computed<string | undefined>({
|
||||
}
|
||||
})
|
||||
|
||||
export const isPublic = computed<boolean | undefined>(() =>
|
||||
selected.value ? isPublicLeague(selected.value) : undefined)
|
||||
|
||||
export function isPublicLeague (id: string) {
|
||||
return tradeLeagues.value.some(league => id === league.id)
|
||||
}
|
||||
|
||||
export async function load () {
|
||||
isLoading.value = true
|
||||
error.value = null
|
||||
@@ -27,7 +34,7 @@ export async function load () {
|
||||
tradeLeagues.value = leagues.filter(league => !league.rules.some(rule => rule.id === 'NoParties'))
|
||||
|
||||
const leagueIsAlive = tradeLeagues.value.some(league => league.id === selected.value)
|
||||
if (!leagueIsAlive) {
|
||||
if (!leagueIsAlive && isRegularLeague(selected.value!)) {
|
||||
if (tradeLeagues.value.length > 2) {
|
||||
const TMP_CHALLENGE = 2
|
||||
selected.value = tradeLeagues.value[TMP_CHALLENGE].id
|
||||
@@ -42,3 +49,9 @@ export async function load () {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function isRegularLeague (id: string) {
|
||||
// not a Private League (PL01)
|
||||
// not a Race Event (.RE01)
|
||||
return /^[A-Za-z ]+$/.test(id)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ref, watch } from 'vue'
|
||||
import { MainProcess } from '@/ipc/main-process-bindings'
|
||||
import { selected as selectedLeague } from './Leagues'
|
||||
import { selected as selectedLeague, isPublic as isPublicLeague } from './Leagues'
|
||||
import { nameToDetailsId } from '../price-check/trends/getDetailsId'
|
||||
|
||||
interface NinjaCurrencyInfo { /* eslint-disable camelcase */
|
||||
@@ -64,7 +64,7 @@ export interface ItemInfo {
|
||||
detailsId: string
|
||||
}
|
||||
|
||||
const PRICE_BY_DETAILS_ID = new Map<string, ItemInfo>()
|
||||
let PRICE_BY_DETAILS_ID = new Map<string, ItemInfo>()
|
||||
|
||||
const RETRY_TIME = 60 * 1000
|
||||
const UPDATE_TIME = 10 * 60 * 1000
|
||||
@@ -102,7 +102,7 @@ const priceQueue = [
|
||||
]
|
||||
|
||||
async function load (force: boolean = false) {
|
||||
if (!selectedLeague.value) return
|
||||
if (!selectedLeague.value || !isPublicLeague.value) return
|
||||
const leagueAtStartOfLoad = selectedLeague.value
|
||||
|
||||
for (const dataType of priceQueue) {
|
||||
@@ -231,5 +231,7 @@ setInterval(() => {
|
||||
}, RETRY_TIME)
|
||||
|
||||
watch(selectedLeague, () => {
|
||||
chaosExaRate.value = undefined
|
||||
PRICE_BY_DETAILS_ID = new Map<string, ItemInfo>()
|
||||
load(true)
|
||||
})
|
||||
|
||||
@@ -60,7 +60,7 @@ import { AppConfig } from '@/web/Config'
|
||||
import { FilterTag, ItemFilters, StatFilter } from './filters/interfaces'
|
||||
import { MainProcess } from '@/ipc/main-process-bindings'
|
||||
import { PriceCheckWidget } from '../overlay/interfaces'
|
||||
import { selected as selectedLeague } from '@/web/background/Leagues'
|
||||
import { selected as selectedLeague, isPublic as isPublicLeague } from '@/web/background/Leagues'
|
||||
|
||||
let _showSupportLinksCounter = 0
|
||||
|
||||
@@ -160,7 +160,8 @@ export default defineComponent({
|
||||
}, { deep: false })
|
||||
|
||||
const showPredictedPrice = computed(() => {
|
||||
if (AppConfig().language !== 'en') return false
|
||||
if (AppConfig().language !== 'en' ||
|
||||
!isPublicLeague.value) return false
|
||||
|
||||
return props.item.rarity === ItemRarity.Rare &&
|
||||
props.item.category !== ItemCategory.Map &&
|
||||
|
||||
@@ -50,16 +50,15 @@ export default defineComponent({
|
||||
})
|
||||
|
||||
const result = computed(() => {
|
||||
if (!detailsId.value) return
|
||||
|
||||
if (!ITEM_DROP.has(detailsId.value)) return null
|
||||
if (!detailsId.value || !ITEM_DROP.has(detailsId.value)) return null
|
||||
|
||||
const r = ITEM_DROP.get(detailsId.value)!
|
||||
return {
|
||||
const out = {
|
||||
// TODO: show at least icon when price is not available on poe.ninja yet
|
||||
related: r.query.map(id => findByDetailsId(id)).filter(_ => Boolean(_)),
|
||||
items: r.items.map(id => findByDetailsId(id)).filter(_ => Boolean(_))
|
||||
}
|
||||
return (out.related.length) ? out : null
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
@@ -6,13 +6,19 @@
|
||||
</div>
|
||||
<div v-if="leagues.isLoading.value" class="mb-4">
|
||||
<i class="fas fa-info-circle text-gray-600"></i> {{ t('Loading leagues...') }}</div>
|
||||
<div v-else-if="leagues.trade.value.length"
|
||||
class="mb-4 grid grid-cols-2 gap-x-2 gap-y-1 whitespace-no-wrap"
|
||||
style="grid-template-columns: repeat(2, min-content);">
|
||||
<div v-for="league of leagues.trade.value" :key="league.id">
|
||||
<ui-radio v-model="leagueId" :value="league.id">{{ league.id }}</ui-radio>
|
||||
<template v-else-if="leagues.trade.value.length">
|
||||
<div
|
||||
class="mb-2 grid grid-cols-2 gap-x-2 gap-y-1 whitespace-no-wrap"
|
||||
style="grid-template-columns: repeat(2, min-content);">
|
||||
<div v-for="league of leagues.trade.value" :key="league.id">
|
||||
<ui-radio v-model="leagueId" :value="league.id">{{ league.id }}</ui-radio>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-x-2 mb-4">
|
||||
<div class="text-gray-500">{{ t('or Private League') }}</div>
|
||||
<input v-model="customLeagueId" placeholder="My League (PL12345)" class="rounded bg-gray-900 px-1 mb-1 flex-1" />
|
||||
</div>
|
||||
</template>
|
||||
<div v-else-if="leagues.error.value || true" class="mb-4">
|
||||
<span class="text-red-400">{{ t('Failed to load leagues') }}</span>
|
||||
</div>
|
||||
@@ -116,6 +122,12 @@ export default defineComponent({
|
||||
return {
|
||||
t,
|
||||
leagueId: configModelValue(() => props.config, 'leagueId'),
|
||||
customLeagueId: computed<string>({
|
||||
get: () => !Leagues.isPublicLeague(props.config.leagueId ?? '')
|
||||
? props.config.leagueId ?? ''
|
||||
: '',
|
||||
set: (value) => { props.config.leagueId = value }
|
||||
}),
|
||||
accountName: configModelValue(() => props.config, 'accountName'),
|
||||
showSeller: configModelValue(() => configWidget.value, 'showSeller'),
|
||||
activateStockFilter: configModelValue(() => configWidget.value, 'activateStockFilter'),
|
||||
@@ -174,6 +186,7 @@ export default defineComponent({
|
||||
{
|
||||
"ru": {
|
||||
"Account name": "Имя учетной записи",
|
||||
"or Private League": "или Приватная лига",
|
||||
"Show seller": "Показывать продавца",
|
||||
"Last character name": "Имя последнего персонажа",
|
||||
"Your items will be highlighted even if this setting is off": "Ваши предметы будут подсвечены, даже если эта настройка выключена",
|
||||
|
||||
Reference in New Issue
Block a user