aboutsummaryrefslogtreecommitdiff
path: root/shardweb/lib/views/layout_view.ex
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2018-10-15 12:18:05 +0200
committerAlex Auvolat <alex@adnab.me>2018-10-15 12:18:05 +0200
commit8c49dd71d29359447c24b1cd4f48a8faf0c4fdca (patch)
treee2d8b61139d6b72e6abfda6277918f54fdae36ef /shardweb/lib/views/layout_view.ex
parent7a9678843647de930885792149b279ef105f67b6 (diff)
downloadshard-8c49dd71d29359447c24b1cd4f48a8faf0c4fdca.tar.gz
shard-8c49dd71d29359447c24b1cd4f48a8faf0c4fdca.zip
Refactor shard starting/stopping
Diffstat (limited to 'shardweb/lib/views/layout_view.ex')
-rw-r--r--shardweb/lib/views/layout_view.ex7
1 files changed, 5 insertions, 2 deletions
diff --git a/shardweb/lib/views/layout_view.ex b/shardweb/lib/views/layout_view.ex
index d554804..40863a1 100644
--- a/shardweb/lib/views/layout_view.ex
+++ b/shardweb/lib/views/layout_view.ex
@@ -3,6 +3,7 @@ defmodule ShardWeb.LayoutView do
def shard_list do
Shard.Manager.list_shards
+ |> Enum.map(fn {id, manifest, _} -> {id, manifest, Shard.Manager.find_or_start manifest} end)
end
def str_of_pk_list(conn, pk_list) do
@@ -32,7 +33,8 @@ defmodule ShardWeb.LayoutView do
end
def privchat_with_unread(conn) do
- for {id, %SApp.Chat.PrivChat.Manifest{pk_list: pk_list}, pid} <- shard_list(),
+ for {id, %SApp.Chat.PrivChat.Manifest{pk_list: pk_list}, _} <- shard_list(),
+ pid = Shard.Manager.find_or_start(%SApp.Chat.PrivChat.Manifest{pk_list: pk_list}),
conn.assigns.pk in pk_list,
unread_time = SApp.Chat.has_unread?(pid),
unread_time != nil,
@@ -40,7 +42,8 @@ defmodule ShardWeb.LayoutView do
end
def chat_with_unread(_conn) do
- for {id, %SApp.Chat.Manifest{channel: c}, pid} <- shard_list(),
+ for {id, %SApp.Chat.Manifest{channel: c}, _} <- shard_list(),
+ pid = Shard.Manager.find_or_start(%SApp.Chat.Manifest{channel: c}),
unread_time = SApp.Chat.has_unread?(pid),
unread_time != nil,
do: {id, %SApp.Chat.Manifest{channel: c}, pid}