feat(shows): redesign archive functionality and update delete show references
This commit is contained in:
parent
33ccef5142
commit
c4ac2ed128
@ -7,5 +7,6 @@ export const API_ENDPOINT = {
|
|||||||
TIME: buildApiUrl("/v1/time"),
|
TIME: buildApiUrl("/v1/time"),
|
||||||
DANIME: buildApiUrl("/v1/danime"),
|
DANIME: buildApiUrl("/v1/danime"),
|
||||||
OAUTH_FIREBASE: buildApiUrl("/v1/oauth/firebase"),
|
OAUTH_FIREBASE: buildApiUrl("/v1/oauth/firebase"),
|
||||||
|
ARCHIVE: buildApiUrl("/v1/archive"),
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
@ -35,3 +35,12 @@ export type FirebaseAuthResponse = {
|
|||||||
issuer?: string;
|
issuer?: string;
|
||||||
expires?: number;
|
expires?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ArchiveResult = {
|
||||||
|
moved_ids: number[];
|
||||||
|
deleted_ids: number[];
|
||||||
|
skipped_ids: number[];
|
||||||
|
inserted: number;
|
||||||
|
deleted: number;
|
||||||
|
skipped: number;
|
||||||
|
};
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { API_ENDPOINT } from "./endpoint";
|
import { API_ENDPOINT } from "./endpoint";
|
||||||
import { ApiError, apiFetch } from "./client";
|
import { ApiError, apiFetch } from "./client";
|
||||||
import type { DanimeEpisode, ScheduleResponse, ShowItem, TimeResponse } from "./types";
|
import type { ArchiveResult, DanimeEpisode, ScheduleResponse, ShowItem, TimeResponse } from "./types";
|
||||||
|
|
||||||
export type { DanimeEpisode, ScheduleResponse, ShowItem, TimeResponse } from "./types";
|
export type { DanimeEpisode, ScheduleResponse, ShowItem, TimeResponse } from "./types";
|
||||||
|
|
||||||
@ -137,18 +137,19 @@ export async function createShow(payload: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteShow(id: number, idToken: string) {
|
export async function archiveShow(id: number, idToken: string) {
|
||||||
if (!idToken) {
|
if (!idToken) {
|
||||||
throw new ApiError("Missing auth token for delete");
|
throw new ApiError("Missing auth token for archive");
|
||||||
}
|
}
|
||||||
const url = `${API_ENDPOINT.v1.SHOWS}?id=${encodeURIComponent(id)}`;
|
await apiFetch<ArchiveResult>(API_ENDPOINT.v1.ARCHIVE, {
|
||||||
await apiFetch<void>(url, {
|
method: "POST",
|
||||||
method: "DELETE",
|
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": `Bearer ${idToken}`,
|
"Authorization": `Bearer ${idToken}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
|
body: JSON.stringify({ ids: [id] }),
|
||||||
timeoutMs: 10_000,
|
timeoutMs: 10_000,
|
||||||
expect: "void",
|
expect: "json",
|
||||||
logLabel: "delete show",
|
logLabel: "archive show",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState, useRef } from "react";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { logApiError } from "../utils/logger";
|
import { logApiError } from "../utils/logger";
|
||||||
import { toastError, toastInfo } from "../utils/toastBus";
|
import { toastError, toastInfo } from "../utils/toastBus";
|
||||||
import { createShow, deleteShow, fetchDanimeEpisode, fetchShows, postCurrentEpisode } from "../api/watchparty";
|
import { archiveShow, createShow, fetchDanimeEpisode, fetchShows, postCurrentEpisode } from "../api/watchparty";
|
||||||
import type { DanimeEpisode, ShowItem } from "../api/watchparty";
|
import type { DanimeEpisode, ShowItem } from "../api/watchparty";
|
||||||
import { useAuth } from "../auth/AuthProvider";
|
import { useAuth } from "../auth/AuthProvider";
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ export default function ShowsPage() {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
setDeletingId(showId);
|
setDeletingId(showId);
|
||||||
await deleteShow(showId, idToken);
|
await archiveShow(showId, idToken);
|
||||||
toastInfo("エピソードを削除しました");
|
toastInfo("エピソードを削除しました");
|
||||||
if (selectedId === showId) {
|
if (selectedId === showId) {
|
||||||
setSelectedId(null);
|
setSelectedId(null);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user