From b4b8e8b4b6c8762f3ff61e32606da391b3dc59fa Mon Sep 17 00:00:00 2001 From: Guillermo Gallardo Date: Mon, 2 Dec 2024 16:36:39 +0100 Subject: [PATCH] fix: add delay before showing greeting --- frontend/src/pages/hello-near/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/hello-near/index.js b/frontend/src/pages/hello-near/index.js index e62b1c4..3450314 100644 --- a/frontend/src/pages/hello-near/index.js +++ b/frontend/src/pages/hello-near/index.js @@ -28,11 +28,15 @@ export default function HelloNear() { }, [signedAccountId]); const saveGreeting = async () => { + wallet.callMethod({ contractId: CONTRACT, method: 'set_greeting', args: { greeting: newGreeting } }) + .then(async () => { + const greeting = await wallet.viewMethod({ contractId: CONTRACT, method: 'get_greeting' }); + setGreeting(greeting); + }); + setShowSpinner(true); + await new Promise(resolve => setTimeout(resolve, 300)); setGreeting(newGreeting); - await wallet.callMethod({ contractId: CONTRACT, method: 'set_greeting', args: { greeting: newGreeting } }); - const greeting = await wallet.viewMethod({ contractId: CONTRACT, method: 'get_greeting' }); - setGreeting(greeting); setShowSpinner(false); };