Skip to content

publish/privacy-toggle button failing without hard refresh #272

@toldandretold

Description

@toldandretold

the "publish" button id=privacy-toggle

<button id="privacy-toggle" data-is-private="true" style="position: absolute; top: 10px; right: 10px; z-index: 1002;" title="Book is Private - Click to make public">
      <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#d73a49" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
  <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
</svg>
    </button>

inside the

<div id="source-container">

in

@resources/views/reader.blade.php

sometimes does not work until user refreshes the page.

The button is designed to make a book either public or private. when private, it is a red lock icon. when public a green earth.

It can be observed for testing by creating a new book, or opening one that is owned/createdby user's account.

Then, click the cloudRef button at top right.

problem

Button often doesn't work until refresh page.

Reproduce problem: navigate through SPA pathways (clicking home butotn then back button, or any pathway that doesn't take a hard refresh) then, does the publish button work?

Note, it will change from one state to another visually, but may not have actaully changed the books status from private to public.

To confirm if it has worked: either refresh page to see if state is still changed. Or, go to library data table in postgresql for that book, and see if the visibility column has changed from public to private or vice versa

likely cause

The fact that it works after page refresh indicates its a problem of button initialisation or de-initialisation during the SPA pathways.

likely solution (USE THE STANDARD SYSTEM)

To fix, that means integrating this buttons event listener initialisation with the standard

@resources/js/utilities/buttonRegistry.js system.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions