Files
dupe/client/src/stores/animeStore.js
wisecolt 41c602104e feat(anime): anime yönetimi ve arayüzü ekle
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.
2026-01-28 21:48:18 +03:00

44 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
}
}