1
0
mirror of https://github.com/algora-io/tv.git synced 2025-10-30 23:07:56 +02:00

Revert "add timestamps for chat messages (#36)"

This reverts commit ab0bd74945.
This commit is contained in:
zafer
2024-05-21 02:30:45 +03:00
parent 8b6116fd90
commit 0b4d3f3145
3 changed files with 0 additions and 56 deletions

View File

@@ -1,24 +0,0 @@
defmodule AlgoraWeb.ChatMessageTimestampComponent do
use AlgoraWeb, :live_component
def render(assigns) do
~H"""
<span class="text-gray-400 text-xs ml-1">
<%= format_timestamp(@message.inserted_at) %>
</span>
"""
end
defp format_timestamp(timestamp) do
now = NaiveDateTime.utc_now()
diff_in_seconds = NaiveDateTime.diff(now, timestamp)
cond do
diff_in_seconds < 60 -> "Just now"
diff_in_seconds < 3600 -> "#{div(diff_in_seconds, 60)}m ago"
diff_in_seconds < 86_400 -> "#{div(diff_in_seconds, 3600)}h ago"
diff_in_seconds < 604_800 -> "#{div(diff_in_seconds, 86400)}d ago"
true -> Calendar.strftime(timestamp, "%b %-d, %Y")
end
end
end

View File

@@ -82,11 +82,6 @@ defmodule AlgoraWeb.ChatLive do
<span class="font-medium text-gray-100">
<%= message.body %>
</span>
<.live_component
module={AlgoraWeb.ChatMessageTimestampComponent}
id={"timestamp-#{message.id}"}
message={message}
/>
</div>
</div>
</div>
@@ -110,7 +105,6 @@ defmodule AlgoraWeb.ChatLive do
Chat.subscribe_to_room(video)
Presence.subscribe(channel_handle)
schedule_timestamp_tick()
end
videos = Library.list_channel_videos(channel, 50)
@@ -229,16 +223,6 @@ defmodule AlgoraWeb.ChatLive do
def handle_info({Library, _}, socket), do: {:noreply, socket}
def handle_info(:tick, socket) do
send_update(AlgoraWeb.ChatMessageTimestampComponent, %{})
schedule_timestamp_tick()
{:noreply, socket}
end
defp schedule_timestamp_tick() do
Process.send_after(self(), :tick, :timer.minutes(1))
end
defp system_message?(%Chat.Message{} = message) do
message.sender_handle == "algora"
end

View File

@@ -411,11 +411,6 @@ defmodule AlgoraWeb.VideoLive do
<span class="font-medium text-gray-100">
<%= message.body %>
</span>
<.live_component
module={AlgoraWeb.ChatMessageTimestampComponent}
id={"timestamp-#{message.id}"}
message={message}
/>
<button
:if={@current_user && Chat.can_delete?(@current_user, message)}
phx-click="delete"
@@ -525,7 +520,6 @@ defmodule AlgoraWeb.VideoLive do
})
Presence.subscribe(channel_handle)
schedule_timestamp_tick()
end
videos = Library.list_channel_videos(channel, 50)
@@ -668,16 +662,6 @@ defmodule AlgoraWeb.VideoLive do
def handle_info({Library, _}, socket), do: {:noreply, socket}
def handle_info(:tick, socket) do
send_update(AlgoraWeb.ChatMessageTimestampComponent, %{})
schedule_timestamp_tick()
{:noreply, socket}
end
defp schedule_timestamp_tick() do
Process.send_after(self(), :tick, :timer.minutes(1))
end
defp fmt(num) do
chars = num |> Integer.to_string() |> String.to_charlist()
{h, t} = Enum.split(chars, rem(length(chars), 3))