<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="309444" data-post-id="309444">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="GumptionWare" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/GumptionWare/120/27009_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  GumptionWare
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hey <a class="mention" href="/u/sezaru" rel="nofollow">@sezaru</a>, I am stuck on getting this error when I try to compile.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">error: undefined function put_notification/2 (expected MinderyWeb.UserSessionController to define such a function or for it to be imported, but none are available)
</code></pre>
<p>I can see from your repo that this is defined in <code>flashy.ex</code>, but my import in <code>app.js</code> is apparently not finding it–or maybe my <code>mix deps.get</code> is not picking it up. (I have verified both multiple times).</p>
<p>I’m probably making a dumb mistake/subtle typo somewhere. Anything obvious jump out at you?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309444" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/flash-message-to-disappear-after-5-seconds/32285/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-309444" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309444"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="309497" data-post-id="309497">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sezaru" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sezaru/120/36113_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sezaru
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Did you went through the installation steps <a href="https://github.com/sezaru/flashy#installation" class="inline-onebox" rel="noopener nofollow ugc">GitHub - sezaru/flashy: Flashy is a small library that extends LiveView's flash support to function and live components. · GitHub</a>? In this specific case it seems you are missing the <code>import Flashy</code> in your <code>lib/&lt;your_app&gt;_web.ex</code> file</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309497" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/flash-message-to-disappear-after-5-seconds/32285/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-309497" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309497"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="309499" data-post-id="309499">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="GumptionWare" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/GumptionWare/120/27009_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  GumptionWare
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>UPDATE:</p>
<p>We resolved the <code>undefined function put_notification</code> issue. (We were missing the <code>import Flashy</code> in <em><strong>both</strong></em> places in MyAppWeb.ex.)</p>
<p>I think we are getting close. We are now figuring out how to change the icons displaying for each <code>type</code>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309499" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/flash-message-to-disappear-after-5-seconds/32285/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-309499" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309499"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="309552" data-post-id="309552">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="GumptionWare" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/GumptionWare/120/27009_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  GumptionWare
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>UPDATE:</p>
<p>We have Flashy functionality working, but we are figuring out why our configuration results in the Petal <code>Alert</code> components getting rendered for us much differently than they do in the <code>flashy_demo</code> project.</p>
<p>All that aside, <em><strong>many thanks</strong></em> for creating this. This is <em><strong>exactly</strong></em> the kind of thing I was saying we all need for our Phoenix projects.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309552" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/flash-message-to-disappear-after-5-seconds/32285/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-309552" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309552"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="309574" data-post-id="309574">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sezaru" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sezaru/120/36113_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sezaru
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Not sure what is being rendered differently, but one thing that can affect it is what css you have applied in tags above it in the <code>app.html.heex</code> and <code>root.html.heex</code>.</p>
<p>If that is the case, you can always customize the <code>Flashy.Container</code> css to adapt to your needs.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309574" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/flash-message-to-disappear-after-5-seconds/32285/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-309574" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309574"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="309809" data-post-id="309809">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="GumptionWare" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/GumptionWare/120/27009_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  GumptionWare
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thank you <a class="mention" href="/u/sezaru" rel="nofollow">@sezaru</a>. As a Phoenix newbie, I’m struggling with adapting my Liveview tests for using Flashy. For example:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">...
  refute get_session(conn, :user_token)
  assert Phoenix.Flash.get(conn.assigns.flash, :info) =~ "Password reset successfully"
...
</code></pre>
<p>I’m getting <code>** (FunctionClauseError) no function clause matching in Kernel.=~/2</code> against that <code>Phoenix.Flash.get(conn.assigns.flash, :info) =~ ...</code> line, which makes sense, because our <code>conn.assigns</code> no longer has a <code>flash</code>.</p>
<p>What I cannot discern from the Flashy docs is how to retrieve the value from the <code>put_notification</code> that replaced the former call to <code>put_flash</code>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309809" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/flash-message-to-disappear-after-5-seconds/32285/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-309809" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309809"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="309846" data-post-id="309846">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sezaru" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sezaru/120/36113_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sezaru
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>So, the way flash mechanism work is that it is a <code>key/value</code> structure.</p>
<p>In other words, that <code>Phoenix.Flash.get(conn.assigns.flash, :info)</code> is searching for a flash with the key <code>:info</code> on it, internally, the function just does a simple <code>Map.get</code> .</p>
<p>This would work with the default flash that comes with phoenix since you create a flash giving it a key like <code>:info</code>, <code>:error</code>, etc and a string as a value.</p>
<p>That’s why you can’t have more than one flash message per key.</p>
<p><code>Flashy</code> leverages the <code>key/value</code> to store strings as the key and a struct that implements the <code>Flashy.Notification.Protocol</code> as the value.</p>
<p>You can look how that works in this file <a href="https://github.com/sezaru/flashy/blob/master/lib/flashy.ex" class="inline-onebox" rel="noopener nofollow ugc">flashy/lib/flashy.ex at master · sezaru/flashy · GitHub</a></p>
<p>If you want to test that, i guess you could mock the <code>:erlang.unique_integer/1</code> function for the test, that way you would have control to how the key is generated during the test.</p>
<p>Or you can also just traverse the <code>conn.assigns.flash</code> map and find the notification there.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309846" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/flash-message-to-disappear-after-5-seconds/32285/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-309846" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309846"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="309848" data-post-id="309848">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="GumptionWare" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/GumptionWare/120/27009_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  GumptionWare
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks, I have abstracted those dynamic values you assign to <code>key</code> (<code>flashy-N</code>) for my testing. I will share some examples once I work through the variations in my current suite of tests.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="309848" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/flash-message-to-disappear-after-5-seconds/32285/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-309848" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="309848"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #18"></div>
  </section>
