Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 14 additions & 4 deletions src/components/members/invite-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ export function InviteForm({
return;
}

// Check for existing pending invite
// Remove any existing pending invite so re-inviting is idempotent.
// This covers the case where a previous revoke failed silently (e.g.
// RLS-blocked deletes return success with 0 rows) or the user simply
// wants to refresh the invite expiry.
const { data: existingInvite } = await supabase
.from("workspace_invites")
.select("id")
Expand All @@ -75,9 +78,16 @@ export function InviteForm({
.maybeSingle();

if (existingInvite) {
onError("An invite has already been sent to this email.");
setSending(false);
return;
const { error: deleteError } = await supabase
.from("workspace_invites")
.delete()
.eq("id", existingInvite.id);

if (deleteError) {
onError("Failed to replace existing invite. Try revoking it first.");
setSending(false);
return;
}
}

// Generate token and expiry
Expand Down
7 changes: 6 additions & 1 deletion src/components/sidebar/page-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function PageSearch() {
const [selectedIndex, setSelectedIndex] = useState(0);
const [workspaceId, setWorkspaceId] = useState<string | null>(null);
const [workspaceResolved, setWorkspaceResolved] = useState(false);
const [searched, setSearched] = useState(false);
const containerRef = useRef<HTMLDivElement>(null);
const inputRef = useRef<HTMLInputElement>(null);
const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);
Expand Down Expand Up @@ -88,6 +89,7 @@ export function PageSearch() {
setResults([]);
} finally {
setLoading(false);
setSearched(true);
}
},
[workspaceId]
Expand All @@ -106,6 +108,7 @@ export function PageSearch() {
if (!query.trim()) {
setResults([]);
setLoading(false);
setSearched(false);
return;
}

Expand Down Expand Up @@ -147,6 +150,7 @@ export function PageSearch() {
setOpen(false);
setQuery("");
setResults([]);
setSearched(false);
}

function handleKeyDown(e: React.KeyboardEvent) {
Expand Down Expand Up @@ -182,6 +186,7 @@ export function PageSearch() {
function handleClear() {
setQuery("");
setResults([]);
setSearched(false);
setOpen(false);
inputRef.current?.focus();
}
Expand Down Expand Up @@ -282,7 +287,7 @@ export function PageSearch() {
</div>
)}

{!loading && workspaceResolved && results.length === 0 && query.trim().length > 0 && (
{!loading && searched && results.length === 0 && query.trim().length > 0 && (
<div className="px-3 py-4 text-center text-xs text-muted-foreground">
No pages match your search
</div>
Expand Down
Loading