sodapopcan

sodapopcan

Phoenix stream reset woes

I’m having a bad time here and just posting to see if anyone can see what I’m doing wrong.

I’m using Flop Phoenix with streams. When I go to sort fields by clicking the header, the URL updates properly but nothing re-renders. Refreshing the page gives the desired results, so I figure there is nothing wrong with my business code. I’ve set it up according to the docs and no matter what I do, nothing seems to work. I’ve tried simplifying the table, configuring the stream with a different id function, and ore or less randomly changing the order of things, adding a mount function, removing the table opts, and so on. I’m sort of at my wit’s end for now so going to walk away for a bit, but I wanted to post here just in case someone can see what I’m doing wrong. I’m assuming it’s something really stupid.

Thanks in advance (and no problem if no one wants to help, lol).

Here is my whole liveview minus event handlers:

defmodule DesjWeb.Admin.Requests.IndexLive do
  @moduledoc false
  use DesjWeb, :live_view

  @impl true
  def handle_params(params, _uri, socket) do
    case Desj.Requests.list_open_requests(params) do
      {:ok, {requests, meta}} ->
        socket =
          socket
          |> stream(:requests, requests, reset: true)
          |> assign(:meta, meta)

        {:noreply, socket}

      {:error, _meta} ->
        {:noreply, push_navigate(socket, to: ~p"/admin/requests")}
    end
  end

  @impl true
  def render(assigns) do
    ~H"""
    <div :if={@meta.total_count == 0}>
      There are no requests at this time.
    </div>

    <Flop.Phoenix.table
      :if={@meta.total_count > 0}
      items={@streams.requests}
      meta={@meta}
      path={~p"/admin/requests"}
      opts={flop_table_opts(image?: true)}
    >
      <:col :let={{_, request}}>
        <.artwork artwork={request.artwork} />
      </:col>
      <:col :let={{_, request}} label="Artwork" field={:artwork_title}>
        <%= request.artwork.title %>
      </:col>
      <:col :let={{_, request}} label="User" field={:user_name}>
        <%= request.user.name %>
      </:col>
      <:col :let={{_, request}} label="Exclusivity?" field={:request_exclusivity}>
        <%= request.request_exclusivity %>
      </:col>
      <:col :let={{_, request}}>
        <div :if={request.status == :open} class="flex items-center gap-2">
          <form id={"reject-form-#{request.id}"} phx-submit="REJECT">
            <input type="hidden" name="request_id" value={request.id} />
            <.button kind={:reject}>Reject</.button>
          </form>

          <form id={"accept-form-#{request.id}"} phx-submit="ACCEPT">
            <input type="hidden" name="request_id" value={request.id} />
            <.button kind={:go}>Accept</.button>
          </form>
        </div>

        <div>
          <form
            :if={request.status == :rejected}
            id={"undo-reject-form-#{request.id}"}
            phx-submit="UNDO_REJECT"
          >
            <input type="hidden" name="request_id" value={request.id} /> Rejected
            <.button>Undo</.button>
          </form>
        </div>
      </:col>
    </Flop.Phoenix.table>
    """
  end
end

Marked As Solved

Also Liked

sodapopcan

sodapopcan

Ohhhhh, thanks! I thought I was losing my mind. I found a few issues but they were old so assumed it wasn’t a thing anymore.

THANKS!!

PS: I’m aware I have some bare <form>s (it’s on the list)… no one reading this should take that as good style :upside_down_face:

Last Post!

sodapopcan

sodapopcan

Ohhhhh, thanks! I thought I was losing my mind. I found a few issues but they were old so assumed it wasn’t a thing anymore.

THANKS!!

PS: I’m aware I have some bare <form>s (it’s on the list)… no one reading this should take that as good style :upside_down_face:

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49084 226
New

We're in Beta

About us Mission Statement