This commit is contained in:
afkarxyz committed 2025-12-11 22:17:57 +07:00
1 parent 2d913d987f
commit aa87cce538
25 files changed
+3835 -1574

No files matched your search

+58
View File
@@ -6,6 +6,7 @@
import type { TwitterResponse, TimelineEntry, AccountInfo } from "@/types/api";
const FETCH_STATE_KEY = "twitter_fetch_state";
const CURSOR_STATE_KEY = "twitter_cursor_state"; // Lightweight cursor-only storage
export interface FetchState {
username: string;
@@ -166,6 +167,63 @@ export function stateToResponse(state: FetchState): TwitterResponse | null {
};
}
/**
* Save cursor only (lightweight, can be called every batch)
*/
export function saveCursor(username: string, cursor: string): void {
try {
const allCursors = getAllCursors();
allCursors[username.toLowerCase()] = {
cursor,
lastUpdated: Date.now(),
};
localStorage.setItem(CURSOR_STATE_KEY, JSON.stringify(allCursors));
} catch (error) {
console.error("Failed to save cursor:", error);
}
}
/**
* Get cursor for username from localStorage (lightweight, synchronous)
*/
export function getCursor(username: string): string | null {
try {
const allCursors = getAllCursors();
return allCursors[username.toLowerCase()]?.cursor || null;
} catch (error) {
console.error("Failed to get cursor:", error);
return null;
}
}
/**
* Get all cursors
*/
function getAllCursors(): Record<string, { cursor: string; lastUpdated: number }> {
try {
const stored = localStorage.getItem(CURSOR_STATE_KEY);
if (stored) {
return JSON.parse(stored);
}
} catch (error) {
console.error("Failed to parse cursors:", error);
}
return {};
}
/**
* Clear cursor for username
*/
export function clearCursor(username: string): void {
try {
const allCursors = getAllCursors();
delete allCursors[username.toLowerCase()];
localStorage.setItem(CURSOR_STATE_KEY, JSON.stringify(allCursors));
} catch (error) {
console.error("Failed to clear cursor:", error);
}
}
/**
* Merge new timeline entries with existing (deduplicate by tweet_id)
*/
+4
View File
@@ -12,6 +12,8 @@ export interface Settings {
sfxEnabled: boolean;
gifQuality: GifQuality;
gifResolution: GifResolution;
proxy: string; // Proxy URL (e.g., http://proxy:port or socks5://proxy:port). Empty to use system proxy or no proxy.
fetchTimeout: number; // Fetch timeout in seconds. Default: 60 seconds.
}
export const DEFAULT_SETTINGS: Settings = {
@@ -22,6 +24,8 @@ export const DEFAULT_SETTINGS: Settings = {
sfxEnabled: true,
gifQuality: "fast",
gifResolution: "high",
proxy: "",
fetchTimeout: 60, // Default: 60 seconds
};
export const FONT_OPTIONS: { value: FontFamily; label: string; fontFamily: string }[] = [