Allow excluding archived channels in getChannelsBySections (#2871)

This commit is contained in:
Miguel Alatzar 2019-06-06 15:52:10 -07:00 committed by Miguel Alatzar
parent a95fcb3847
commit e1e2d9aedb
3 changed files with 9 additions and 3 deletions

View file

@ -384,7 +384,7 @@ class ShareViewController: SLComposeServiceViewController {
return nil
}
let channelsInTeamBySections = store.getChannelsBySections(forTeamId) as NSDictionary
let channelsInTeamBySections = store.getChannelsBySections(forTeamId, excludeArchived: true) as NSDictionary
channelDecks.append(buildChannelSection(
channels: channelsInTeamBySections.object(forKey: "public") as! NSArray,
currentChannelId: selectedChannel?.id ?? currentChannel?.object(forKey: "id") as! String,

View file

@ -7,7 +7,7 @@
+(instancetype)shared;
-(NSDictionary *)getChannelById:(NSString *)channelId;
-(NSDictionary *)getChannelsBySections:(NSString *)forTeamId;
-(NSDictionary *)getChannelsBySections:(NSString *)forTeamId excludeArchived:(BOOL)excludeArchived;
-(NSDictionary *)getCurrentChannel;
-(NSString *)getCurrentChannelId;
-(NSString *)getCurrentTeamId;

View file

@ -31,7 +31,7 @@
return channel;
}
-(NSDictionary *)getChannelsBySections:(NSString *)forTeamId {
-(NSDictionary *)getChannelsBySections:(NSString *)forTeamId excludeArchived:(BOOL)excludeArchived {
NSDictionary *channelsStore = [self.entities objectForKey:@"channels"];
NSString *currentUserId = [self getCurrentUserId];
NSString *currentChannelId = [self getCurrentChannelId];
@ -44,6 +44,12 @@
for (NSString * key in channels) {
NSMutableDictionary *channel = [[channels objectForKey:key] mutableCopy];
NSNumber *deleteAt = [channel objectForKey:@"delete_at"];
if (excludeArchived && ![deleteAt isEqualToNumber:@0]) {
continue;
}
NSString *team_id = [channel objectForKey:@"team_id"];
NSString *channelType = [channel objectForKey:@"type"];
BOOL isDM = [channelType isEqualToString:@"D"];