aboutsummaryrefslogtreecommitdiff
path: root/shard/lib/app/chat.ex
diff options
context:
space:
mode:
Diffstat (limited to 'shard/lib/app/chat.ex')
-rw-r--r--shard/lib/app/chat.ex10
1 files changed, 9 insertions, 1 deletions
diff --git a/shard/lib/app/chat.ex b/shard/lib/app/chat.ex
index c7df62e..52ad920 100644
--- a/shard/lib/app/chat.ex
+++ b/shard/lib/app/chat.ex
@@ -51,9 +51,17 @@ defmodule SApp.Chat do
:ok ->
Shard.Manager.dispatch_to(id, nil, self())
{:ok, page_store} = SApp.PageStore.start_link(id, :page_store)
+ root = Shard.Manager.load_state id
+ root = cond do
+ root == nil -> nil
+ GenServer.call(page_store, {:have_rec, root}) -> root
+ true ->
+ Logger.warn "Not all pages for saved root were saved, restarting from an empty state!"
+ nil
+ end
mst = %MST{store: %SApp.PageStore{pid: page_store},
cmp: &msg_cmp/2,
- root: Shard.Manager.load_state(id)}
+ root: root}
GenServer.cast(self(), :init_pull)
{:ok,
%{channel: channel,