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
4 changes: 2 additions & 2 deletions src/frontend/src/api/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ export const api = {

getDefaultCanvas: async (): Promise<CanvasData> => {
try {
const result = await fetchApi('/api/pad/from-template/default');
return result;
const result = await fetchApi('/api/templates/default');
return result.data;
} catch (error) {
throw error;
}
Expand Down
16 changes: 5 additions & 11 deletions src/frontend/src/ui/SettingsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { UserSettings, DEFAULT_SETTINGS } from "../types/settings";
import { RefreshCw } from "lucide-react";
import { normalizeCanvasData } from "../utils/canvasUtils";
import { capture } from "../utils/posthog";
import { api } from "../api/hooks";
import "./SettingsDialog.scss";

interface SettingsDialogProps {
Expand Down Expand Up @@ -47,25 +48,18 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
setIsRestoring(true);
capture('restore_tutorial_canvas_clicked');

// Fetch the default canvas data from the backend
const response = await fetch('/api/canvas/default', {
method: 'GET',
credentials: 'include'
});

if (!response.ok) {
throw new Error(`Failed to fetch default canvas: ${response.statusText}`);
}
// Use the API function from hooks.ts to fetch the default canvas
const defaultCanvasData = await api.getDefaultCanvas();

const defaultCanvasData = await response.json();
console.debug("Default canvas data:", defaultCanvasData);

// Normalize the canvas data before updating the scene
const normalizedData = normalizeCanvasData(defaultCanvasData);

// Update the canvas with the normalized default data
excalidrawAPI.updateScene(normalizedData);

console.log("Canvas reset to default successfully");
console.debug("Canvas reset to default successfully");

// Close the dialog after successful restore
handleClose();
Expand Down