chore: remove save status indicator
This commit is contained in:
+2
-13
@@ -12,8 +12,6 @@ import type {
|
|||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { DEFAULT_TITLE, type DrawingMeta, type ScenePayload } from "./shared";
|
import { DEFAULT_TITLE, type DrawingMeta, type ScenePayload } from "./shared";
|
||||||
|
|
||||||
type SaveStatus = "saved" | "saving" | "failed";
|
|
||||||
|
|
||||||
type DrawingResponse = DrawingMeta & ScenePayload;
|
type DrawingResponse = DrawingMeta & ScenePayload;
|
||||||
|
|
||||||
function pathToId(pathname = window.location.pathname): string | null {
|
function pathToId(pathname = window.location.pathname): string | null {
|
||||||
@@ -95,7 +93,6 @@ export function App() {
|
|||||||
const [activeTitle, setActiveTitle] = useState(DEFAULT_TITLE);
|
const [activeTitle, setActiveTitle] = useState(DEFAULT_TITLE);
|
||||||
const [scene, setScene] = useState<ScenePayload | null>(null);
|
const [scene, setScene] = useState<ScenePayload | null>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [saveStatus, setSaveStatus] = useState<SaveStatus>("saved");
|
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
const currentIdRef = useRef<string | null>(activeId);
|
const currentIdRef = useRef<string | null>(activeId);
|
||||||
@@ -123,8 +120,6 @@ export function App() {
|
|||||||
if (!drawingId || !nextScene) {
|
if (!drawingId || !nextScene) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSaveStatus("saving");
|
|
||||||
setError(null);
|
setError(null);
|
||||||
|
|
||||||
const promise = requestJson<{ ok: true; drawing: DrawingMeta }>(`/api/drawings/${drawingId}`, {
|
const promise = requestJson<{ ok: true; drawing: DrawingMeta }>(`/api/drawings/${drawingId}`, {
|
||||||
@@ -133,10 +128,8 @@ export function App() {
|
|||||||
})
|
})
|
||||||
.then((body) => {
|
.then((body) => {
|
||||||
setDrawings((current) => replaceMeta(current, body.drawing));
|
setDrawings((current) => replaceMeta(current, body.drawing));
|
||||||
setSaveStatus("saved");
|
|
||||||
})
|
})
|
||||||
.catch((saveError: unknown) => {
|
.catch((saveError: unknown) => {
|
||||||
setSaveStatus("failed");
|
|
||||||
setError(saveError instanceof Error ? saveError.message : "Save failed");
|
setError(saveError instanceof Error ? saveError.message : "Save failed");
|
||||||
throw saveError;
|
throw saveError;
|
||||||
})
|
})
|
||||||
@@ -166,7 +159,6 @@ export function App() {
|
|||||||
clearTimeout(timeoutRef.current);
|
clearTimeout(timeoutRef.current);
|
||||||
}
|
}
|
||||||
|
|
||||||
setSaveStatus("saving");
|
|
||||||
timeoutRef.current = window.setTimeout(() => {
|
timeoutRef.current = window.setTimeout(() => {
|
||||||
timeoutRef.current = null;
|
timeoutRef.current = null;
|
||||||
void saveScene();
|
void saveScene();
|
||||||
@@ -204,7 +196,6 @@ export function App() {
|
|||||||
setActiveId(drawing.id);
|
setActiveId(drawing.id);
|
||||||
setActiveTitle(drawing.title);
|
setActiveTitle(drawing.title);
|
||||||
setScene(nextScene);
|
setScene(nextScene);
|
||||||
setSaveStatus("saved");
|
|
||||||
} catch (loadError) {
|
} catch (loadError) {
|
||||||
const list = await refreshList();
|
const list = await refreshList();
|
||||||
if (list.length === 0) {
|
if (list.length === 0) {
|
||||||
@@ -435,9 +426,6 @@ export function App() {
|
|||||||
|
|
||||||
<main className="editor-shell">
|
<main className="editor-shell">
|
||||||
<div className="toolbar">
|
<div className="toolbar">
|
||||||
<span className={`status-badge status-${saveStatus}`}>
|
|
||||||
{saveStatus === "saving" ? "Saving..." : saveStatus === "failed" ? "Save failed" : "Saved"}
|
|
||||||
</span>
|
|
||||||
<button type="button" className="secondary-button" onClick={() => void exportPng()} disabled={!scene}>
|
<button type="button" className="secondary-button" onClick={() => void exportPng()} disabled={!scene}>
|
||||||
Export PNG
|
Export PNG
|
||||||
</button>
|
</button>
|
||||||
@@ -459,7 +447,8 @@ export function App() {
|
|||||||
key={activeDrawing?.id ?? activeId}
|
key={activeDrawing?.id ?? activeId}
|
||||||
initialData={sceneToInitialData(scene)}
|
initialData={sceneToInitialData(scene)}
|
||||||
onChange={(elements, appState, files) => {
|
onChange={(elements, appState, files) => {
|
||||||
latestSceneRef.current = sceneFromEditor(elements, appState, files);
|
const nextScene = sceneFromEditor(elements, appState, files);
|
||||||
|
latestSceneRef.current = nextScene;
|
||||||
|
|
||||||
if (ignoreChangeRef.current) {
|
if (ignoreChangeRef.current) {
|
||||||
ignoreChangeRef.current = false;
|
ignoreChangeRef.current = false;
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ input {
|
|||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-badge,
|
|
||||||
.primary-button,
|
.primary-button,
|
||||||
.secondary-button,
|
.secondary-button,
|
||||||
.icon-button {
|
.icon-button {
|
||||||
@@ -127,23 +126,6 @@ input {
|
|||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-badge {
|
|
||||||
padding: 8px 10px;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-saving {
|
|
||||||
color: #1d4ed8;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-failed {
|
|
||||||
color: #b91c1c;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-saved {
|
|
||||||
color: #166534;
|
|
||||||
}
|
|
||||||
|
|
||||||
.primary-button,
|
.primary-button,
|
||||||
.secondary-button {
|
.secondary-button {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|||||||
Reference in New Issue
Block a user