This change modifies the validation/planning phase to skip the expensive thumbnail generation step in 'getUnifiedMediaState'. Since the planning phase primarily needs file IDs and names to calculate deletions, adoptions, and reorders, skipping the thumbnail verification/retrieval (including sidecar checks) significantly reduces the latency of the 'Save Changes' operation.
74 lines
1.8 KiB
TypeScript
74 lines
1.8 KiB
TypeScript
import { IShopifyMediaService } from "../interfaces/IShopifyMediaService"
|
|
|
|
export class MockShopifyMediaService implements IShopifyMediaService {
|
|
stagedUploadsCreate(input: any[]): any {
|
|
return {
|
|
stagedTargets: input.map(i => ({
|
|
url: "https://mock-upload.shopify.com",
|
|
resourceUrl: `https://mock-resource.shopify.com/${i.filename}`,
|
|
parameters: []
|
|
})),
|
|
userErrors: []
|
|
}
|
|
}
|
|
|
|
productCreateMedia(productId: string, media: any[]): any {
|
|
return {
|
|
media: media.map(m => ({
|
|
id: `gid://shopify/Media/${Math.random()}`,
|
|
alt: m.alt,
|
|
mediaContentType: m.mediaContentType,
|
|
status: "PROCESSING"
|
|
})),
|
|
mediaUserErrors: [],
|
|
product: {
|
|
id: productId,
|
|
title: "Mock Product"
|
|
}
|
|
}
|
|
}
|
|
|
|
getProductMedia(productId: string): any[] {
|
|
// Return empty or mock list
|
|
return []
|
|
}
|
|
|
|
getProduct(productId: string): any {
|
|
return {
|
|
id: productId,
|
|
title: "Mock Product",
|
|
handle: "mock-product",
|
|
onlineStoreUrl: "https://mock-shop.myshopify.com/products/mock-product"
|
|
}
|
|
}
|
|
|
|
getProductWithMedia(productId: string): any {
|
|
return {
|
|
product: this.getProduct(productId),
|
|
media: this.getProductMedia(productId)
|
|
};
|
|
}
|
|
|
|
productDeleteMedia(productId: string, mediaId: string): any {
|
|
return {
|
|
productDeleteMedia: {
|
|
deletedMediaId: mediaId,
|
|
userErrors: []
|
|
}
|
|
}
|
|
}
|
|
|
|
productReorderMedia(productId: string, moves: any[]): any {
|
|
return {
|
|
productReorderMedia: {
|
|
job: { id: "job_123" },
|
|
userErrors: []
|
|
}
|
|
}
|
|
}
|
|
|
|
getShopDomain(): string {
|
|
return 'mock-shop.myshopify.com';
|
|
}
|
|
}
|