We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 973caf2 commit 0717445Copy full SHA for 0717445
lib/instagram_clone_web/live/header_nav_component.ex
@@ -18,13 +18,18 @@ defmodule InstagramCloneWeb.HeaderNavComponent do
18
19
@impl true
20
def update(assigns, socket) do
21
- current_user_id = assigns.current_user.id
22
- unread_notification? = Notifications.get_unread(current_user_id)
23
-
24
{:ok,
25
socket
26
|> assign(assigns)
27
- |> assign(unread_notifications?: unread_notification?)}
+ |> assign(unread_notifications?: unread_notification?(assigns))}
+ end
+
+ defp unread_notification?(assigns) do
28
+ if assigns.current_user do
29
+ Notifications.get_unread(assigns.current_user.id)
30
+ else
31
+ false
32
33
end
34
35
0 commit comments