return async ({ dispatch, getState }) => { const token = await dispatch(getFeedlyToken()); const contents = await feedlyApi.getStreamContents(token.access_token, { streamId, count: fetchOptions.numEntries, ranked: fetchOptions.entryOrder, unreadOnly: fetchOptions.onlyUnread }); const { categories } = getState(); const category = categories.items[streamId] || null; const stream: Stream = { streamId, title: category ? category.label : '', fetchedAt, entries: contents.items.map(convertEntry), continuation: contents.continuation || null, feed: null, fetchOptions }; return stream; };
return async ({ dispatch }) => { const token = await dispatch(getFeedlyToken()); const streamId = pinsStreamIdOf(token.id); const contents = await feedlyApi.getStreamContents(token.access_token, { streamId, count: fetchOptions.numEntries, ranked: fetchOptions.entryOrder, unreadOnly: fetchOptions.onlyUnread }); const stream: Stream = { streamId: PINS_STREAM_ID, title: 'Pins', entries: contents.items.map(convertEntry), fetchedAt, continuation: contents.continuation || null, feed: null, fetchOptions }; dispatch({ type: 'STREAM_FETCHED', stream }); return stream; };
return async ({ dispatch }) => { dispatch({ type: 'MORE_ENTRIES_FETCHING', streamId }); let entries: Entry[] = []; try { const token = await dispatch(getFeedlyToken()); const feedlyStreamId = toFeedlyStreamId(streamId, token.id); const contents = await feedlyApi.getStreamContents(token.access_token, { streamId: feedlyStreamId, continuation, count: fetchOptions.numEntries, ranked: fetchOptions.entryOrder, unreadOnly: fetchOptions.onlyUnread }); entries = contents.items.map(convertEntry); dispatch({ type: 'MORE_ENTRIES_FETCHED', streamId, entries, continuation: contents.continuation || null }); } catch (error) { dispatch({ type: 'MORE_ENTRIES_FETCHING_FAILED', streamId }); throw error; } const urls = entries .filter((entry) => !!entry.url) .map((entry) => entry.url); const expandedUrls = await dispatch(expandUrls(urls)); await dispatch(fetchBookmarkCounts(expandedUrls)); };
return async ({ dispatch }) => { const token = await dispatch(getFeedlyToken()); const [contents, feed] = await Promise.all([ feedlyApi.getStreamContents(token.access_token, { streamId, count: fetchOptions.numEntries, ranked: fetchOptions.entryOrder, unreadOnly: fetchOptions.onlyUnread }), feedlyApi.getFeed(token.access_token, streamId) ]); const stream = { streamId, category: null, title: feed.title || feed.website || feed.id.replace(/^feed\//, ''), fetchedAt, entries: contents.items.map(convertEntry), continuation: contents.continuation || null, feed: { feedId: feed.id, streamId: feed.id, title: feed.title, description: feed.description || '', url: feed.website || '', feedUrl: feed.id.replace(/^feed\//, ''), iconUrl: feed.iconUrl || '', subscribers: feed.subscribers || 0, isLoading: false }, fetchOptions }; return stream; };