From f5b4131160520a2540445619188c3c8e0f37da37 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 12 Oct 2018 16:38:11 +0200 Subject: Notifications for chat ; useless user info page --- shardweb/lib/views/layout_view.ex | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'shardweb/lib/views') diff --git a/shardweb/lib/views/layout_view.ex b/shardweb/lib/views/layout_view.ex index 317d405..990df55 100644 --- a/shardweb/lib/views/layout_view.ex +++ b/shardweb/lib/views/layout_view.ex @@ -24,4 +24,25 @@ defmodule ShardWeb.LayoutView do l -> Enum.join(l, ", ") end end + + def chat_shard_last_msg(pid) do + [{{_, msgbin, _}, true}] = GenServer.call(pid, {:read_history, nil, 1}) + {_, msg} = SData.term_unbin msgbin + msg + end + + def privchat_with_unread(conn) do + for {id, %SApp.Chat.PrivChat.Manifest{pk_list: pk_list}, pid} <- shard_list(), + conn.assigns.pk in pk_list, + unread_time = GenServer.call(pid, :has_unread), + unread_time != nil, + do: {id, %SApp.Chat.PrivChat.Manifest{pk_list: pk_list}, pid} + end + + def chat_with_unread(conn) do + for {id, %SApp.Chat.Manifest{channel: c}, pid} <- shard_list(), + unread_time = GenServer.call(pid, :has_unread), + unread_time != nil, + do: {id, %SApp.Chat.Manifest{channel: c}, pid} + end end -- cgit v1.2.3