diff --git a/Components/Feed/GlobePanel.razor b/Components/Feed/GlobePanel.razor index 559a37a..4584a04 100644 --- a/Components/Feed/GlobePanel.razor +++ b/Components/Feed/GlobePanel.razor @@ -67,11 +67,15 @@ DotNetObjectReference reference; PeriodicTimer statsTimer; readonly CancellationTokenSource cancellation = new(); - string sentFingerprint; + int? sentFingerprint; + // the posts are looked at again only when the feed hands them over, never on the stats overlay's own renders + bool postsHandedOver = true; GlobeStats stats; protected override void OnInitialized() => IsLoading = false; + protected override void OnParametersSet() => postsHandedOver = true; + protected override async Task OnAfterRenderAsync(bool firstRender) { await base.OnAfterRenderAsync(firstRender); @@ -86,7 +90,11 @@ statsTimer = new(TimeSpan.FromSeconds(1)); _ = ReadStats(cancellation.Token); } - await SendPosts(); + if (postsHandedOver) + { + postsHandedOver = false; + await SendPosts(); + } } catch (JSDisconnectedException) { @@ -105,7 +113,17 @@ var located = Posts.Where(p => p.Location is not null).ToList(); var self = InstanceService.Known(InstanceService.SelfHost); - var fingerprint = string.Join('|', located.Select(p => $"{p.Key}:{p.Location.Latitude}:{p.Location.Longitude}:{p.Location.CdnKey}")) + $"#{self?.Geo?.Latitude}"; + // a hash, not a string of every place: a feed of thousands is looked at on every page it loads + var hash = new HashCode(); + foreach (var post in located) + { + hash.Add(post.Key); + hash.Add(post.Location.Latitude); + hash.Add(post.Location.Longitude); + hash.Add(post.Location.CdnKey); + } + hash.Add(self?.Geo?.Latitude); + var fingerprint = hash.ToHashCode(); if (fingerprint == sentFingerprint) return; sentFingerprint = fingerprint;