mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 17:45:21 +00:00
Fix connection tracking and timestamp compatibility issues
- Fix 'alone :/' bug by not requiring nicknames for peer counting - Handle both second and millisecond timestamps for compatibility with older clients - Fix NaN errors in autocomplete positioning with bounds checking - Simplify getAllConnectedPeerIDs to show all valid active peers - Add timestamp conversion logic to handle ~55 year time difference bug
This commit is contained in:
@@ -106,8 +106,11 @@ struct ContentView: View {
|
||||
// Calculate approximate position based on nickname length and @ position
|
||||
let nicknameWidth: CGFloat = viewModel.selectedPrivateChatPeer != nil ? 90 : 80
|
||||
let charWidth: CGFloat = 8.5 // Approximate width of monospace character
|
||||
let atPosition = viewModel.autocompleteRange?.location ?? 0
|
||||
let offsetX = nicknameWidth + (CGFloat(atPosition) * charWidth)
|
||||
let atPosition = CGFloat(viewModel.autocompleteRange?.location ?? 0)
|
||||
let offsetX = nicknameWidth + (atPosition * charWidth)
|
||||
|
||||
// Ensure offsetX is valid (not NaN or infinite)
|
||||
let safeOffsetX = offsetX.isFinite ? offsetX : nicknameWidth
|
||||
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
ForEach(Array(viewModel.autocompleteSuggestions.enumerated()), id: \.element) { index, suggestion in
|
||||
@@ -133,7 +136,7 @@ struct ContentView: View {
|
||||
.stroke(secondaryTextColor.opacity(0.5), lineWidth: 1)
|
||||
)
|
||||
.frame(width: 150, alignment: .leading)
|
||||
.offset(x: min(offsetX, geometry.size.width - 180)) // Prevent going off-screen
|
||||
.offset(x: min(safeOffsetX, max(0, geometry.size.width - 180))) // Prevent going off-screen
|
||||
.padding(.bottom, 45) // Position just above input
|
||||
|
||||
Spacer()
|
||||
|
||||
Reference in New Issue
Block a user