Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Demo App Refresh Tokens + Connection Banner #3313

Merged
merged 5 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DemoApp/Shared/Token+Development.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension StreamChatWrapper {
{ completion in
// Simulate API call delay
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
var generatedToken: Token? = _generateUserToken(
let generatedToken: Token? = _generateUserToken(
secret: refreshDetails.appSecret,
userID: initialToken.userId,
expirationDate: Date().addingTimeInterval(refreshDetails.duration)
Expand All @@ -26,7 +26,7 @@ extension StreamChatWrapper {

let numberOfSuccessfulRefreshes = refreshDetails.numberOfSuccessfulRefreshesBeforeFailing
let shouldNotFail = numberOfSuccessfulRefreshes == 0
if shouldNotFail || self.numberOfRefreshTokens <= numberOfSuccessfulRefreshes {
if shouldNotFail || self.numberOfRefreshTokens >= numberOfSuccessfulRefreshes {
print("Demo App Token Refreshing: New token generated successfully.")
let newToken = generatedToken ?? initialToken
completion(.success(newToken))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ extension BannerShowingConnectionDelegate: ChatConnectionControllerDelegate {
bannerView.update(text: "Disconnected")
showBanner()
case .connected:
bannerView.update(text: "Connected")
hideBanner()
case .disconnecting:
bannerView.update(text: "Disconnecting...")
showBanner()
case .connecting:
bannerView.update(text: "Connecting...")
showBanner()
case .initialized:
break
}
Expand All @@ -45,7 +48,7 @@ extension BannerShowingConnectionDelegate: ChatConnectionControllerDelegate {
private extension BannerShowingConnectionDelegate {
func setupViews() {
attachToTopViewIfNeeded()
bannerView.alpha = 0
bannerView.alpha = 1
bannerView.update(text: "Connecting...")
}

Expand Down
Loading