mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-23 17:17:31 -04:00
featured gates done
This commit is contained in:
parent
e5be40a3d0
commit
bcb5c880b5
2 changed files with 17 additions and 5 deletions
|
@ -15,7 +15,7 @@ func on_bookmarks_ready() -> void:
|
|||
if bookmarks.gates.size() > 0: return
|
||||
|
||||
await featured_gates_request()
|
||||
Debug.logclr("Featured gates requested", Color.LIGHT_SEA_GREEN)
|
||||
Debug.logclr("======== Featured gates ========", Color.LIGHT_SEA_GREEN)
|
||||
|
||||
var gates = JSON.parse_string(result_str)
|
||||
if gates == null or gates.is_empty():
|
||||
|
@ -23,8 +23,8 @@ func on_bookmarks_ready() -> void:
|
|||
return
|
||||
|
||||
for gate in gates:
|
||||
# TODO: download image and add to bookmarks
|
||||
Debug.logr(gate["url"])
|
||||
await star_gate(gate)
|
||||
|
||||
|
||||
func featured_gates_request() -> void:
|
||||
|
@ -35,3 +35,10 @@ func featured_gates_request() -> void:
|
|||
|
||||
var err = await Backend.request(api.featured_gates, callback)
|
||||
if err != HTTPRequest.RESULT_SUCCESS: Debug.logclr("Cannot send featured gates request", Color.RED)
|
||||
|
||||
|
||||
func star_gate(gate_d: Dictionary) -> void:
|
||||
var image_path = await FileDownloader.download(gate_d["image"])
|
||||
var gate = Gate.create(gate_d["url"], gate_d["title"], gate_d["description"], image_path, "", "")
|
||||
|
||||
bookmarks.star(gate)
|
||||
|
|
|
@ -5,7 +5,12 @@ extends GridContainer
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
bookmarks.on_star.connect(show_bookmark)
|
||||
for gate in bookmarks.gates.values():
|
||||
var bookmark: BookmarkUI = bookmark_scene.instantiate()
|
||||
bookmark.fill(gate)
|
||||
add_child(bookmark)
|
||||
show_bookmark(gate)
|
||||
|
||||
|
||||
func show_bookmark(gate: Gate) -> void:
|
||||
var bookmark: BookmarkUI = bookmark_scene.instantiate()
|
||||
bookmark.fill(gate)
|
||||
add_child(bookmark)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue