I know it sounds stupid to say, "Buy both", but that is what I would recommend.
Decide what YOU consider the minimum amount of magazines and ammunition to have on hand would be. Then inventory what you currently have. Work on the area you are lowest in, then gradually increase both magazines and ammunition.
Right now, magazines (AR and Glock) are really cheep on the internet. The cost of gas and admission to a show and "HOPE" I find a reassonable deal just about covers the cost of shipping when I order from the net.
Rifle ammunition is hard to find at a good price right now. But if you need it and none is to be found, how much is it worth to you?
I am currently ok on ammunition. I am replacing all of my older magazines for my Glock's and my AR15's with new ones. I test fire the new ones, then put them away. The magazines I had been using are now for range/training use.