feat(ios): mark shares processed after successful import
Call SharedImage.markProcessed(shareId) from the share import workflow once a shared image has been successfully stored in the temp DB. The call is gated to iOS and a non-empty shareId, and a mark-processed failure is logged as a warning without failing the already-successful import. Add explicit logging for processing started/succeeded/failed and markProcessed invoked. On a storage failure the share is left intact and not marked processed, so it remains available for retry. Android is unchanged.
This commit is contained in:
@@ -169,12 +169,45 @@ async function checkAndStoreNativeSharedImage(): Promise<{
|
|||||||
// Check if we have valid image data (base64 must be non-null and non-empty)
|
// Check if we have valid image data (base64 must be non-null and non-empty)
|
||||||
if (result && result.base64 && result.base64.trim().length > 0) {
|
if (result && result.base64 && result.base64.trim().length > 0) {
|
||||||
const fileName = result.fileName || "shared-image.jpg";
|
const fileName = result.fileName || "shared-image.jpg";
|
||||||
|
const shareId = result.shareId;
|
||||||
|
const shareIdLog = shareId || "unknown";
|
||||||
|
|
||||||
// Store in temp database using extracted method
|
// Hand off to the app: store in temp database using extracted method
|
||||||
logger.info(
|
logger.info(
|
||||||
"[Main] Native shared image found (via plugin), storing in temp DB",
|
`[Main] Shared image processing started shareId=${shareIdLog} fileName=${fileName}`,
|
||||||
);
|
);
|
||||||
await storeSharedImageInTempDB(result.base64, fileName);
|
|
||||||
|
try {
|
||||||
|
await storeSharedImageInTempDB(result.base64, fileName);
|
||||||
|
} catch (storeError) {
|
||||||
|
// Processing failed - leave the shared item intact (do NOT mark processed)
|
||||||
|
logger.error(
|
||||||
|
`[Main] Shared image processing failed shareId=${shareIdLog}:`,
|
||||||
|
storeError,
|
||||||
|
);
|
||||||
|
isProcessingSharedImage = false;
|
||||||
|
return { success: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
`[Main] Shared image processing succeeded shareId=${shareIdLog} fileName=${fileName}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Signal explicit completion only after successful processing.
|
||||||
|
// iOS-only: the markProcessed API is not implemented on Android.
|
||||||
|
if (shareId && Capacitor.getPlatform() === "ios") {
|
||||||
|
try {
|
||||||
|
logger.info(`[Main] markProcessed invoked shareId=${shareId}`);
|
||||||
|
await SharedImage.markProcessed({ shareId });
|
||||||
|
} catch (markError) {
|
||||||
|
// A failure to mark processed must not fail the (already successful)
|
||||||
|
// share processing; the share simply remains available for retry.
|
||||||
|
logger.warn(
|
||||||
|
`[Main] markProcessed failed shareId=${shareId}:`,
|
||||||
|
markError,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
isProcessingSharedImage = false;
|
isProcessingSharedImage = false;
|
||||||
return { success: true, fileName };
|
return { success: true, fileName };
|
||||||
|
|||||||
Reference in New Issue
Block a user