Kullanıcı arayüzünde Anime sekmesi ve oynatıcı entegrasyonu eklendi. Sunucu tarafında Anime için özel bir veri yapısı ve API uç noktaları oluşturuldu. - Anime içerikleri için `_anime` klasöründe ayrı metadata saklama alanı eklendi. - Kök dizindeki (root) dosyaların çöpe taşınması ve geri yüklenmesi için 'root-trash' sistemi tanımlandı. - TVDB sorgularında Anime için İngilizce dil tercihi uygulandı. - Mail.ru indirmelerinde anime kapsamı (scope) desteği eklendi.
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
import { writable } from "svelte/store";
|
||
import { apiFetch } from "../utils/api.js";
|
||
|
||
export const animeCount = writable(0);
|
||
let requestSeq = 0;
|
||
let lastValue = 0;
|
||
let zeroTimer = null;
|
||
|
||
export async function refreshAnimeCount() {
|
||
const ticket = ++requestSeq;
|
||
try {
|
||
const resp = await apiFetch("/api/anime");
|
||
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
||
const list = await resp.json();
|
||
if (ticket !== requestSeq) return;
|
||
const nextVal = Array.isArray(list) ? list.length : 0;
|
||
if (nextVal > 0) {
|
||
if (zeroTimer) {
|
||
clearTimeout(zeroTimer);
|
||
zeroTimer = null;
|
||
}
|
||
lastValue = nextVal;
|
||
animeCount.set(nextVal);
|
||
} else if (lastValue > 0) {
|
||
if (zeroTimer) clearTimeout(zeroTimer);
|
||
const zeroTicket = requestSeq;
|
||
zeroTimer = setTimeout(() => {
|
||
if (zeroTicket === requestSeq) {
|
||
lastValue = 0;
|
||
animeCount.set(0);
|
||
}
|
||
zeroTimer = null;
|
||
}, 500);
|
||
} else {
|
||
lastValue = 0;
|
||
animeCount.set(0);
|
||
}
|
||
} catch (err) {
|
||
console.warn("⚠️ Anime sayacı güncellenemedi:", err?.message || err);
|
||
// Hata durumunda mevcut değeri koru, titreşimi önle
|
||
}
|
||
}
|
||
|