From f4f9f14fbca2733a65a5d26ee63d5eeef3b6aa3f Mon Sep 17 00:00:00 2001 From: Jannik Streek Date: Wed, 18 Dec 2024 08:58:24 +0100 Subject: [PATCH] check data --- assets/scss/app.scss | 11 ++++++----- lib/mindwendel_web/live/brainstorming_live/show.ex | 7 ++++++- lib/mindwendel_web/live/live_helpers.ex | 7 +++++++ lib/mindwendel_web/live/start_live/home.ex | 7 ++++++- priv/gettext/de/LC_MESSAGES/default.po | 6 +++--- priv/gettext/default.pot | 6 +++--- priv/gettext/en/LC_MESSAGES/default.po | 6 +++--- 7 files changed, 34 insertions(+), 16 deletions(-) diff --git a/assets/scss/app.scss b/assets/scss/app.scss index 8eefa8b1..b814e2a8 100644 --- a/assets/scss/app.scss +++ b/assets/scss/app.scss @@ -53,16 +53,17 @@ a .bi { /* LiveView specific classes for your customizations */ +// similar to .phx-connected but also works when javascript is disabled +div[data-phx-session] { + height: 100%; + width: 100%; +} + .phx-click-loading { opacity: 0.5; transition: opacity 1s ease-out; } -.phx-connected { - height: 100%; - width: 100%; -} - .phx-disconnected { cursor: wait; } diff --git a/lib/mindwendel_web/live/brainstorming_live/show.ex b/lib/mindwendel_web/live/brainstorming_live/show.ex index 9af70372..0fec1131 100644 --- a/lib/mindwendel_web/live/brainstorming_live/show.ex +++ b/lib/mindwendel_web/live/brainstorming_live/show.ex @@ -64,7 +64,12 @@ defmodule MindwendelWeb.BrainstormingLive.Show do @impl true def handle_event("brainstormings_from_local_storage", brainstormings_stored, socket) do - {:noreply, assign(socket, :brainstormings_stored, brainstormings_stored)} + valid_stored_brainstormings = + if is_list(brainstormings_stored), + do: brainstormings_stored |> Enum.filter(&valid_stored_brainstorming?/1), + else: [] + + {:noreply, assign(socket, :brainstormings_stored, valid_stored_brainstormings)} end @impl true diff --git a/lib/mindwendel_web/live/live_helpers.ex b/lib/mindwendel_web/live/live_helpers.ex index 1d172906..750c89c3 100644 --- a/lib/mindwendel_web/live/live_helpers.ex +++ b/lib/mindwendel_web/live/live_helpers.ex @@ -53,4 +53,11 @@ defmodule MindwendelWeb.LiveHelpers do {:error, _} -> iso8601 end end + + def valid_stored_brainstorming?(brainstorming) do + case Ecto.UUID.cast(brainstorming["id"]) do + {:ok, _} -> brainstorming["last_accessed_at"] && brainstorming["name"] + :error -> false + end + end end diff --git a/lib/mindwendel_web/live/start_live/home.ex b/lib/mindwendel_web/live/start_live/home.ex index bf5312cd..0f357d3e 100644 --- a/lib/mindwendel_web/live/start_live/home.ex +++ b/lib/mindwendel_web/live/start_live/home.ex @@ -24,6 +24,11 @@ defmodule MindwendelWeb.StartLive.Home do @impl true def handle_event("brainstormings_from_local_storage", brainstormings_stored, socket) do - {:noreply, assign(socket, :brainstormings_stored, brainstormings_stored)} + valid_stored_brainstormings = + if is_list(brainstormings_stored), + do: brainstormings_stored |> Enum.filter(&valid_stored_brainstorming?/1), + else: [] + + {:noreply, assign(socket, :brainstormings_stored, valid_stored_brainstormings)} end end diff --git a/priv/gettext/de/LC_MESSAGES/default.po b/priv/gettext/de/LC_MESSAGES/default.po index 40349635..b1f8317b 100644 --- a/priv/gettext/de/LC_MESSAGES/default.po +++ b/priv/gettext/de/LC_MESSAGES/default.po @@ -26,12 +26,12 @@ msgstr "Wie können wir ..." msgid "Ready?" msgstr "Fertig?" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:192 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:197 #, elixir-autogen, elixir-format msgid "%{name} - Edit" msgstr "%{name} - Editieren" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:169 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:174 #, elixir-autogen, elixir-format msgid "%{name} - New Idea" msgstr "%{name} - Neue Idee" @@ -385,7 +385,7 @@ msgstr "Löschen" msgid "Type the label name" msgstr "Gebe dem Label einen Namen" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:179 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:184 #, elixir-autogen, elixir-format, fuzzy msgid "%{name} - New Lane" msgstr "%{name} - Neue Idee" diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 1f5d7f0d..f2c1eb4f 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -25,12 +25,12 @@ msgstr "" msgid "Ready?" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:192 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:197 #, elixir-autogen, elixir-format msgid "%{name} - Edit" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:169 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:174 #, elixir-autogen, elixir-format msgid "%{name} - New Idea" msgstr "" @@ -384,7 +384,7 @@ msgstr "" msgid "Type the label name" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:179 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:184 #, elixir-autogen, elixir-format msgid "%{name} - New Lane" msgstr "" diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po index c33bfb11..16ffbba2 100644 --- a/priv/gettext/en/LC_MESSAGES/default.po +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -26,12 +26,12 @@ msgstr "" msgid "Ready?" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:192 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:197 #, elixir-autogen, elixir-format msgid "%{name} - Edit" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:169 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:174 #, elixir-autogen, elixir-format msgid "%{name} - New Idea" msgstr "" @@ -385,7 +385,7 @@ msgstr "" msgid "Type the label name" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:179 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:184 #, elixir-autogen, elixir-format, fuzzy msgid "%{name} - New Lane" msgstr ""