Skip to content
Open
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
22 changes: 17 additions & 5 deletions client/src/lib/Dashboard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@
console.error("Failed to load club data:", err);
}
}
async function openSpace(space) {
await fetch(`${API_BASE}/spaces/${space.id}/open`, {
method: "POST",
credentials: "include",
});

space.last_opened_at = new Date().toISOString();

window.open(space.access_url, "_blank");
}

window.open(space.access_url, '_blank');
}

async function loadSpaceShareStatuses() {
for (const space of spaces) {
Expand Down Expand Up @@ -722,14 +735,13 @@ $: filteredSpaces = sortedSpaces.filter(space => {
{:else}
{#if space.running || space.status?.toLowerCase() === "running"}
{#if space.access_url}
<a
href={space.access_url}
target="_blank"
rel="noopener noreferrer"
<button
type="button"
class="action-btn open"
on:click={() => openSpace(space)}
>
Open
</a>
</button>

<button
type="button"
Expand Down
10 changes: 10 additions & 0 deletions src/api/spaces/space.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,17 @@ router.post("/:spaceId/favorite", async (req, res) => {
res.status(500).json({ error: err.message });
}
});
router.post('/:spaceId/open', async (req, res) => {
const { spaceId } = req.params;

await pg('spaces')
.where('id', spaceId)
.update({
last_opened_at: new Date()
});

res.json({ success: true });
});
router.post("/:spaceId/share/club", spaceShareLimiter, async (req, res) => {
const { spaceId } = req.params;
const { share } = req.body;
Expand Down