Skip to content

Commit

Permalink
fix: manage empty blob
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin-Guillemin committed Jan 8, 2024
1 parent 7859cef commit f53feb5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VITE_BASE_URI="/"
VITE_PERSISTANCE_API_URL="/"
VITE_USER_INFO_API_URI="/portail/api/v5-1/userinfo?claims=private&groups="
VITE_AXIOS_TIMEOUT="10000"
VITE_AXIOS_TIMEOUT="10000"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ document.body.appendChild(tldrawEditor);
| `persistance-api-url` | `string` | `true` | | URL du fichier (GET & PUT) |
| `user-info-api-url` | `string` | `true` | | URL des informations utilisateurs |

<br/>

```html
<tldraw-editor persistance-api-url="" user-info-api-url="" />
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gip-recia/tldraw-webcomponent",
"version": "1.0.0",
"version": "1.1.2",
"type": "module",
"files": [
"dist"
Expand Down
6 changes: 4 additions & 2 deletions src/hooks/usePersistance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ export function usePersistance(persistanceApiUrl: string) {
const loadDocument = useCallback(
async (app: TldrawApp): Promise<void> => {
const response = await getFile(persistanceApiUrl);
app.loadDocument(JSON.parse(response.data.blob).document as TDDocument);
app.document.name = response.data.title;
if (response.data.blob != '') {
app.loadDocument(JSON.parse(response.data.blob).document as TDDocument);
app.document.name = response.data.title;
}
},
[persistanceApiUrl],
);
Expand Down

0 comments on commit f53feb5

Please sign in to comment.