diff --git a/src/components/item/CreateShortcutModal.vue b/src/components/item/CreateShortcutModal.vue
index f55fd58..776cae6 100644
--- a/src/components/item/CreateShortcutModal.vue
+++ b/src/components/item/CreateShortcutModal.vue
@@ -48,6 +48,31 @@
+
+
+
,
@@ -167,6 +194,8 @@ const parentFolder = ref<{ id: number | null; name: string; parentId: number | n
setFolders(HOME_FOLDER_PARENT_ID);
async function setFolders(folderId: number | null) {
+ hasLoadedFolders.value = false;
+
if (folderId === HOME_FOLDER_PARENT_ID) {
parentFolder.value = null;
folders.value = [];
@@ -200,10 +229,8 @@ async function getFolders() {
return;
}
- console.log(parentFolder.value);
-
- const response = await fetch(
- api(`item/${parentFolder.value.id ? `${parentFolder.value.id}` : ''}`),
+ const response = await fetchFromApi(
+ `item/${parentFolder.value.id ? `${parentFolder.value.id}` : ''}`,
{
method: 'GET',
headers: {
@@ -232,8 +259,16 @@ async function getFolders() {
if (!FolderClass.isFolder(item)) continue;
+ if (item.parentId !== parentFolder.value.id) {
+ throw new Error(
+ "Invalid parent id, user must've changed the parent folder before the request finished",
+ );
+ }
+
folders.value.push(item);
}
+
+ hasLoadedFolders.value = true;
} catch (e) {
console.error('Error' + e);
}
diff --git a/src/lib/items/docs.ts b/src/lib/items/docs.ts
index 3bce554..5e9dc59 100644
--- a/src/lib/items/docs.ts
+++ b/src/lib/items/docs.ts
@@ -1,6 +1,6 @@
import { ItemClass, type ItemType } from './items';
import { type FolderType } from './folders';
-import { api, fetchFromApi } from '@lib/helpers';
+import { fetchFromApi } from '@lib/helpers';
export class DocsClass extends ItemClass {
private _text: string;
diff --git a/src/lib/items/shortcuts.ts b/src/lib/items/shortcuts.ts
index edef778..3c3f21a 100644
--- a/src/lib/items/shortcuts.ts
+++ b/src/lib/items/shortcuts.ts
@@ -1,4 +1,4 @@
-import { api, fetchFromApi } from '@lib/helpers';
+import { fetchFromApi } from '@lib/helpers';
import { ItemClass, type ItemType } from './items';
import { FolderClass } from './folders';
import { FileClass } from './files';
@@ -15,7 +15,7 @@ export class ShortcutClass extends ItemClass {
}
async setLinkedItem(linkedItemId: number) {
- const response = await fetch(api('item/' + linkedItemId + '/single'), {
+ const response = await fetchFromApi('item/' + linkedItemId + '/single', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
@@ -41,7 +41,7 @@ export class ShortcutClass extends ItemClass {
}
static async create(input: { name: string; parentId: number | null; linkedItemId: number }) {
- const response = await fetch(api('shortcut'), {
+ const response = await fetchFromApi('shortcut', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -94,7 +94,7 @@ export class ShortcutClass extends ItemClass {
}
async delete() {
- const response = await fetch(api('shortcut/' + this.id), {
+ const response = await fetchFromApi('shortcut/' + this.id, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',