89 lines
5 KiB
Java
89 lines
5 KiB
Java
package com.discord.widgets.servers;
|
|
|
|
import com.discord.api.role.GuildRole;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.models.member.GuildMember;
|
|
import com.discord.models.user.MeUser;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.guilds.RoleUtils;
|
|
import com.discord.utilities.permissions.PermissionUtils;
|
|
import com.discord.widgets.servers.WidgetServerSettingsRolesList;
|
|
import com.discord.widgets.servers.WidgetServerSettingsRolesListAdapter;
|
|
import d0.t.m;
|
|
import j0.k.b;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Map;
|
|
import rx.Observable;
|
|
import rx.functions.Func4;
|
|
/* compiled from: WidgetServerSettingsRolesList.kt */
|
|
public final class WidgetServerSettingsRolesList$Model$Companion$get$1<T, R> implements b<MeUser, Observable<? extends WidgetServerSettingsRolesList.Model>> {
|
|
public final /* synthetic */ long $guildId;
|
|
|
|
/* compiled from: WidgetServerSettingsRolesList.kt */
|
|
/* renamed from: com.discord.widgets.servers.WidgetServerSettingsRolesList$Model$Companion$get$1$1 reason: invalid class name */
|
|
public static final class AnonymousClass1<T, R> implements b<Map<Long, ? extends GuildMember>, GuildMember> {
|
|
public final /* synthetic */ MeUser $meUser;
|
|
|
|
public AnonymousClass1(MeUser meUser) {
|
|
this.$meUser = meUser;
|
|
}
|
|
|
|
public final GuildMember call(Map<Long, GuildMember> map) {
|
|
return map.get(Long.valueOf(this.$meUser.getId()));
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // j0.k.b
|
|
public /* bridge */ /* synthetic */ GuildMember call(Map<Long, ? extends GuildMember> map) {
|
|
return call((Map<Long, GuildMember>) map);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetServerSettingsRolesList.kt */
|
|
/* renamed from: com.discord.widgets.servers.WidgetServerSettingsRolesList$Model$Companion$get$1$2 reason: invalid class name */
|
|
public static final class AnonymousClass2<T1, T2, T3, T4, R> implements Func4<Guild, GuildMember, Long, Map<Long, ? extends GuildRole>, WidgetServerSettingsRolesList.Model> {
|
|
public final /* synthetic */ MeUser $meUser;
|
|
public final /* synthetic */ WidgetServerSettingsRolesList$Model$Companion$get$1 this$0;
|
|
|
|
public AnonymousClass2(WidgetServerSettingsRolesList$Model$Companion$get$1 widgetServerSettingsRolesList$Model$Companion$get$1, MeUser meUser) {
|
|
this.this$0 = widgetServerSettingsRolesList$Model$Companion$get$1;
|
|
this.$meUser = meUser;
|
|
}
|
|
|
|
public final WidgetServerSettingsRolesList.Model call(Guild guild, GuildMember guildMember, Long l, Map<Long, GuildRole> map) {
|
|
if (guild == null || guildMember == null || l == null || map == null) {
|
|
return null;
|
|
}
|
|
boolean can = PermissionUtils.can(268435456, l);
|
|
boolean isElevated = PermissionUtils.isElevated(this.$meUser.getMfaEnabled(), guild.getMfaLevel());
|
|
GuildRole highestRole = RoleUtils.getHighestRole(map, guildMember);
|
|
ArrayList<GuildRole> arrayList = new ArrayList(map.values());
|
|
Collections.sort(arrayList, RoleUtils.getROLE_COMPARATOR());
|
|
ArrayList arrayList2 = new ArrayList(arrayList.size() + 1);
|
|
arrayList2.add(new WidgetServerSettingsRolesListAdapter.HelpItem(this.this$0.$guildId));
|
|
for (GuildRole guildRole : arrayList) {
|
|
arrayList2.add(new WidgetServerSettingsRolesListAdapter.RoleItem(guildRole, this.this$0.$guildId == guildRole.getId(), guild.getOwnerId() != this.$meUser.getId() && !RoleUtils.rankIsHigher(highestRole, guildRole), can, isElevated));
|
|
}
|
|
return new WidgetServerSettingsRolesList.Model(this.this$0.$guildId, guild.getName(), can, isElevated, arrayList2);
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object] */
|
|
@Override // rx.functions.Func4
|
|
public /* bridge */ /* synthetic */ WidgetServerSettingsRolesList.Model call(Guild guild, GuildMember guildMember, Long l, Map<Long, ? extends GuildRole> map) {
|
|
return call(guild, guildMember, l, (Map<Long, GuildRole>) map);
|
|
}
|
|
}
|
|
|
|
public WidgetServerSettingsRolesList$Model$Companion$get$1(long j) {
|
|
this.$guildId = j;
|
|
}
|
|
|
|
public final Observable<? extends WidgetServerSettingsRolesList.Model> call(MeUser meUser) {
|
|
StoreStream.Companion companion = StoreStream.Companion;
|
|
return Observable.h(companion.getGuilds().observeGuild(this.$guildId), companion.getGuilds().observeComputed(this.$guildId, m.listOf(Long.valueOf(meUser.getId()))).F(new AnonymousClass1(meUser)), companion.getPermissions().observePermissionsForGuild(this.$guildId), companion.getGuilds().observeRoles(this.$guildId), new AnonymousClass2(this, meUser));
|
|
}
|
|
}
|