Skip to content

Commit

Permalink
Bugfix/fix example project fetching older messages (#136)
Browse files Browse the repository at this point in the history
* Fix excessive TryLoadPreviousMessagesAsync calling - ScrollRect after finished scrolling can have like 1.00005  so we need to add threshold when detecting user scrolling

* cleanup
  • Loading branch information
sierpinskid authored Jan 3, 2024
1 parent b26d09e commit 3737732
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,5 @@ internal CacheRepository(ConstructorHandler constructor, ICache cache)

private readonly ConstructorHandler _constructor;
private readonly ICache _cache;
private readonly IStatefulModelsFactory _statefulModelsFactory;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public StreamUser CreateStreamUser(string uniqueId)
private readonly ILogs _logs;
private readonly StreamChatClient _streamChatClient;
private readonly IStatefulModelContext _context;
private readonly Cache _cache;
private readonly ICache _cache;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ internal StreamStatefulModelBase(string uniqueId, ICacheRepository<TStatefulMode
Repository.Track(Self);
}

//StreamTodo: wrap completely the _additionalProperties in StreamCustomData and not operate on both
protected Dictionary<string, object> GetInternalAdditionalPropertiesDictionary() => _additionalProperties;

protected abstract string InternalUniqueId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ protected override void OnUpdate()
return;
}

if (_scrollRect.verticalNormalizedPosition >= 1f && !IsScrollListRebuilding)
// Check against 1f + threshold because idle ScrollRect after scrolling can have fractional values above 1f
if (_scrollRect.verticalNormalizedPosition >= 1.05f && !IsScrollListRebuilding)
{
TryLoadPreviousMessagesAsync().LogIfFailed();
}
Expand Down Expand Up @@ -283,9 +284,8 @@ private void HideContextMenuIfTouchedOutside()
return;
}

if (Input.touchCount == 0)
if (Input.touchCount == 0 || _activePopup == null)
{

return;
}

Expand Down

0 comments on commit 3737732

Please sign in to comment.