Better check whether public mode is set: $('#isPublic').val()
The current check means getStorageStats is still called if a logged in user is opening a public link (which is a mixed case)