@@ -65,21 +65,6 @@ func sort_posts(post_a : FirestoreDocument, post_b : FirestoreDocument):
65
65
func load_posts ():
66
66
if not UserData .friend_list .empty ():
67
67
posts_section .get_node ("NoFriends" ).hide ()
68
- # Get a list of all user's friends' posts
69
- # var temp_post_list : Array = yield(Utilities.get_friends_posts(), "result_query")
70
- # if temp_post_list[0].has("error"):
71
- # Activities.show_error(JSON.print(temp_post_list[0].error))
72
-
73
- # for friend in UserData.friend_list:
74
- # var post_task : FirestoreTask = Utilities.get_user_posts(friend)
75
- # var posts : Array = yield(post_task, "result_query")
76
- # if posts.empty():
77
- # continue
78
- # for post in posts:
79
- # if not post.has("document"):
80
- # continue
81
- # friend_posts.append(FirestoreDocument.new(post.document))
82
-
83
68
var posts : Array = yield (Utilities .get_all_posts (), "listed_documents" )
84
69
for post in posts :
85
70
if post .has ("fields" ):
@@ -92,26 +77,19 @@ func load_posts():
92
77
if friend_posts .empty ():
93
78
pass
94
79
else :
95
- # For each post in the list (which is a document)
96
80
for post in friend_posts .slice (0 , 10 ):
97
- # Create the actual FirestoreDocument
98
- # var post_info : FirestoreDocument = FirestoreDocument.new(post.document)
99
- # Make sure that the post is not already present in the dynamic DB PostsManager,
100
-
101
81
if PostsManager .has_post (post .doc_name ):
102
- # If this happens, check if a PostContainer linked to this post is already present in DB,
103
- # and eventually add it if not already added to the PostBox
104
82
if PostsManager .has_post_container (post .doc_name ):
105
83
var post_container : PostContainer = PostsManager .get_post_container_by_id (post .doc_name )
106
84
add_post (post_container )
107
85
else :
108
- # Create a PostContainer object, and populate it
109
- # the PostContainer object will automatically add itself to the list in PostsManager
110
86
var post_container : PostContainer = Activities .post_container_scene .instance ()
111
87
var post_obj : PostsManager .Post = PostsManager .add_post_from_doc (post .doc_name , post )
112
88
post_container .load_post (post_obj )
113
89
add_post (post_container )
114
90
else :
91
+ for post in post_box .get_children ():
92
+ if post is PostContainer : post .queue_free ()
115
93
posts_section .get_node ("NoFriends" ).show ()
116
94
117
95
@@ -128,8 +106,7 @@ func add_post(post : PostContainer):
128
106
func add_shared_post (post_id : String , document : FirestoreDocument , image : ImageTexture ):
129
107
var post : PostContainer = Activities .post_container_scene .instance ()
130
108
add_post (post )
131
- PostsManager .add_shared_post (post_id , document , image )
132
- post .load_shared_post (post_id , document , image )
109
+ post .load_post (PostsManager .add_shared_post (post_id , document , image ))
133
110
post_box .move_child (post , 0 )
134
111
135
112
0 commit comments