Skip to content

Commit

Permalink
fix props type and update questions route
Browse files Browse the repository at this point in the history
  • Loading branch information
yangxqiao committed Apr 23, 2020
1 parent 1bb330e commit 6ef1d6d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
5 changes: 0 additions & 5 deletions src/redux/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,17 @@ const initialState =
questionText: null,
}]


function rootReducer(state = initialState, action) {
if (action.type === 'SAVE_VIDEO') {
return state.map(videoObj => {
// found: update video
if (videoObj.questionID === action.payload.questionID) {
console.log('located ', state)

return action.payload
}
// not the video we are looking for continue
return videoObj

})
}
console.log('returning redux state ', state)
return state
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface Question {

interface Props {
navigation: NavigationScreenProp<NavigationState>,
videos: any,
videos: Array<Record<string, any>>,
}

/* AKA: Q&A screen */
Expand All @@ -31,7 +31,6 @@ function QuestionsScreen(props: Props) {
const [modalVisibility, setModalVisibility] = useState(false)

useEffect(() => {
console.log('VIDEOS in redux: ', props.videos)
fetch(`${BASE_PATH}/api/user/questions`)
.then(res => res.json())
.then(data => {
Expand All @@ -41,7 +40,7 @@ function QuestionsScreen(props: Props) {
.catch(error => {
console.log('Error' + error)
})
}, [])
})

return (
<View style={styles.container}>
Expand All @@ -51,8 +50,6 @@ function QuestionsScreen(props: Props) {
<TouchableHighlight
onPress={() => {
if(item.Answered) {
console.log('VIDEOS in redux alert: ', props.videos)

Alert.alert(
'Edit your Answer clip',
'If you want to change your clip, do it here!',
Expand Down
2 changes: 0 additions & 2 deletions src/screens/Main/RecordStack/RecordScreen/RecordScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,12 @@ function RecordScreen(props: Props) {
}

async function save(){
console.log(video.uri)
const asset = await MediaLibrary.createAssetAsync(video.uri)
if (asset) {
setVideo(null)
}
answerQuestion()
const payload ={'questionID': questionID, 'uri': video.uri, 'questionText': question}
console.log('SAVING: ', payload)
props.dispatch(saveVideo(payload))
pop()
}
Expand Down

0 comments on commit 6ef1d6d

Please sign in to comment.