From 782b0fc700842fa2877074839a8c5f7d8cff3163 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 9 Nov 2024 00:40:54 +0100 Subject: [PATCH] fix errors --- src/Components/Profile/ProfileView.tsx | 2 ++ src/Components/Profile/Subcomponents/SocialShareBar.tsx | 2 ++ src/Components/Profile/UserSettings.tsx | 4 +++- src/Components/Profile/itemFunctions.ts | 8 +++++--- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Components/Profile/ProfileView.tsx b/src/Components/Profile/ProfileView.tsx index a54ae222..ec98a677 100644 --- a/src/Components/Profile/ProfileView.tsx +++ b/src/Components/Profile/ProfileView.tsx @@ -63,7 +63,9 @@ export function ProfileView({ attestationApi }: { attestationApi?: ItemsApi console.log(value) setAttestations(value) + return null }) + // eslint-disable-next-line promise/prefer-await-to-callbacks .catch((error) => { console.error('Error fetching items:', error) }) diff --git a/src/Components/Profile/Subcomponents/SocialShareBar.tsx b/src/Components/Profile/Subcomponents/SocialShareBar.tsx index 13b94910..150fde40 100644 --- a/src/Components/Profile/Subcomponents/SocialShareBar.tsx +++ b/src/Components/Profile/Subcomponents/SocialShareBar.tsx @@ -16,7 +16,9 @@ const SocialShareBar = ({ .writeText(url) .then(() => { toast.success('link copied to clipboard') + return null }) + // eslint-disable-next-line promise/prefer-await-to-callbacks .catch((error: never) => { toast.error('Fehler beim Kopieren des Links: ', error) }) diff --git a/src/Components/Profile/UserSettings.tsx b/src/Components/Profile/UserSettings.tsx index 88d644e7..e98896cd 100644 --- a/src/Components/Profile/UserSettings.tsx +++ b/src/Components/Profile/UserSettings.tsx @@ -1,5 +1,4 @@ /* eslint-disable @typescript-eslint/no-unsafe-argument */ -/* eslint-disable @typescript-eslint/no-floating-promises */ /* eslint-disable @typescript-eslint/restrict-template-expressions */ import { useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom' @@ -43,6 +42,9 @@ export function UserSettings() { }, }) .then(() => navigate('/')) + .catch((e) => { + throw e + }) } return ( diff --git a/src/Components/Profile/itemFunctions.ts b/src/Components/Profile/itemFunctions.ts index 3ad3d1d5..d1f35043 100644 --- a/src/Components/Profile/itemFunctions.ts +++ b/src/Components/Profile/itemFunctions.ts @@ -9,6 +9,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ +import { setTimeout } from 'timers/promises' + import { toast } from 'react-toastify' import { Item } from '#src/types' @@ -16,8 +18,6 @@ import { encodeTag } from '#utils/FormatTags' import { hashTagRegex } from '#utils/HashTagRegex' import { randomColor } from '#utils/RandomColor' -const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) - export const submitNewItem = async ( evt: any, type: string, @@ -224,7 +224,7 @@ export const onUpdateItem = async ( }) // take care that addTag request comes before item request - await sleep(200) + await setTimeout(200) if (!item.new) { item?.layer?.api?.updateItem && @@ -243,6 +243,7 @@ export const onUpdateItem = async ( .then(() => { setLoading(false) navigate(`/item/${item.id}${params && '?' + params}`) + return null }) } else { item.new = false @@ -272,6 +273,7 @@ export const onUpdateItem = async ( .then(() => { setLoading(false) navigate(`/${params && '?' + params}`) + return null }) } }