Skip to content

Commit

Permalink
fix: add delay before showing greeting
Browse files Browse the repository at this point in the history
  • Loading branch information
gagdiez committed Dec 2, 2024
1 parent 9bd819b commit b4b8e8b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions frontend/src/pages/hello-near/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down

0 comments on commit b4b8e8b

Please sign in to comment.