fix(private-zone): hide incomplete albums and refresh Maya cover
This commit is contained in:
@@ -257,14 +257,6 @@ export function PrivateZoneScreen() {
|
||||
<StatusCard message="Loading private albums..." />
|
||||
) : null}
|
||||
|
||||
{!state.isLoading && state.items.length === 0 && !state.errorMessage ? (
|
||||
<StatusCard
|
||||
message="No private albums yet."
|
||||
actionLabel="Refresh"
|
||||
onAction={() => dispatch({ type: "PrivateZoneRefresh" })}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<div className={styles.timeline}>
|
||||
{state.items.map((album, index) => (
|
||||
<PrivateAlbumCard
|
||||
|
||||
@@ -67,6 +67,20 @@ describe("Private Album schema models", () => {
|
||||
expect(response).not.toHaveProperty("packageOptions");
|
||||
});
|
||||
|
||||
it("keeps incomplete-content metadata without exposing pending images", () => {
|
||||
const response = PrivateAlbumsResponseSchema.parse({
|
||||
items: [],
|
||||
creditBalance: 100,
|
||||
pendingImageCount: 7,
|
||||
hasIncompleteContent: true,
|
||||
pendingImages: [{ url: COVER_URL }],
|
||||
});
|
||||
|
||||
expect(response.pendingImageCount).toBe(7);
|
||||
expect(response.hasIncompleteContent).toBe(true);
|
||||
expect(response).not.toHaveProperty("pendingImages");
|
||||
});
|
||||
|
||||
it("parses an unlock response with all album images", () => {
|
||||
const response = PrivateAlbumUnlockResponseSchema.parse({
|
||||
albumId: ALBUM_ID,
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { arrayOrEmpty, numberOrZero } from "../../nullable-defaults";
|
||||
import {
|
||||
arrayOrEmpty,
|
||||
booleanOrFalse,
|
||||
numberOrZero,
|
||||
} from "../../nullable-defaults";
|
||||
import { PrivateAlbumSchema } from "../private_album";
|
||||
|
||||
export const PrivateAlbumsResponseSchema = z
|
||||
.object({
|
||||
items: arrayOrEmpty(PrivateAlbumSchema),
|
||||
creditBalance: numberOrZero,
|
||||
pendingImageCount: numberOrZero,
|
||||
hasIncompleteContent: booleanOrFalse,
|
||||
})
|
||||
.readonly();
|
||||
|
||||
|
||||
@@ -41,6 +41,21 @@ describe("private zone album flow", () => {
|
||||
actor.stop();
|
||||
});
|
||||
|
||||
it("keeps incomplete album metadata without creating a visible album", async () => {
|
||||
const actor = await loadPrivateZone({
|
||||
loadResponse: makeAlbumsResponse({
|
||||
items: [],
|
||||
pendingImageCount: 7,
|
||||
hasIncompleteContent: true,
|
||||
}),
|
||||
});
|
||||
|
||||
expect(actor.getSnapshot().context.items).toEqual([]);
|
||||
expect(actor.getSnapshot().context.pendingImageCount).toBe(7);
|
||||
expect(actor.getSnapshot().context.hasIncompleteContent).toBe(true);
|
||||
actor.stop();
|
||||
});
|
||||
|
||||
it("moves to failed when the album actor rejects", async () => {
|
||||
const actor = createActor(
|
||||
createTestPrivateZoneMachine({
|
||||
|
||||
@@ -15,6 +15,8 @@ export function applyAlbumsResponse(
|
||||
return {
|
||||
items: response.items,
|
||||
creditBalance: response.creditBalance,
|
||||
pendingImageCount: response.pendingImageCount,
|
||||
hasIncompleteContent: response.hasIncompleteContent,
|
||||
errorMessage: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ export interface PrivateZoneContextState {
|
||||
status: string;
|
||||
items: MachineContext["items"];
|
||||
creditBalance: number;
|
||||
pendingImageCount: number;
|
||||
hasIncompleteContent: boolean;
|
||||
errorMessage: string | null;
|
||||
unlockingAlbumId: string | null;
|
||||
unlockErrorMessage: string | null;
|
||||
@@ -70,6 +72,8 @@ function selectPrivateZoneState(
|
||||
status: String(state.value),
|
||||
items: state.context.items,
|
||||
creditBalance: state.context.creditBalance,
|
||||
pendingImageCount: state.context.pendingImageCount,
|
||||
hasIncompleteContent: state.context.hasIncompleteContent,
|
||||
errorMessage: state.context.errorMessage,
|
||||
unlockingAlbumId: state.context.unlockingAlbumId,
|
||||
unlockErrorMessage: state.context.unlockErrorMessage,
|
||||
|
||||
@@ -13,6 +13,8 @@ export interface PrivateZoneState {
|
||||
characterId: string;
|
||||
items: readonly PrivateAlbum[];
|
||||
creditBalance: number;
|
||||
pendingImageCount: number;
|
||||
hasIncompleteContent: boolean;
|
||||
errorMessage: string | null;
|
||||
unlockingAlbumId: string | null;
|
||||
unlockErrorMessage: string | null;
|
||||
@@ -28,6 +30,8 @@ export function createInitialPrivateZoneState(
|
||||
characterId,
|
||||
items: [],
|
||||
creditBalance: 0,
|
||||
pendingImageCount: 0,
|
||||
hasIncompleteContent: false,
|
||||
errorMessage: null,
|
||||
unlockingAlbumId: null,
|
||||
unlockErrorMessage: null,
|
||||
|
||||
Reference in New Issue
Block a user