feat(collection): replace paginated collection browser with full owned map
Adds collection.get_owned endpoint that returns { definitionId → count }
for the player's entire collection in a single DB round-trip. The client
caches this map and filters/sorts entirely client-side using definitions
already in ContentCache, eliminating all pagination and "load more" UI.
- Search, type, and affinity filters now work across the full collection
instantly with no network round-trips
- deck_editor_panel: arch spirit picker also uses the owned map —
removes a separate collection.get_cards request
- cards_view: same pattern, grid rebuilds client-side on filter change
- CollectionCache: persists owned map to disk (owned.json per player)
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -12,6 +12,7 @@ var _loaded_player_id : String = ""
|
||||
var _cards_pages : Dictionary = {}
|
||||
var _decks_payload : Dictionary = {}
|
||||
var _deck_payloads : Dictionary = {}
|
||||
var _owned_map : Dictionary = {} ## definitionId(String) → ownedCount(int)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -138,6 +139,27 @@ func remove_deck(deck_id: String) -> void:
|
||||
_write_json_file(_decks_file_path(), _decks_payload)
|
||||
|
||||
|
||||
func get_owned_map() -> Dictionary:
|
||||
_ensure_loaded()
|
||||
if _loaded_player_id.is_empty():
|
||||
return {}
|
||||
if not _owned_map.is_empty():
|
||||
return _owned_map.duplicate(true)
|
||||
var payload := _read_json_file(_owned_file_path())
|
||||
if not payload.is_empty():
|
||||
_owned_map = payload
|
||||
return payload.duplicate(true)
|
||||
return {}
|
||||
|
||||
|
||||
func store_owned_map(map: Dictionary) -> void:
|
||||
_ensure_loaded()
|
||||
if _loaded_player_id.is_empty():
|
||||
return
|
||||
_owned_map = map.duplicate(true)
|
||||
_write_json_file(_owned_file_path(), _owned_map)
|
||||
|
||||
|
||||
func _ensure_loaded() -> void:
|
||||
var current_player_id := Auth.user_id
|
||||
if current_player_id == _loaded_player_id:
|
||||
@@ -146,6 +168,7 @@ func _ensure_loaded() -> void:
|
||||
_cards_pages.clear()
|
||||
_decks_payload.clear()
|
||||
_deck_payloads.clear()
|
||||
_owned_map.clear()
|
||||
|
||||
|
||||
func _player_dir() -> String:
|
||||
@@ -164,6 +187,10 @@ func _deck_file_path(deck_id: String) -> String:
|
||||
return "%s/deck_%s.json" % [_player_dir(), _sanitize_path_component(deck_id)]
|
||||
|
||||
|
||||
func _owned_file_path() -> String:
|
||||
return "%s/owned.json" % _player_dir()
|
||||
|
||||
|
||||
func _sanitize_path_component(value: String) -> String:
|
||||
var safe := value.strip_edges()
|
||||
if safe.is_empty():
|
||||
|
||||
Reference in New Issue
Block a user