fix some build errors
This commit is contained in:
@@ -258,7 +258,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import type { ProfitResult, Tier, JournalType } from '../../types/crafting'
|
import type { ProfitResult, JournalType } from '../../types/crafting'
|
||||||
import { formatSilver, formatLastUpdated, tierEnchantStyle, itemImageUrl } from '../../utils/formatting'
|
import { formatSilver, formatLastUpdated, tierEnchantStyle, itemImageUrl } from '../../utils/formatting'
|
||||||
import { useAlbionPrices } from '../../composables/useAlbionPrices'
|
import { useAlbionPrices } from '../../composables/useAlbionPrices'
|
||||||
import { useFilters } from '../../composables/useFilters'
|
import { useFilters } from '../../composables/useFilters'
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
import { ref, watch, onUnmounted } from 'vue'
|
|
||||||
import type { Ref } from 'vue'
|
|
||||||
import { AUTO_REFRESH_INTERVAL_S } from '../data/constants'
|
|
||||||
|
|
||||||
export function useAutoRefresh(fetchFn: () => Promise<void>, enabled: Ref<boolean>) {
|
|
||||||
const countdown = ref(AUTO_REFRESH_INTERVAL_S)
|
|
||||||
|
|
||||||
let intervalId: ReturnType<typeof setInterval> | null = null
|
|
||||||
let tickId: ReturnType<typeof setInterval> | null = null
|
|
||||||
|
|
||||||
function startRefresh() {
|
|
||||||
stopRefresh()
|
|
||||||
countdown.value = AUTO_REFRESH_INTERVAL_S
|
|
||||||
|
|
||||||
// Countdown tick every second
|
|
||||||
tickId = setInterval(() => {
|
|
||||||
countdown.value = Math.max(0, countdown.value - 1)
|
|
||||||
}, 1000)
|
|
||||||
|
|
||||||
// Fetch every interval
|
|
||||||
intervalId = setInterval(async () => {
|
|
||||||
await fetchFn()
|
|
||||||
countdown.value = AUTO_REFRESH_INTERVAL_S
|
|
||||||
}, AUTO_REFRESH_INTERVAL_S * 1000)
|
|
||||||
}
|
|
||||||
|
|
||||||
function stopRefresh() {
|
|
||||||
if (intervalId !== null) {
|
|
||||||
clearInterval(intervalId)
|
|
||||||
intervalId = null
|
|
||||||
}
|
|
||||||
if (tickId !== null) {
|
|
||||||
clearInterval(tickId)
|
|
||||||
tickId = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
enabled,
|
|
||||||
(val) => {
|
|
||||||
if (val) {
|
|
||||||
startRefresh()
|
|
||||||
} else {
|
|
||||||
stopRefresh()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ immediate: true }
|
|
||||||
)
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
|
||||||
stopRefresh()
|
|
||||||
})
|
|
||||||
|
|
||||||
return { countdown }
|
|
||||||
}
|
|
||||||
@@ -69,14 +69,11 @@
|
|||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import { tierStyle, itemImageUrl } from '../utils/formatting'
|
import { tierStyle, itemImageUrl } from '../utils/formatting'
|
||||||
import PriceCell from '../components/PriceCell.vue'
|
import PriceCell from '../components/PriceCell.vue'
|
||||||
import { useFilters } from '../composables/useFilters'
|
|
||||||
import { ENCHANTMENTS } from '../data/constants'
|
import { ENCHANTMENTS } from '../data/constants'
|
||||||
import type { Enchantment } from '../types/crafting'
|
import type { Enchantment } from '../types/crafting'
|
||||||
|
|
||||||
const { filters } = useFilters()
|
|
||||||
|
|
||||||
function enchantedId(baseId: string, enchant: Enchantment): string {
|
function enchantedId(baseId: string, enchant: Enchantment): string {
|
||||||
return enchant === 0 ? baseId : `${baseId}_LEVEL${enchant}@${enchant}`
|
return enchant === 0 ? baseId : `${baseId}_LEVEL${enchant}`
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MaterialDef {
|
interface MaterialDef {
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ import { computed, ref } from 'vue'
|
|||||||
import { useProductionOrder } from '../composables/useProductionOrder'
|
import { useProductionOrder } from '../composables/useProductionOrder'
|
||||||
import { useAlbionPrices } from '../composables/useAlbionPrices'
|
import { useAlbionPrices } from '../composables/useAlbionPrices'
|
||||||
import { useFilters } from '../composables/useFilters'
|
import { useFilters } from '../composables/useFilters'
|
||||||
import { formatSilver, formatItemId, formatLastUpdated, tierStyle, itemImageUrl } from '../utils/formatting'
|
import { formatSilver, formatItemId, formatLastUpdated, itemImageUrl } from '../utils/formatting'
|
||||||
import { fameTypeOf, craftsPerJournal } from '../data/constants'
|
import { fameTypeOf, craftsPerJournal } from '../data/constants'
|
||||||
import { localProductionBonus, rrrFromBonus, FOCUS_LPB, isRrrExempt } from '../data/cityBonuses'
|
import { localProductionBonus, rrrFromBonus, FOCUS_LPB, isRrrExempt } from '../data/cityBonuses'
|
||||||
import type { Tier, JournalType } from '../types/crafting'
|
import type { Tier, JournalType } from '../types/crafting'
|
||||||
|
|||||||
Reference in New Issue
Block a user