aboutsummaryrefslogtreecommitdiff
path: root/shardweb/lib/views/layout_view.ex
diff options
context:
space:
mode:
Diffstat (limited to 'shardweb/lib/views/layout_view.ex')
-rw-r--r--shardweb/lib/views/layout_view.ex21
1 files changed, 21 insertions, 0 deletions
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