-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into google-login-new-…
…version
- Loading branch information
Showing
71 changed files
with
745 additions
and
819 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import { concat } from 'ramda'; | ||
import { getError, getFetched, toFetching, isFetching } from 'utils/fetchBox'; | ||
import { relatedExperiencesStateSelector } from 'selectors/experienceSelector'; | ||
|
||
export const SET_RELATED_EXPERIENCES = '@@EXPERIENCE/SET_RELATED_EXPERIENCES'; | ||
|
||
const setRelatedExperiencesState = relatedExperiencesState => ({ | ||
type: SET_RELATED_EXPERIENCES, | ||
relatedExperiencesState, | ||
}); | ||
|
||
export const queryRelatedExperiencesOnExperience = experienceId => async ( | ||
dispatch, | ||
getState, | ||
{ api }, | ||
) => { | ||
const page = 0; | ||
|
||
dispatch( | ||
setRelatedExperiencesState( | ||
// this is an work around | ||
toFetching({ | ||
data: { | ||
experienceId, | ||
page, | ||
relatedExperiences: [], | ||
hasMore: false, | ||
}, | ||
}), | ||
), | ||
); | ||
|
||
try { | ||
const relatedExperiences = await api.experiences.queryRelatedExperiences({ | ||
id: experienceId, | ||
start: page * 5, | ||
limit: 5, | ||
}); | ||
|
||
const previousState = relatedExperiencesStateSelector(getState()); // FetchBox | ||
|
||
if ( | ||
experienceId === previousState.data.experienceId && | ||
page === previousState.data.page | ||
) { | ||
const hasMore = relatedExperiences.length < 5 ? false : true; | ||
|
||
dispatch( | ||
setRelatedExperiencesState( | ||
getFetched({ | ||
experienceId, | ||
page, | ||
relatedExperiences, | ||
hasMore, | ||
}), | ||
), | ||
); | ||
} | ||
} catch (error) { | ||
dispatch(setRelatedExperiencesState(getError(error))); | ||
} | ||
}; | ||
|
||
export const loadMoreRelatedExperiences = () => async ( | ||
dispatch, | ||
getState, | ||
{ api }, | ||
) => { | ||
const state = relatedExperiencesStateSelector(getState()); // FetchBox | ||
|
||
// 判斷 isFetching | ||
if (isFetching(state)) { | ||
return; | ||
} | ||
|
||
const experienceId = state.data.experienceId; | ||
const page = state.data.page + 1; | ||
|
||
dispatch( | ||
setRelatedExperiencesState( | ||
// this is an work around | ||
toFetching({ | ||
data: { | ||
experienceId, | ||
page, | ||
relatedExperiences: state.data.relatedExperiences, | ||
hasMore: false, | ||
}, | ||
}), | ||
), | ||
); | ||
|
||
try { | ||
const relatedExperiences = await api.experiences.queryRelatedExperiences({ | ||
id: experienceId, | ||
start: page * 5, | ||
limit: 5, | ||
}); | ||
|
||
const previousState = relatedExperiencesStateSelector(getState()); // FetchBox | ||
|
||
if ( | ||
experienceId === previousState.data.experienceId && | ||
page === previousState.data.page | ||
) { | ||
const hasMore = relatedExperiences.length < 5 ? false : true; | ||
|
||
dispatch( | ||
setRelatedExperiencesState( | ||
getFetched({ | ||
experienceId, | ||
page, | ||
relatedExperiences: concat( | ||
previousState.data.relatedExperiences, | ||
relatedExperiences, | ||
), | ||
hasMore, | ||
}), | ||
), | ||
); | ||
} | ||
} catch (error) { | ||
const previousState = relatedExperiencesStateSelector(getState()); // FetchBox | ||
|
||
if ( | ||
experienceId === previousState.data.experienceId && | ||
page === previousState.data.page | ||
) { | ||
dispatch(setRelatedExperiencesState(getError(error))); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ | |
} | ||
|
||
.logo { | ||
fill: #fff; | ||
filter: invert(1); | ||
width: 120px; | ||
margin-right: 8px; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.