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