feat: don't unnecessarily prompt when installing libraries (#3329)

This commit is contained in:
David Luzar 2021-03-26 18:32:38 +01:00 committed by GitHub
parent cf9e29834d
commit 30ae4b8bf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 7 deletions

View file

@ -609,7 +609,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
this.onSceneUpdated();
};
private importLibraryFromUrl = async (url: string) => {
private importLibraryFromUrl = async (url: string, token?: string | null) => {
if (window.location.hash.includes(URL_HASH_KEYS.addLibrary)) {
const hash = new URLSearchParams(window.location.hash.slice(1));
hash.delete(URL_HASH_KEYS.addLibrary);
@ -628,6 +628,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
throw new Error();
}
if (
token === Library.csrfToken ||
window.confirm(
t("alerts.confirmAddLibrary", { numShapes: json.library.length }),
)

View file

@ -179,7 +179,7 @@ const LibraryMenuItems = ({
<a
href={`https://libraries.excalidraw.com?target=${
window.name || "_blank"
}&referrer=${referrer}&useHash=true`}
}&referrer=${referrer}&useHash=true&token=${Library.csrfToken}`}
target="_excalidraw_libraries"
>
{t("labels.libraries")}