Skip to content

Commit

Permalink
Merge pull request #101 from akameco/fix-new
Browse files Browse the repository at this point in the history
検索新着修正
  • Loading branch information
akameco authored Jul 12, 2017
2 parents ecbd1e5 + baeaa4c commit 7c86d63
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions app/containers/ColumnSearch/saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,34 +73,33 @@ function* fetchUntilLimit(action: Action): Generator<*, void, *> {
}
}

function* fetchNew(action: Action): Generator<*, void, *> {
function* fetchNew({ id }: Action): Generator<*, void, *> {
try {
const { ids } = yield select(selectors.makeSelectColumn(), action)
const beforeIds = yield select(
selectors.makeLimitedSelectIllustsId(),
action
)
const { ids, usersIn } = yield select(selectors.makeSelectColumn(), { id })
const beforeIds = yield select(selectors.makeLimitedSelectIllustsId(), {
id,
})

const endpoint = getEndpoint(action.id)
const fomattedWord = usersIn === 0 ? id : `${id}${usersIn}users入り`
const endpoint = getEndpoint(fomattedWord)

const { result } = yield call(api.get, endpoint, true)

const nextIds = union(result.illusts, ids)
yield put(actions.fetchNewSuccess(action.id, nextIds))
yield put(actions.fetchNewSuccess(id, nextIds))

const afterIds = yield select(
selectors.makeLimitedSelectIllustsId(),
action
)
const afterIds = yield select(selectors.makeLimitedSelectIllustsId(), {
id,
})

const diffIllusts = difference(afterIds, beforeIds)
if (diffIllusts.length > 0) {
for (const illustId of diffIllusts) {
yield put(addNotifyWithIllust(`検索新着 ${action.id} イラスト`, illustId))
yield put(addNotifyWithIllust(`検索新着 ${id} イラスト`, illustId))
}
}
} catch (err) {
yield put(actions.fetchNewFailre(action.id, err))
yield put(actions.fetchNewFailre(id, err))
}
}

Expand Down

0 comments on commit 7c86d63

Please sign in to comment.