fix: address Copilot review comments
- ChessPosition: include all fields in equals/hashCode - AcceptedGamesRegistry: add thread safety with synchronized - ChessEventBroadcaster: use valid filter for connection trigger - ChessEventBroadcaster: fix misleading relayResults - Remove println debug logging from ChessSubscription/Broadcaster - UserProfileScreen: use proper JSON parsing via MetadataEvent Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2025 Vitor Pamplona
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2025 Vitor Pamplona
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2025 Vitor Pamplona
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2025 Vitor Pamplona
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
|
||||
+2
-5
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2025 Vitor Pamplona
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
@@ -104,10 +104,7 @@ class DesktopChessSubscriptionController(
|
||||
) {
|
||||
// Add chess events to local cache for persistence
|
||||
if (event.kind in CHESS_EVENT_KINDS) {
|
||||
val isNew = DesktopChessEventCache.add(event)
|
||||
if (isNew) {
|
||||
println("[ChessSubscription] Cached new event: kind=${event.kind}, id=${event.id.take(8)}")
|
||||
}
|
||||
DesktopChessEventCache.add(event)
|
||||
}
|
||||
onEvent(event, isLive, relay, forFilters)
|
||||
}
|
||||
|
||||
+17
-24
@@ -201,21 +201,25 @@ fun UserProfileScreen(
|
||||
relays = configuredRelays,
|
||||
pubKeyHex = pubKeyHex,
|
||||
onEvent = { event, _, _, _ ->
|
||||
try {
|
||||
val content = event.content
|
||||
displayName = extractJsonField(content, "display_name") ?: extractJsonField(content, "name")
|
||||
about = extractJsonField(content, "about")
|
||||
picture = extractJsonField(content, "picture")
|
||||
|
||||
// Store MetadataEvent for editing (only for own profile)
|
||||
if (isOwnProfile && event is MetadataEvent) {
|
||||
val current = latestMetadataEvent
|
||||
if (current == null || event.createdAt > current.createdAt) {
|
||||
latestMetadataEvent = event
|
||||
if (event is MetadataEvent) {
|
||||
try {
|
||||
val metadata = event.contactMetaData()
|
||||
if (metadata != null) {
|
||||
displayName = metadata.displayName ?: metadata.name
|
||||
about = metadata.about
|
||||
picture = metadata.picture
|
||||
}
|
||||
|
||||
// Store MetadataEvent for editing (only for own profile)
|
||||
if (isOwnProfile) {
|
||||
val current = latestMetadataEvent
|
||||
if (current == null || event.createdAt > current.createdAt) {
|
||||
latestMetadataEvent = event
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
// Ignore parse errors
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
// Ignore parse errors
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -688,17 +692,6 @@ fun UserProfileScreen(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple JSON field extractor (not production-ready, just for demo).
|
||||
*/
|
||||
private fun extractJsonField(
|
||||
json: String,
|
||||
field: String,
|
||||
): String? {
|
||||
val regex = """"$field"\s*:\s*"([^"]*)"""".toRegex()
|
||||
return regex.find(json)?.groupValues?.get(1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Follows a user by publishing an updated contact list event.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user