If I remember this right Hagia Sophia was a mostly a wooden structure that was damaged\burned in the Nikka Riots (532 AD). Justinian I had it rebuilt into the magnificent structure it is today.
Righto!
Byzantine Emperor Constantius commissioned construction of the first Hagia Sophia in 360 A.D. Unfortunately it had a wooden roof and burned to the ground during a revolt in 404 AD.
It was rebuilt but again with a wooden roof.
It was badly damaged during the Nika Revolt and repair was impossible. Emperor Justinian I commissioned renowned architects Isidoros (Milet) and Anthemios (Tralles) to build a new basilica. When it was completed in 537 AD Emperor Justinian is reported to have said, “My Lord, thank you for giving me the chance to create such a worshipping place.”
https://www.history.com/topics/ancient-greece/hagia-sophia