bugfix: bounds checking on conversation messages when marking as read
bugfix: bounds checking on conversation messages when marking as read

* also refactored the code

dmitryame/echowaves,dmitryame/echowaves