Skip to content

Add option to make storage persistent to Offline page. - #1274

Merged
simon04 merged 4 commits into
freeCodeCamp:mainfrom
pwnall:add-persistence
Sep 14, 2026
Merged

simon04 merged 4 commits into
freeCodeCamp:mainfrom
pwnall:add-persistence

Conversation

@pwnall

@pwnall pwnall commented Sep 14, 2020

Copy link
Copy Markdown
Contributor

Fixes #703

I tested this manually and it works for me in Chrome.

I looked around a bit and focused on getting something working. I probably got the architecture bits wrong -- I'd be happy to update my PR in response to architectural feedback.

I hope this helps!

@Chukwujiobi-Canon

Copy link
Copy Markdown

Fixes #703

I tested this manually and it works for me in Chrome.

I looked around a bit and focused on getting something working. I probably got the architecture bits wrong -- I'd be happy to update my PR in response to architectural feedback.

I hope this helps!

What do you think of also adding sign up feature to enable user saved data persist even when caches are cleared
Eg enabled docs staying enabled

pwnall and others added 4 commits September 14, 2026 08:39
The preceding commit was transliterated from CoffeeScript, which main
has since converted to JavaScript. These three defects come from the
original and are fixed here rather than silently during the port:

  * the persistence note added one more </div> than it opened
  * checkPersistence's catch handler passed `persisted`, which is only
    bound inside the then handler, so a rejected persisted() raised a
    ReferenceError instead of reporting that persistence is unavailable
  * the button's class attribute was written `class =`
navigator.storage.persist() resolves false without raising whenever the
browser declines -- Chrome when its heuristics are unmet, Firefox when
the prompt is dismissed -- so the denial path is one users hit in the
course of normal use, not an exceptional one.

Rendering it through the page-level error template replaced the whole
view, discarding the documentation table, so a declined request left no
way back other than navigating away and returning. Write the outcome to
the #_offline-persistence-note container the note already carries an id
for, and style the message as an inline note: ._error is centred with
position: absolute and cannot be nested.
Querying persistence made render() finish asynchronously, so the
this.activated check it performs beforehand no longer holds by the time
the page is written. Re-check it in both callbacks, as the surrounding
install callbacks already do.
@simon04
simon04 requested a review from a team as a code owner September 14, 2026 06:40

@simon04 simon04 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@simon04
simon04 merged commit 25785f3 into freeCodeCamp:main Sep 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to make offline storage persistent

3 participants