mendrik

mendrik

Hello,

I’m a bit stuck with a problem that doesn’t seem to go away no matter what I try. I tried it with different liveview versions, including 1.0.0-rc.5, but no dice.

Basically I have a small app for uploading images to a digital album (example album: Albums Digital). Each album has multiple pages and each page has its own upload form.

Now most of the time the uploads work fine, but it seems every other time or so it gets stuck and the backend receives no events. I even tried to check for change events on the client side, but they seem not be fired at all in that case.
The relevant code can be found here Upload code · GitHub

Feel free to create a user to try it out. But I’m a bit at a loss why this is happening, so any suggestions or pointers would be appreciated.

Steps to reproduce: create a new album, upload a few images (either via link at bottom of page or drag&drop). Page ahead, repeat and notice that sometimes you select some images, but no upload was triggered. Immediately after a failure the upload works again.

I suspect there is something off with the state of the form or something like that, I’m also very new to Phoenix and Elixir so maybe I did some silly mistake somewhere.

Cheers,
Andreas

First Post!

mendrik

mendrik OP

Ok I tracked this down some more and it was caused by using custom flash code I found somewhere:

defmodule AlbumWeb.Flash do
  import Phoenix.LiveView

  require Logger

  def on_mount(:default, _params, _session, socket) do
    {:cont, attach_hook(socket, :flash_receiver, :handle_info, &maybe_receive_flash/2)}
  end

  defp maybe_receive_flash({:put_flash, type, message}, socket) do
    {:halt, put_flash(socket, type, message)}
  end

  defp maybe_receive_flash(_, socket), do: {:cont, socket}

  def put_flash!(socket, type, message) do
    send(self(), {:put_flash, type, message})
    Process.send_after(self(), :clear_flash, 3000)
    socket
  end
end

Somehow calling put_flash!() was breaking the state. I have for now opted to not use flash during an upload.

Last Post!

mendrik

mendrik OP

sorry, I thought my previous update fixed it, but my problem still persists.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews