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:
jack
2025-07-04 15:45:29 +02:00
parent 986106fea4
commit 38a7ba07ee
2 changed files with 39 additions and 28 deletions
+6 -3
View File
@@ -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()