Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions apps/cursor/src/actions/delete-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,26 @@ export const deletePluginAction = authActionClient
);
}

const { error } = await supabase
const { data: deleted, error } = await supabase
.from("plugins")
.delete()
.eq("id", id)
.eq("owner_id", userId);
.eq("owner_id", userId)
.select("id");

if (error) {
throw new ActionError(`Failed to delete plugin: ${error.message}`);
}

// A delete that matches no rows is not an error for PostgREST, so without
// this check a row the policy refuses to delete would still produce the
// "Plugin deleted." toast while staying live and keeping its slug.
if (!deleted || deleted.length === 0) {
throw new ActionError(
"The plugin could not be deleted. It is still listed; contact support to have it removed.",
);
}

// Deletions must disappear from cached lists immediately for the owner.
updateTag("plugins");
updateTag(`plugin-${existing.slug}`);
Expand Down