[client][EventsView] Extract some lines to a function to improve readability.