forked from tanner/qotnews
feat: Persist new stories and improve layout consistency
This commit is contained in:
@@ -57,11 +57,13 @@ function Article({ cache }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='article-container'>
|
<div className='article-container'>
|
||||||
{error &&
|
{error ?
|
||||||
<details style={{marginBottom: '1rem'}}>
|
<details style={{marginBottom: '1rem'}}>
|
||||||
<summary>Connection error? Click to expand.</summary>
|
<summary>Connection error? Click to expand.</summary>
|
||||||
<p>{error}</p>
|
<p>{error}</p>
|
||||||
</details>
|
</details>
|
||||||
|
:
|
||||||
|
<div style={{marginBottom: '2rem'}}></div>
|
||||||
}
|
}
|
||||||
{story ?
|
{story ?
|
||||||
<div className='article'>
|
<div className='article'>
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ function Feed({ updateCache }) {
|
|||||||
currentStories.splice(existingStoryIndex, 1);
|
currentStories.splice(existingStoryIndex, 1);
|
||||||
}
|
}
|
||||||
currentStories.unshift(newStory);
|
currentStories.unshift(newStory);
|
||||||
|
|
||||||
|
localStorage.setItem('stories', JSON.stringify(currentStories));
|
||||||
|
setStories(currentStories);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let errorMessage;
|
let errorMessage;
|
||||||
if (error.name === 'AbortError') {
|
if (error.name === 'AbortError') {
|
||||||
|
|||||||
Reference in New Issue
Block a user