Only Allah can keep the hearts steadfast. There’s Khayr for the believers who are patient no matter what happens.
We should constantly ask Allah for His mercy, because it is the afterlife where we will get the result of our deeds.
“Our Lord! Let not our hearts deviate after You have guided us, and grant us mercy from You. Truly, You are the Bestower.“
سورة آل عمران