mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-08-29 10:43:56 +00:00
show loading version progress
This commit is contained in:
@@ -56,6 +56,7 @@ export default function Versions({ open, title, setTitle }) {
|
|||||||
const [hasMore, setHasMore] = useState(false);
|
const [hasMore, setHasMore] = useState(false);
|
||||||
const [cursor, setCursor] = useState(null);
|
const [cursor, setCursor] = useState(null);
|
||||||
const [isRecording, setIsRecording] = useState(false);
|
const [isRecording, setIsRecording] = useState(false);
|
||||||
|
const [loadingVersion, setLoadingVersion] = useState(null);
|
||||||
|
|
||||||
const cacheRef = useMemo(() => loadCache(), []);
|
const cacheRef = useMemo(() => loadCache(), []);
|
||||||
|
|
||||||
@@ -91,6 +92,7 @@ export default function Versions({ open, title, setTitle }) {
|
|||||||
const loadVersion = useCallback(
|
const loadVersion = useCallback(
|
||||||
async (sha) => {
|
async (sha) => {
|
||||||
try {
|
try {
|
||||||
|
setLoadingVersion(sha);
|
||||||
const version = await getVersion(gistId, sha);
|
const version = await getVersion(gistId, sha);
|
||||||
setVersion(sha);
|
setVersion(sha);
|
||||||
setLayout((prev) => ({ ...prev, readOnly: true }));
|
setLayout((prev) => ({ ...prev, readOnly: true }));
|
||||||
@@ -117,6 +119,8 @@ export default function Versions({ open, title, setTitle }) {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Toast.error(t("failed_to_load_diagram"));
|
Toast.error(t("failed_to_load_diagram"));
|
||||||
|
} finally {
|
||||||
|
setLoadingVersion(null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
@@ -288,7 +292,13 @@ export default function Versions({ open, title, setTitle }) {
|
|||||||
)
|
)
|
||||||
.setLocale(i18n.language)
|
.setLocale(i18n.language)
|
||||||
.toLocaleString(DateTime.DATETIME_MED)}`}
|
.toLocaleString(DateTime.DATETIME_MED)}`}
|
||||||
icon={<i className="text-sm fa-solid fa-asterisk" />}
|
icon={
|
||||||
|
r.version === loadingVersion ? (
|
||||||
|
<Spin size="small" />
|
||||||
|
) : (
|
||||||
|
<i className="text-sm fa-solid fa-asterisk ms-1" />
|
||||||
|
)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Steps>
|
</Steps>
|
||||||
|
Reference in New Issue
Block a user