fix: retain uncertain optimistic mutations
This commit is contained in:
@@ -87,6 +87,9 @@ export type AsyncSurfaceProps = Readonly<{
|
||||
onAction?: () => void;
|
||||
onRetry?: () => void;
|
||||
onResolveConflict?: () => void;
|
||||
onReconcileUnknownEffect?: (
|
||||
resolution: "APPLIED" | "NOT_APPLIED",
|
||||
) => void;
|
||||
}>;
|
||||
|
||||
export function AsyncSurface({
|
||||
@@ -95,6 +98,7 @@ export function AsyncSurface({
|
||||
onAction,
|
||||
onRetry,
|
||||
onResolveConflict,
|
||||
onReconcileUnknownEffect,
|
||||
}: AsyncSurfaceProps) {
|
||||
const { message } = useLocale();
|
||||
if (state.base === "initial-loading") return <LoadingSurface />;
|
||||
@@ -121,11 +125,13 @@ export function AsyncSurface({
|
||||
{message(
|
||||
state.indicator === "stale-degraded"
|
||||
? "async.staleDegraded"
|
||||
: state.indicator === "mutation-conflict"
|
||||
? "async.mutationConflict"
|
||||
: state.indicator === "mutation-pending"
|
||||
? "async.mutationPending"
|
||||
: "async.refreshing",
|
||||
: state.indicator === "mutation-effect-unknown"
|
||||
? "async.mutationEffectUnknown"
|
||||
: state.indicator === "mutation-conflict"
|
||||
? "async.mutationConflict"
|
||||
: state.indicator === "mutation-pending"
|
||||
? "async.mutationPending"
|
||||
: "async.refreshing",
|
||||
)}
|
||||
</span>
|
||||
{state.indicator === "stale-degraded" && onRetry ? (
|
||||
@@ -136,6 +142,21 @@ export function AsyncSurface({
|
||||
{message("action.resolveConflict")}
|
||||
</Button>
|
||||
) : null}
|
||||
{state.indicator === "mutation-effect-unknown" &&
|
||||
onReconcileUnknownEffect ? (
|
||||
<>
|
||||
<Button
|
||||
onClick={() => onReconcileUnknownEffect("APPLIED")}
|
||||
>
|
||||
{message("action.confirmMutationApplied")}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => onReconcileUnknownEffect("NOT_APPLIED")}
|
||||
>
|
||||
{message("action.confirmMutationNotApplied")}
|
||||
</Button>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
{children}
|
||||
|
||||
Reference in New Issue
Block a user