diff --git a/WhoIsLive.UX/ViewModels/Screens/StreamsBrowserViewModel.cs b/WhoIsLive.UX/ViewModels/Screens/StreamsBrowserViewModel.cs index 694b21c..741d37b 100644 --- a/WhoIsLive.UX/ViewModels/Screens/StreamsBrowserViewModel.cs +++ b/WhoIsLive.UX/ViewModels/Screens/StreamsBrowserViewModel.cs @@ -287,6 +287,8 @@ private void ChangePage(int page, bool doRecalculation = true) { Page = page; + UnsubscribeFromEvents(); + CurrentPageLiveStreams.Clear(); if (doRecalculation) @@ -295,6 +297,15 @@ private void ChangePage(int page, bool doRecalculation = true) FillPage((Page - 1) * _elementsPerPage); } + public void UnsubscribeFromEvents() + { + foreach (var stream in CurrentPageLiveStreams) + { + stream.BlockRequested -= OnBlockRequested; + stream.OpenRequested -= OnOpenRequested; + } + } + public void RecalculatePageCount() { PageCount = (int)Math.Ceiling((double)_liveStreams.Count / _elementsPerPage); @@ -328,6 +339,7 @@ private void FillPage(int fromIndex) var stream = _liveStreams[i]; CurrentPageLiveStreams.Add(stream); + stream.BlockRequested += OnBlockRequested; stream.OpenRequested += OnOpenRequested; }