@@ -8,6 +8,7 @@ onready var posts_section : VBoxContainer = sections_container.get_node("Posts")
8
8
onready var users_list_section : VBoxContainer = sections_container .get_node ("UsersList" )
9
9
onready var settings_section : VBoxContainer = sections_container .get_node ("Settings" )
10
10
onready var profile_section : VBoxContainer = sections_container .get_node ("Profile" )
11
+ onready var notifications_section : VBoxContainer = sections_container .get_node ("Notifications" )
11
12
12
13
onready var post_box : VBoxContainer = posts_section .get_node ("ScrollPost/PostContainer" )
13
14
onready var profile_post_container : VBoxContainer = profile_section .get_node ("ScrollPost/PostContainer" )
@@ -16,18 +17,19 @@ onready var menu : VBoxContainer = $HomeContainer/Menu
16
17
onready var side_bar : VBoxContainer = $ HomeContainer/SideBar
17
18
onready var friend_list : VBoxContainer = side_bar .get_node ("FriendList" )
18
19
20
+ onready var notification_lbl : Label = $ HomeContainer/Menu/NotificationsBtn/Notification
19
21
20
22
onready var chat_container : GridContainer = $ AspectRatioContainer/ChatContainer
21
23
22
24
onready var show_post : Control = $ ShowPost
23
25
24
- onready var notification_lbl : Label = $ HomeContainer/Menu/NotificationsBtn/Notification
25
26
26
27
var fr_posts : FirestoreCollection = Firebase .Firestore .collection ("posts" )
27
28
28
29
var friend_posts : Array = []
29
30
30
31
var posts_db_reference : FirebaseDatabaseReference
32
+ var notifications_db_reference : FirebaseDatabaseReference
31
33
32
34
var window_size : Vector2
33
35
@@ -43,6 +45,8 @@ func _connect_signals():
43
45
$ HomeContainer/Menu/UsersListBtn .connect ("pressed" , self , "_on_UsersListBtn_pressed" )
44
46
$ HomeContainer/Menu/NotificationsBtn .connect ("pressed" , self , "_on_NotificationsBtn_pressed" )
45
47
$ HomeContainer/Menu/SettingsBtn .connect ("pressed" , self , "_on_SettingsBtn_pressed" )
48
+
49
+ notifications_section .connect ("visibility_changed" , self , "_on_notification_section_visibility" )
46
50
47
51
func _ready ():
48
52
_connect_signals ()
@@ -57,8 +61,7 @@ func _ready():
57
61
animate_Home (true )
58
62
load_posts ()
59
63
friend_list .load_friend_list ()
60
-
61
-
64
+ connect_notifications ()
62
65
63
66
func animate_Home (display : bool ):
64
67
if display :
@@ -100,6 +103,14 @@ func load_posts():
100
103
posts_db_reference = Firebase .Database .get_database_reference ("sociadot/posts" )
101
104
posts_db_reference .connect ("new_data_update" , self , "_on_new_post" )
102
105
106
+ func connect_notifications () -> void :
107
+ notifications_db_reference = Firebase .Database .get_database_reference ("sociadot/notifications/" + UserData .user_id )
108
+ notifications_db_reference .connect ("new_data_update" , self , "_on_new_notification" )
109
+
110
+ func _on_new_notification (notification : FirebaseResource ):
111
+ notifications_section .manage_notification (notification )
112
+ if not notification .data .viewed :
113
+ notification_lbl .show ()
103
114
104
115
func check_friend_posts_list (post_doc : FirestoreDocument ) -> bool :
105
116
for post in friend_posts :
@@ -231,7 +242,12 @@ func _on_open_post(post : PostsManager.Post):
231
242
show_post .show_post (post , UsersManager .get_user_by_id (post .user_id ))
232
243
233
244
func _on_NotificationsBtn_pressed ():
234
- pass
245
+ show_section (notifications_section )
246
+ notification_lbl .hide ()
247
+
248
+ func _on_notification_section_visibility ():
249
+ if not notifications_section .visible :
250
+ notifications_section .view_notifications ()
235
251
236
252
func _on_Home_item_rect_changed ():
237
253
update_chat_container ()
0 commit comments