refactor: Improve article loading error and cache messages

This commit is contained in:
2025-11-21 22:45:54 +00:00
committed by Tanner Collin (aider)
parent 15aa413584
commit a21c84efc6

View File

@@ -36,7 +36,7 @@ function Article({ cache }) {
localForage.setItem(id, result.story); localForage.setItem(id, result.story);
}, },
(error) => { (error) => {
const errorMessage = `Failed to fetch article content (ID: ${id}). Your connection may be down or the server might be experiencing issues. ${error.toString()}.`; const errorMessage = `Failed to fetch new article content (ID: ${id}). Your connection may be down or the server might be experiencing issues. ${error.toString()}.`;
setError(errorMessage); setError(errorMessage);
} }
); );
@@ -60,6 +60,7 @@ function Article({ cache }) {
<details style={{marginBottom: '1rem', visibility: error ? 'visible' : 'hidden'}}> <details style={{marginBottom: '1rem', visibility: error ? 'visible' : 'hidden'}}>
<summary>Connection error? Click to expand.</summary> <summary>Connection error? Click to expand.</summary>
<p>{error}</p> <p>{error}</p>
{story && <p>Loaded article from cache.</p>}
</details> </details>
{story ? {story ?
<div className='article'> <div className='article'>
@@ -101,7 +102,7 @@ function Article({ cache }) {
} }
</div> </div>
: :
<p>loading...</p> <p>Loading...</p>
} }
<ToggleDot id={id} article={false} /> <ToggleDot id={id} article={false} />
</div> </div>