</div>
    <div class="postbit" id="337694" data-post-id="337694">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="davidmac" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  davidmac
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Here is a solution using hooks. It hides info flash messages after 10 seconds and leaves error flash messages open until the user closes them.</p>
<p>Create a file called hooks.js for your hooks.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">// assets/js/hooks.js
let Hooks = {}

Hooks.HideFlash =  {
  mounted() {
    setTimeout(() =&gt; {
      this.pushEvent("lv:clear-flash", { key: this.el.dataset.key })
      this.el.style.display = "none"
    }, 10000)
  }
}

export default Hooks
</code></pre>
<p>Don’t forget to add your hooks to your liveview socket.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">// assets/js/app.js
// ...
let liveSocket = new LiveSocket("/live", Socket, {
  longPollFallbackMs: 2500,
  params: {_csrf_token: csrfToken},
  hooks: Hooks,
})
// ...
</code></pre>
<p>Add the hook to the flash component.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  # core_components.ex
  def flash(assigns) do
    assigns = assign_new(assigns, :id, fn -&gt; "flash-#{assigns.kind}" end)

    ~H"""
    &lt;div
      :if={msg = render_slot(@inner_block) || Phoenix.Flash.get(@flash, @kind)}
      id={@id}
      phx-hook={@kind == :info &amp;&amp; "HideFlash"}
      phx-click={JS.push("lv:clear-flash", value: %{key: @kind}) |&gt; hide("##{@id}")}
      role="alert"
      class={[
        "fixed top-2 right-2 mx-2 min-w-80 max-w-xl z-50 rounded-lg p-3 ring-1",
        @kind == :info &amp;&amp; "bg-emerald-50 text-emerald-800 ring-emerald-500 fill-cyan-900",
        @kind == :error &amp;&amp; "bg-rose-50 text-rose-900 shadow-md ring-rose-500 fill-rose-900"
      ]}
      {@rest}
    &gt;
      &lt;p :if={@title} class="flex items-center gap-1.5 text-sm font-semibold leading-6"&gt;
        &lt;.icon :if={@kind == :info} name="hero-information-circle-mini" class="h-4 w-4" /&gt;
        &lt;.icon :if={@kind == :error} name="hero-exclamation-circle-mini" class="h-4 w-4" /&gt;
        &lt;%= @title %&gt;
      &lt;/p&gt;
      &lt;pre class="mt-2 text-sm leading-5 whitespace-pre-wrap"&gt;&lt;%= msg %&gt;&lt;/pre&gt;
      &lt;button type="button" class="group absolute top-1 right-1 p-2" aria-label={gettext("close")}&gt;
        &lt;.icon name="hero-x-mark-solid" class="h-5 w-5 opacity-40 group-hover:opacity-70" /&gt;
      &lt;/button&gt;
    &lt;/div&gt;
    """
  end
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="337694" data-batch-url="/posts/batch_likers">
                        10
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/flash-message-to-disappear-after-5-seconds/32285/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-337694" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="337694"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #19"></div>
  </section>
</div>
    <div class="postbit" id="353856" data-post-id="353856">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="z7ealth" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/z7ealth/120/38495_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  z7ealth
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I used <a class="mention" href="/u/sfusato" rel="nofollow">@sfusato</a> solution this way</p>
<pre data-code-wrap="Elixir"><code class="lang-Elixir"># myapp_web.ex
def live_view do
    quote do
      use Phoenix.LiveView,
        layout: {NubacoinsWeb.Layouts, :app}

      unquote(html_helpers())
      unquote(flash_helpers()) # &lt;- Added this line
    end
end

def flash_helpers do
    quote do
      def handle_info(:clear_flash, socket) do
        {:noreply, clear_flash(socket)}
      end
    end
end

# app.html.heex
&lt;.flash_group phx-mount={Process.send_after(self(), :clear_flash, 3000)} flash={@flash} /&gt;
</code></pre>
<p>It worked so far</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="353856" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/flash-message-to-disappear-after-5-seconds/32285/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-353856" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="353856"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #20"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/32285/load_more?page=3">Load more posts (3 remaining)</a>
</div></template></turbo-stream>