fix(test1): 恢复旧任务可见性,默认显示全部账号
未打账号标记的历史任务不再被过滤隐藏;默认进入「全部账号」。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b0706b351b
commit
708b2148bb
@ -29,6 +29,7 @@ type XClipJob = {
|
|||||||
error?: string;
|
error?: string;
|
||||||
x2_job_id?: string;
|
x2_job_id?: string;
|
||||||
tweet_id?: string;
|
tweet_id?: string;
|
||||||
|
account_username?: string;
|
||||||
push_date?: string;
|
push_date?: string;
|
||||||
created_at?: number;
|
created_at?: number;
|
||||||
};
|
};
|
||||||
@ -79,11 +80,10 @@ export function ClipsPanel({
|
|||||||
const load = useCallback(async () => {
|
const load = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
const iso = todayBeijingISO();
|
const iso = todayBeijingISO();
|
||||||
const acct = (accountUsername || "").trim().replace(/^@/, "");
|
// Always load full day list; filter client-side so legacy (no account) jobs stay visible
|
||||||
const q = acct ? `&account_username=${encodeURIComponent(acct)}` : "";
|
|
||||||
const [status, jobData] = await Promise.all([
|
const [status, jobData] = await Promise.all([
|
||||||
fetchJson("/api/x-clips/status"),
|
fetchJson("/api/x-clips/status"),
|
||||||
fetchJson(`/api/x-clips/jobs?push_date=${iso}&limit=40${q}`),
|
fetchJson(`/api/x-clips/jobs?push_date=${iso}&limit=80`),
|
||||||
]);
|
]);
|
||||||
setSt(status || null);
|
setSt(status || null);
|
||||||
const s = status?.settings || {};
|
const s = status?.settings || {};
|
||||||
@ -93,7 +93,19 @@ export function ClipsPanel({
|
|||||||
setTrigger(String(s.x_clips_trigger || "tagged"));
|
setTrigger(String(s.x_clips_trigger || "tagged"));
|
||||||
setSampleAny(Boolean(s.x_clips_sample_any_live ?? true));
|
setSampleAny(Boolean(s.x_clips_sample_any_live ?? true));
|
||||||
setAutoPost(Boolean(s.x_clips_auto_post ?? true));
|
setAutoPost(Boolean(s.x_clips_auto_post ?? true));
|
||||||
setJobs(jobData?.jobs || []);
|
const acct = (accountUsername || "").trim().replace(/^@/, "").toLowerCase();
|
||||||
|
const all = (jobData?.jobs || []) as XClipJob[];
|
||||||
|
setJobs(
|
||||||
|
acct
|
||||||
|
? all.filter((j) => {
|
||||||
|
const own = String(j.account_username || "")
|
||||||
|
.trim()
|
||||||
|
.replace(/^@/, "")
|
||||||
|
.toLowerCase();
|
||||||
|
return !own || own === acct;
|
||||||
|
})
|
||||||
|
: all,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast((e as Error).message || "加载失败", "err");
|
toast((e as Error).message || "加载失败", "err");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,19 +68,18 @@ export default function XPage() {
|
|||||||
|
|
||||||
const [username, setUsername] = useState("");
|
const [username, setUsername] = useState("");
|
||||||
|
|
||||||
// Persist selected account across reloads
|
// Persist selected account across reloads ("" = 全部账号)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
try {
|
try {
|
||||||
const saved = window.localStorage.getItem("x2_selected_account") || "";
|
const saved = window.localStorage.getItem("x2_selected_account");
|
||||||
if (saved) setUsername(saved);
|
if (saved !== null) setUsername(saved);
|
||||||
} catch {
|
} catch {
|
||||||
/* ignore */
|
/* ignore */
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
try {
|
try {
|
||||||
if (username) window.localStorage.setItem("x2_selected_account", username);
|
window.localStorage.setItem("x2_selected_account", username);
|
||||||
else window.localStorage.removeItem("x2_selected_account");
|
|
||||||
} catch {
|
} catch {
|
||||||
/* ignore */
|
/* ignore */
|
||||||
}
|
}
|
||||||
@ -111,12 +110,15 @@ export default function XPage() {
|
|||||||
setUsername((cur) => {
|
setUsername((cur) => {
|
||||||
if (cur && accs.some((a) => String(a.username || "") === cur)) return cur;
|
if (cur && accs.some((a) => String(a.username || "") === cur)) return cur;
|
||||||
try {
|
try {
|
||||||
const saved = window.localStorage.getItem("x2_selected_account") || "";
|
const saved = window.localStorage.getItem("x2_selected_account");
|
||||||
|
// Explicit empty string means「全部账号」
|
||||||
|
if (saved === "") return "";
|
||||||
if (saved && accs.some((a) => String(a.username || "") === saved)) return saved;
|
if (saved && accs.some((a) => String(a.username || "") === saved)) return saved;
|
||||||
} catch {
|
} catch {
|
||||||
/* ignore */
|
/* ignore */
|
||||||
}
|
}
|
||||||
return accs[0]?.username ? String(accs[0].username) : cur || "";
|
// Default: 全部账号 — never hide history by auto-picking first account
|
||||||
|
return cur || "";
|
||||||
});
|
});
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
toast.push((e as Error)?.message || "加载失败", "err");
|
toast.push((e as Error)?.message || "加载失败", "err");
|
||||||
|
|||||||
@ -114,7 +114,9 @@ export function jobAccountHandle(job: XJob): string {
|
|||||||
return fromResult.toLowerCase();
|
return fromResult.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Filter jobs by selected account. Empty selected = show all. */
|
/** Filter jobs by selected account. Empty selected = show all.
|
||||||
|
* Legacy jobs without account attribution stay visible (do not hide history).
|
||||||
|
*/
|
||||||
export function jobMatchesAccount(job: XJob, selectedUsername: string): boolean {
|
export function jobMatchesAccount(job: XJob, selectedUsername: string): boolean {
|
||||||
const sel = String(selectedUsername || "")
|
const sel = String(selectedUsername || "")
|
||||||
.trim()
|
.trim()
|
||||||
@ -122,8 +124,7 @@ export function jobMatchesAccount(job: XJob, selectedUsername: string): boolean
|
|||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
if (!sel) return true;
|
if (!sel) return true;
|
||||||
const own = jobAccountHandle(job);
|
const own = jobAccountHandle(job);
|
||||||
// Unattributed legacy jobs: hide when a specific account is selected
|
if (!own) return true;
|
||||||
if (!own) return false;
|
|
||||||
return own === sel;
|
return own === sel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user