Fix #7161 by only refreshing when needed.

Fix for #7161 

Check to see if the sortDirectoriesFirst has actually changed before refresh.

@TomMalbran want to take a look?