It seems to me that you ought to make this work for hiding transient notifications as well, just by moving the clearMessage out of the if statement.