public static object fetchChannels(int page, bool fetchMessagesAfterSuccess = false, bool joined = true, bool discoverAll = false) { return(new ThunkAction <AppState>((dispatcher, getState) => { dispatcher.dispatch(new StartFetchChannelsAction()); return ChannelApi.FetchChannels(page: page, joined: joined, discoverAll: discoverAll) .Then(channelResponse => { dispatcher.dispatch(new FetchChannelsSuccessAction { discoverList = channelResponse.discoverList ?? new List <string>(), joinedList = channelResponse.joinedList ?? new List <string>(), discoverPage = channelResponse.discoverPage, channelMap = channelResponse.channelMap ?? new Dictionary <string, Channel>(), joinedMemberMap = channelResponse.joinedMemberMap ?? new Dictionary <string, ChannelMember>(), groupMap = channelResponse.groupFullMap ?? new Dictionary <string, Group>(), groupMemberMap = channelResponse.groupMemberMap ?? new Dictionary <string, GroupMember>(), updateJoined = joined, discoverHasMore = channelResponse.discoverHasMore }); if (fetchMessagesAfterSuccess) { channelResponse.joinedList.ForEach(joinedChannelId => { dispatcher.dispatch(fetchChannelMessages(channelId: joinedChannelId)); dispatcher.dispatch(fetchChannelMembers(channelId: joinedChannelId)); }); } }) .Catch(error => { dispatcher.dispatch(new FetchChannelsFailureAction()); Debuger.LogError(message: error); dispatcher.dispatch(loadReadyStateFromDB()); }); })); }
public static object fetchCreateChannelFilter() { return(new ThunkAction <AppState>((dispatcher, getState) => { return ChannelApi.FetchChannels(page: 1, joined: false, discoverAll: true) .Then(channelResponse => { dispatcher.dispatch(new FetchDiscoverChannelFilterSuccessAction { discoverList = channelResponse.discoverList ?? new List <string>() }); }) .Catch(error => { dispatcher.dispatch(new FetchDiscoverChannelFilterFailureAction()); Debuger.LogError(message: error); }); })); }