One flow
A write is not done when the wallet opens. It is not even done when the wallet returns a hash.
The safe flow is: call the contract, get a transaction hash, show pending, wait for the receipt, then show success or failure.
Write vs read
A read calls a view or pure function. It does not change chain state and does not ask the user to pay gas.
A write changes blockchain state. The wallet must show the transaction, the user must approve it, and the network must include it in a block.