Skip to content

Commit

Permalink
https://github.com/bonfire-networks/bonfire-app/issues/258
Browse files Browse the repository at this point in the history
  • Loading branch information
mayel committed May 6, 2022
1 parent c718963 commit dbe24ee
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/social/boosts/live_handler.ex
Expand Up @@ -2,24 +2,28 @@ defmodule Bonfire.Social.Boosts.LiveHandler do
use Bonfire.UI.Common.Web, :live_handler
import Where

def handle_event("boost", params, %{assigns: %{object: object}} = socket) do # boost in LV stateful component
with {:ok, boost} <- Bonfire.Social.Boosts.boost(current_user(socket), object) do
boost_action(object, true, params, socket)
end
end

def handle_event("boost", %{"id"=> id} = params, socket) do # boost in LV
#debug(socket)
with {:ok, boost} <- Bonfire.Social.Boosts.boost(current_user(socket), id) do

set = [my_boost: true]

ComponentID.send_assigns(e(params, "component", Bonfire.UI.Social.Activity.BoostActionLive), id, set, socket)

boost_action(id, true, params, socket)
end
end

def handle_event("undo", %{"id"=> id} = params, socket) do # unboost in LV
with {:ok, unboost} <- Bonfire.Social.Boosts.unboost(current_user(socket), id) do
set = [my_boost: false]
boost_action(id, false, params, socket)
end
end

ComponentID.send_assigns(e(params, "component", Bonfire.UI.Social.Activity.BoostActionLive), id, set, socket)
defp boost_action(object, boost?, params, socket) do
set = [my_boost: boost?]

end
ComponentID.send_assigns(e(params, "component", Bonfire.UI.Social.Activity.BoostActionLive), ulid(object), set, socket)
end

def preload(list_of_assigns) do
Expand Down

0 comments on commit dbe24ee

Please sign in to comment.