-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(fetch story): display story data in sidepanel #166
Conversation
import {languageSelector} from '../reducers/language'; | ||
|
||
import {State} from '../reducers/index'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line
} | ||
const StoryItem: FunctionComponent<Props> = ({story}) => ( | ||
<Link to={`/stories/${story.id}`}> | ||
<Link to={`/stories/${story.id}/0`}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the /0
now because of the redirect. We don't have to but it looks cleaner :)
useEffect(() => { | ||
storyId && dispatch(fetchStory(storyId)); | ||
}, [storyId, dispatch]); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just saw that we also have to check here if currently loaded story id and storyId
from the url are the same. If not we shouldn't render the story. This could happen when someone would switch from one story directly to another. This way the old story is still in the store until the new one if fetched from the server.
import globeReducer from './globe'; | ||
|
||
const rootReducer = combineReducers({ | ||
language: languageReducer, | ||
layers: layersReducer, | ||
stories: storiesReducer, | ||
story: storyReducer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move all the story related stuff in a subreducer in another PR
src/scripts/reducers/stories.ts
Outdated
import {State} from './index'; | ||
|
||
export type StoriesState = Story[]; | ||
export type StoriesState = StoriesItem[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please rename this to StoryList
and StoryListItem
and use StoryList
everywhere instead of StoriesItem[]
No description provided.