hotfix: Fix map behaviour for 'Allow only tracked characters' map option

This commit is contained in:
Dmitry Popov
2025-01-07 13:46:34 +01:00
parent 1cd23d5efd
commit e5ef35c186
4 changed files with 16 additions and 30 deletions
+2 -2
View File
@@ -201,7 +201,7 @@ defmodule WandererApp.Map.Server.Impl do
| map: map |> WandererApp.Map.update_subscription_settings!(subscription_settings)
}
def handle_event(:update_characters, %{map_id: map_id} = state) do
def handle_event(:update_characters, state) do
Process.send_after(self(), :update_characters, @update_characters_timeout)
CharactersImpl.update_characters(state)
@@ -259,7 +259,7 @@ defmodule WandererApp.Map.Server.Impl do
state
end
def handle_event(:cleanup_systems, %{map_id: map_id} = state) do
def handle_event(:cleanup_systems, state) do
Process.send_after(self(), :cleanup_systems, @systems_cleanup_timeout)
state |> SystemsImpl.cleanup_systems()
@@ -192,16 +192,15 @@ defmodule WandererAppWeb.MapCharactersEventHandler do
end
def handle_ui_event(
"toggle_follow",
%{"character-id" => clicked_char_id},
%{
assigns: %{
map_id: map_id,
current_user: current_user
}
} = socket
) do
"toggle_follow",
%{"character-id" => clicked_char_id},
%{
assigns: %{
map_id: map_id,
current_user: current_user
}
} = socket
) do
{:ok, all_settings} = WandererApp.MapCharacterSettingsRepo.get_all_by_map(map_id)
# Find and filter user's characters
@@ -217,7 +216,7 @@ defmodule WandererAppWeb.MapCharactersEventHandler do
existing = Enum.find(my_settings, &(&1.character_id == clicked_char_id))
{:ok, target_setting} =
if existing do
if not is_nil(existing) do
{:ok, existing}
else
WandererApp.MapCharacterSettingsRepo.create(%{
@@ -276,7 +275,6 @@ defmodule WandererAppWeb.MapCharactersEventHandler do
{:noreply, socket}
end
def handle_ui_event("hide_tracking", _, socket),
do: {:noreply, socket |> assign(show_tracking?: false)}
@@ -162,7 +162,7 @@ defmodule WandererAppWeb.MapCoreEventHandler do
socket
)
def handle_ui_event("toggle_follow_" <> character_id, _, socket),
def handle_ui_event("toggle_follow_" <> character_id, _, socket),
do:
MapCharactersEventHandler.handle_ui_event(
"toggle_follow",
@@ -234,7 +234,7 @@ defmodule WandererAppWeb.MapCoreEventHandler do
|> MapCharactersEventHandler.add_character()}
def handle_ui_event(event, body, socket) do
Logger.warning(fn -> "unhandled map ui event: #{event} #{inspect(body)}" end)
Logger.warning(fn -> "unhandled map ui event: #{inspect(event)} #{inspect(body)}" end)
{:noreply, socket}
end
+2 -14
View File
@@ -77,13 +77,14 @@ defmodule WandererAppWeb.MapLive do
def handle_info(:not_all_characters_tracked, %{assigns: %{map_slug: map_slug}} = socket),
do:
WandererAppWeb.MapEventHandler.handle_ui_event(
%{event: "add_character"},
"add_character",
nil,
socket
|> put_flash(
:error,
"You should enable tracking for all characters that have access to this map first!"
)
|> push_navigate(to: ~p"/tracking/#{map_slug}")
)
@impl true
@@ -101,17 +102,4 @@ defmodule WandererAppWeb.MapLive do
socket
|> assign(:active_page, :map)
end
def character_item(assigns) do
~H"""
<div class="flex items-center gap-3">
<div class="avatar">
<div class="rounded-md w-12 h-12">
<img src={member_icon_url(@character.eve_id)} alt={@character.name} />
</div>
</div>
<%= @character.name %>
</div>
"""
end
end