From 4b4c01bb146f9fcde1e3e47ca859bbbfef0e95f0 Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Mon, 21 Aug 2023 13:40:48 +0200 Subject: [PATCH] feat(chat): message bookmarks --- lib/bdfr_browser/message.ex | 1 + ...30821110436_add_chat_message_bookmarks.exs | 9 ++++++ priv/templates/http/chat.eex | 29 ++++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 priv/repo/migrations/20230821110436_add_chat_message_bookmarks.exs diff --git a/lib/bdfr_browser/message.ex b/lib/bdfr_browser/message.ex index 83480a3..ff4f96c 100644 --- a/lib/bdfr_browser/message.ex +++ b/lib/bdfr_browser/message.ex @@ -12,6 +12,7 @@ defmodule BdfrBrowser.Message do field :author, :string field :message, :string field :posted_at, :utc_datetime + field :bookmark, :string belongs_to :chat, Chat end diff --git a/priv/repo/migrations/20230821110436_add_chat_message_bookmarks.exs b/priv/repo/migrations/20230821110436_add_chat_message_bookmarks.exs new file mode 100644 index 0000000..acaf9b1 --- /dev/null +++ b/priv/repo/migrations/20230821110436_add_chat_message_bookmarks.exs @@ -0,0 +1,9 @@ +defmodule BdfrBrowser.Repo.Migrations.AddChatMessageBookmarks do + use Ecto.Migration + + def change do + alter table("messages") do + add :bookmark, :string + end + end +end diff --git a/priv/templates/http/chat.eex b/priv/templates/http/chat.eex index 65ccd53..364a909 100644 --- a/priv/templates/http/chat.eex +++ b/priv/templates/http/chat.eex @@ -1,7 +1,12 @@

Chats

<%= for message <- messages do %> -
+
+ data-bookmark="<%= message.bookmark %>" + <% end %> + >
@@ -10,9 +15,31 @@
<%= message.author %>, <%= DateTime.to_iso8601(message.posted_at) %> + + <%= unless is_nil(message.bookmark) do %> + <%= message.bookmark %> + <% end %>
<% end %> + +