799 lines
32 KiB
Java
799 lines
32 KiB
Java
package com.discord.widgets.settings;
|
|
|
|
import a0.a.a.b;
|
|
import android.content.Context;
|
|
import androidx.annotation.MainThread;
|
|
import b.d.b.a.a;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.channel.ChannelUtils;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.models.domain.ModelMuteConfig;
|
|
import com.discord.models.domain.ModelNotificationSettings;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.stores.StoreChannels;
|
|
import com.discord.stores.StoreGuilds;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.StoreThreadsJoined;
|
|
import com.discord.stores.StoreUserGuildSettings;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.time.Clock;
|
|
import com.discord.utilities.time.ClockFactory;
|
|
import com.discord.utilities.time.TimeUtils;
|
|
import com.discord.widgets.chat.input.MentionUtilsKt;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
import rx.subjects.PublishSubject;
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
public final class MuteSettingsSheetViewModel extends AppViewModel<ViewState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final long MUTE_DURATION_ALWAYS = 0;
|
|
private final long channelId;
|
|
private final Clock clock;
|
|
private final Config config;
|
|
private final PublishSubject<Event> eventSubject;
|
|
private final long guildId;
|
|
private final Observable<StoreState> storeStateObservable;
|
|
private final StoreUserGuildSettings storeUserGuildSettings;
|
|
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
/* renamed from: com.discord.widgets.settings.MuteSettingsSheetViewModel$1 reason: invalid class name */
|
|
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
|
|
public final /* synthetic */ MuteSettingsSheetViewModel this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public AnonymousClass1(MuteSettingsSheetViewModel muteSettingsSheetViewModel) {
|
|
super(1);
|
|
this.this$0 = muteSettingsSheetViewModel;
|
|
}
|
|
|
|
/* 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 // kotlin.jvm.functions.Function1
|
|
public /* bridge */ /* synthetic */ Unit invoke(StoreState storeState) {
|
|
invoke(storeState);
|
|
return Unit.a;
|
|
}
|
|
|
|
public final void invoke(StoreState storeState) {
|
|
m.checkNotNullParameter(storeState, "storeState");
|
|
MuteSettingsSheetViewModel.access$handleStoreState(this.this$0, storeState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ Observable access$observeStoreState(Companion companion, long j, long j2, StoreGuilds storeGuilds, StoreChannels storeChannels, StoreUserGuildSettings storeUserGuildSettings, StoreThreadsJoined storeThreadsJoined) {
|
|
return companion.observeStoreState(j, j2, storeGuilds, storeChannels, storeUserGuildSettings, storeThreadsJoined);
|
|
}
|
|
|
|
private final Observable<StoreState> observeStoreState(long j, long j2, StoreGuilds storeGuilds, StoreChannels storeChannels, StoreUserGuildSettings storeUserGuildSettings, StoreThreadsJoined storeThreadsJoined) {
|
|
Observable<StoreState> h = Observable.h(storeGuilds.observeGuild(j), storeChannels.observeChannel(j2), storeUserGuildSettings.observeGuildSettings(), storeThreadsJoined.observeJoinedThread(j2), MuteSettingsSheetViewModel$Companion$observeStoreState$1.INSTANCE);
|
|
m.checkNotNullExpressionValue(h, "Observable.combineLatest…dThread\n )\n }");
|
|
return h;
|
|
}
|
|
}
|
|
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
public static abstract class Config {
|
|
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
public static final class Channel extends Config {
|
|
private final long channelId;
|
|
|
|
public Channel(long j) {
|
|
super(null);
|
|
this.channelId = j;
|
|
}
|
|
|
|
public static /* synthetic */ Channel copy$default(Channel channel, long j, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
j = channel.channelId;
|
|
}
|
|
return channel.copy(j);
|
|
}
|
|
|
|
public final long component1() {
|
|
return this.channelId;
|
|
}
|
|
|
|
public final Channel copy(long j) {
|
|
return new Channel(j);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof Channel) && this.channelId == ((Channel) obj).channelId;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final long getChannelId() {
|
|
return this.channelId;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return b.a(this.channelId);
|
|
}
|
|
|
|
public String toString() {
|
|
return a.B(a.R("Channel(channelId="), this.channelId, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
public static final class Guild extends Config {
|
|
private final long guildId;
|
|
|
|
public Guild(long j) {
|
|
super(null);
|
|
this.guildId = j;
|
|
}
|
|
|
|
public static /* synthetic */ Guild copy$default(Guild guild, long j, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
j = guild.guildId;
|
|
}
|
|
return guild.copy(j);
|
|
}
|
|
|
|
public final long component1() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final Guild copy(long j) {
|
|
return new Guild(j);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof Guild) && this.guildId == ((Guild) obj).guildId;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final long getGuildId() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return b.a(this.guildId);
|
|
}
|
|
|
|
public String toString() {
|
|
return a.B(a.R("Guild(guildId="), this.guildId, ")");
|
|
}
|
|
}
|
|
|
|
private Config() {
|
|
}
|
|
|
|
public /* synthetic */ Config(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
public static abstract class Event {
|
|
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
public static final class Dismiss extends Event {
|
|
public static final Dismiss INSTANCE = new Dismiss();
|
|
|
|
private Dismiss() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
public static final class NavigateToChannelSettings extends Event {
|
|
private final long channelId;
|
|
|
|
public NavigateToChannelSettings(long j) {
|
|
super(null);
|
|
this.channelId = j;
|
|
}
|
|
|
|
public static /* synthetic */ NavigateToChannelSettings copy$default(NavigateToChannelSettings navigateToChannelSettings, long j, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
j = navigateToChannelSettings.channelId;
|
|
}
|
|
return navigateToChannelSettings.copy(j);
|
|
}
|
|
|
|
public final long component1() {
|
|
return this.channelId;
|
|
}
|
|
|
|
public final NavigateToChannelSettings copy(long j) {
|
|
return new NavigateToChannelSettings(j);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof NavigateToChannelSettings) && this.channelId == ((NavigateToChannelSettings) obj).channelId;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final long getChannelId() {
|
|
return this.channelId;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return b.a(this.channelId);
|
|
}
|
|
|
|
public String toString() {
|
|
return a.B(a.R("NavigateToChannelSettings(channelId="), this.channelId, ")");
|
|
}
|
|
}
|
|
|
|
private Event() {
|
|
}
|
|
|
|
public /* synthetic */ Event(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
public enum SettingsType {
|
|
GUILD,
|
|
DM,
|
|
GROUP_DM,
|
|
THREAD,
|
|
GUILD_CHANNEL,
|
|
CATEGORY,
|
|
UNKNOWN
|
|
}
|
|
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
public static final class StoreState {
|
|
private final Channel channel;
|
|
private final Guild guild;
|
|
private final ModelNotificationSettings guildNotificationSettings;
|
|
private final StoreThreadsJoined.JoinedThread joinedThread;
|
|
|
|
public StoreState(Guild guild, Channel channel, ModelNotificationSettings modelNotificationSettings, StoreThreadsJoined.JoinedThread joinedThread) {
|
|
this.guild = guild;
|
|
this.channel = channel;
|
|
this.guildNotificationSettings = modelNotificationSettings;
|
|
this.joinedThread = joinedThread;
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ StoreState(Guild guild, Channel channel, ModelNotificationSettings modelNotificationSettings, StoreThreadsJoined.JoinedThread joinedThread, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(guild, channel, (i & 4) != 0 ? null : modelNotificationSettings, joinedThread);
|
|
}
|
|
|
|
public static /* synthetic */ StoreState copy$default(StoreState storeState, Guild guild, Channel channel, ModelNotificationSettings modelNotificationSettings, StoreThreadsJoined.JoinedThread joinedThread, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
guild = storeState.guild;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
channel = storeState.channel;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
modelNotificationSettings = storeState.guildNotificationSettings;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
joinedThread = storeState.joinedThread;
|
|
}
|
|
return storeState.copy(guild, channel, modelNotificationSettings, joinedThread);
|
|
}
|
|
|
|
public final Guild component1() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final Channel component2() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final ModelNotificationSettings component3() {
|
|
return this.guildNotificationSettings;
|
|
}
|
|
|
|
public final StoreThreadsJoined.JoinedThread component4() {
|
|
return this.joinedThread;
|
|
}
|
|
|
|
public final StoreState copy(Guild guild, Channel channel, ModelNotificationSettings modelNotificationSettings, StoreThreadsJoined.JoinedThread joinedThread) {
|
|
return new StoreState(guild, channel, modelNotificationSettings, joinedThread);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof StoreState)) {
|
|
return false;
|
|
}
|
|
StoreState storeState = (StoreState) obj;
|
|
return m.areEqual(this.guild, storeState.guild) && m.areEqual(this.channel, storeState.channel) && m.areEqual(this.guildNotificationSettings, storeState.guildNotificationSettings) && m.areEqual(this.joinedThread, storeState.joinedThread);
|
|
}
|
|
|
|
public final Channel getChannel() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final Guild getGuild() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final ModelNotificationSettings getGuildNotificationSettings() {
|
|
return this.guildNotificationSettings;
|
|
}
|
|
|
|
public final StoreThreadsJoined.JoinedThread getJoinedThread() {
|
|
return this.joinedThread;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Guild guild = this.guild;
|
|
int i = 0;
|
|
int hashCode = (guild != null ? guild.hashCode() : 0) * 31;
|
|
Channel channel = this.channel;
|
|
int hashCode2 = (hashCode + (channel != null ? channel.hashCode() : 0)) * 31;
|
|
ModelNotificationSettings modelNotificationSettings = this.guildNotificationSettings;
|
|
int hashCode3 = (hashCode2 + (modelNotificationSettings != null ? modelNotificationSettings.hashCode() : 0)) * 31;
|
|
StoreThreadsJoined.JoinedThread joinedThread = this.joinedThread;
|
|
if (joinedThread != null) {
|
|
i = joinedThread.hashCode();
|
|
}
|
|
return hashCode3 + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder R = a.R("StoreState(guild=");
|
|
R.append(this.guild);
|
|
R.append(", channel=");
|
|
R.append(this.channel);
|
|
R.append(", guildNotificationSettings=");
|
|
R.append(this.guildNotificationSettings);
|
|
R.append(", joinedThread=");
|
|
R.append(this.joinedThread);
|
|
R.append(")");
|
|
return R.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
public static abstract class ViewState {
|
|
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
public static final class Failure extends ViewState {
|
|
public static final Failure INSTANCE = new Failure();
|
|
|
|
private Failure() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
public static final class Loaded extends ViewState {
|
|
private final boolean isChannelMuted;
|
|
private final boolean isGuildMuted;
|
|
private final String muteEndTime;
|
|
private final int notificationSetting;
|
|
private final SettingsType settingsType;
|
|
private final String subtitle;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Loaded(SettingsType settingsType, String str, boolean z2, boolean z3, String str2, int i) {
|
|
super(null);
|
|
m.checkNotNullParameter(settingsType, "settingsType");
|
|
m.checkNotNullParameter(str, "subtitle");
|
|
this.settingsType = settingsType;
|
|
this.subtitle = str;
|
|
this.isChannelMuted = z2;
|
|
this.isGuildMuted = z3;
|
|
this.muteEndTime = str2;
|
|
this.notificationSetting = i;
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ Loaded(SettingsType settingsType, String str, boolean z2, boolean z3, String str2, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(settingsType, str, (i2 & 4) != 0 ? false : z2, (i2 & 8) != 0 ? false : z3, (i2 & 16) != 0 ? null : str2, (i2 & 32) != 0 ? ModelNotificationSettings.FREQUENCY_UNSET : i);
|
|
}
|
|
|
|
public static /* synthetic */ Loaded copy$default(Loaded loaded, SettingsType settingsType, String str, boolean z2, boolean z3, String str2, int i, int i2, Object obj) {
|
|
if ((i2 & 1) != 0) {
|
|
settingsType = loaded.settingsType;
|
|
}
|
|
if ((i2 & 2) != 0) {
|
|
str = loaded.subtitle;
|
|
}
|
|
if ((i2 & 4) != 0) {
|
|
z2 = loaded.isChannelMuted;
|
|
}
|
|
if ((i2 & 8) != 0) {
|
|
z3 = loaded.isGuildMuted;
|
|
}
|
|
if ((i2 & 16) != 0) {
|
|
str2 = loaded.muteEndTime;
|
|
}
|
|
if ((i2 & 32) != 0) {
|
|
i = loaded.notificationSetting;
|
|
}
|
|
return loaded.copy(settingsType, str, z2, z3, str2, i);
|
|
}
|
|
|
|
public final SettingsType component1() {
|
|
return this.settingsType;
|
|
}
|
|
|
|
public final String component2() {
|
|
return this.subtitle;
|
|
}
|
|
|
|
public final boolean component3() {
|
|
return this.isChannelMuted;
|
|
}
|
|
|
|
public final boolean component4() {
|
|
return this.isGuildMuted;
|
|
}
|
|
|
|
public final String component5() {
|
|
return this.muteEndTime;
|
|
}
|
|
|
|
public final int component6() {
|
|
return this.notificationSetting;
|
|
}
|
|
|
|
public final Loaded copy(SettingsType settingsType, String str, boolean z2, boolean z3, String str2, int i) {
|
|
m.checkNotNullParameter(settingsType, "settingsType");
|
|
m.checkNotNullParameter(str, "subtitle");
|
|
return new Loaded(settingsType, str, z2, z3, str2, i);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Loaded)) {
|
|
return false;
|
|
}
|
|
Loaded loaded = (Loaded) obj;
|
|
return m.areEqual(this.settingsType, loaded.settingsType) && m.areEqual(this.subtitle, loaded.subtitle) && this.isChannelMuted == loaded.isChannelMuted && this.isGuildMuted == loaded.isGuildMuted && m.areEqual(this.muteEndTime, loaded.muteEndTime) && this.notificationSetting == loaded.notificationSetting;
|
|
}
|
|
|
|
public final String getMuteEndTime() {
|
|
return this.muteEndTime;
|
|
}
|
|
|
|
public final int getNotificationSetting() {
|
|
return this.notificationSetting;
|
|
}
|
|
|
|
public final SettingsType getSettingsType() {
|
|
return this.settingsType;
|
|
}
|
|
|
|
public final String getSubtitle() {
|
|
return this.subtitle;
|
|
}
|
|
|
|
public int hashCode() {
|
|
SettingsType settingsType = this.settingsType;
|
|
int i = 0;
|
|
int hashCode = (settingsType != null ? settingsType.hashCode() : 0) * 31;
|
|
String str = this.subtitle;
|
|
int hashCode2 = (hashCode + (str != null ? str.hashCode() : 0)) * 31;
|
|
boolean z2 = this.isChannelMuted;
|
|
int i2 = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = z2 ? 1 : 0;
|
|
int i6 = (hashCode2 + i3) * 31;
|
|
boolean z3 = this.isGuildMuted;
|
|
if (!z3) {
|
|
i2 = z3 ? 1 : 0;
|
|
}
|
|
int i7 = (i6 + i2) * 31;
|
|
String str2 = this.muteEndTime;
|
|
if (str2 != null) {
|
|
i = str2.hashCode();
|
|
}
|
|
return ((i7 + i) * 31) + this.notificationSetting;
|
|
}
|
|
|
|
public final boolean isChannelMuted() {
|
|
return this.isChannelMuted;
|
|
}
|
|
|
|
public final boolean isGuildMuted() {
|
|
return this.isGuildMuted;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder R = a.R("Loaded(settingsType=");
|
|
R.append(this.settingsType);
|
|
R.append(", subtitle=");
|
|
R.append(this.subtitle);
|
|
R.append(", isChannelMuted=");
|
|
R.append(this.isChannelMuted);
|
|
R.append(", isGuildMuted=");
|
|
R.append(this.isGuildMuted);
|
|
R.append(", muteEndTime=");
|
|
R.append(this.muteEndTime);
|
|
R.append(", notificationSetting=");
|
|
return a.A(R, this.notificationSetting, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: MuteSettingsSheetViewModel.kt */
|
|
public static final class Uninitialized extends ViewState {
|
|
public static final Uninitialized INSTANCE = new Uninitialized();
|
|
|
|
private Uninitialized() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
private ViewState() {
|
|
}
|
|
|
|
public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
|
|
static {
|
|
SettingsType.values();
|
|
int[] iArr = new int[7];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
iArr[SettingsType.GUILD.ordinal()] = 1;
|
|
iArr[SettingsType.THREAD.ordinal()] = 2;
|
|
iArr[SettingsType.GUILD_CHANNEL.ordinal()] = 3;
|
|
iArr[SettingsType.DM.ordinal()] = 4;
|
|
iArr[SettingsType.GROUP_DM.ordinal()] = 5;
|
|
iArr[SettingsType.CATEGORY.ordinal()] = 6;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public MuteSettingsSheetViewModel(long j, long j2, Observable<StoreState> observable, StoreUserGuildSettings storeUserGuildSettings, Clock clock) {
|
|
super(ViewState.Uninitialized.INSTANCE);
|
|
m.checkNotNullParameter(observable, "storeStateObservable");
|
|
m.checkNotNullParameter(storeUserGuildSettings, "storeUserGuildSettings");
|
|
m.checkNotNullParameter(clock, "clock");
|
|
this.guildId = j;
|
|
this.channelId = j2;
|
|
this.storeStateObservable = observable;
|
|
this.storeUserGuildSettings = storeUserGuildSettings;
|
|
this.clock = clock;
|
|
this.config = j != 0 ? new Config.Guild(j) : new Config.Channel(j2);
|
|
this.eventSubject = PublishSubject.k0();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), MuteSettingsSheetViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
|
|
}
|
|
|
|
/* JADX WARNING: Illegal instructions before constructor call */
|
|
public /* synthetic */ MuteSettingsSheetViewModel(long j, long j2, Observable observable, StoreUserGuildSettings storeUserGuildSettings, Clock clock, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(j, j2, r6, (i & 8) != 0 ? StoreStream.Companion.getUserGuildSettings() : storeUserGuildSettings, (i & 16) != 0 ? ClockFactory.get() : clock);
|
|
Observable observable2;
|
|
if ((i & 4) != 0) {
|
|
Companion companion = Companion;
|
|
StoreStream.Companion companion2 = StoreStream.Companion;
|
|
observable2 = Companion.access$observeStoreState(companion, j, j2, companion2.getGuilds(), companion2.getChannels(), companion2.getUserGuildSettings(), companion2.getThreadsJoined());
|
|
} else {
|
|
observable2 = observable;
|
|
}
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(MuteSettingsSheetViewModel muteSettingsSheetViewModel, StoreState storeState) {
|
|
muteSettingsSheetViewModel.handleStoreState(storeState);
|
|
}
|
|
|
|
@MainThread
|
|
private final void emitDismissEvent() {
|
|
PublishSubject<Event> publishSubject = this.eventSubject;
|
|
publishSubject.k.onNext(Event.Dismiss.INSTANCE);
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:108:0x017e */
|
|
/* JADX WARNING: Removed duplicated region for block: B:109:0x0183 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:113:0x00dd A[EDGE_INSN: B:113:0x00dd->B:53:0x00dd ?: BREAK , SYNTHETIC] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:79:0x0124 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:96:0x015b */
|
|
/* JADX WARNING: Removed duplicated region for block: B:99:0x0167 */
|
|
@MainThread
|
|
private final void handleStoreState(StoreState storeState) {
|
|
String str;
|
|
ModelNotificationSettings.ChannelOverride channelOverride;
|
|
String str2;
|
|
ModelNotificationSettings guildNotificationSettings;
|
|
ModelMuteConfig muteConfig;
|
|
StoreThreadsJoined.JoinedThread joinedThread;
|
|
List<ModelNotificationSettings.ChannelOverride> channelOverrides;
|
|
Object obj;
|
|
boolean z2;
|
|
Guild guild = storeState.getGuild();
|
|
Channel channel = storeState.getChannel();
|
|
SettingsType settingsType = guild != null ? SettingsType.GUILD : channel != null ? ChannelUtils.m(channel) ? SettingsType.DM : ChannelUtils.p(channel) ? SettingsType.GROUP_DM : ChannelUtils.k(channel) ? SettingsType.CATEGORY : ChannelUtils.C(channel) ? SettingsType.THREAD : SettingsType.GUILD_CHANNEL : SettingsType.UNKNOWN;
|
|
if (settingsType == SettingsType.UNKNOWN) {
|
|
updateViewState(ViewState.Failure.INSTANCE);
|
|
return;
|
|
}
|
|
int ordinal = settingsType.ordinal();
|
|
if (ordinal != 0) {
|
|
if (!(ordinal == 1 || ordinal == 2)) {
|
|
if (ordinal == 3) {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append('\"');
|
|
m.checkNotNull(channel);
|
|
sb.append(ChannelUtils.c(channel));
|
|
sb.append('\"');
|
|
str = sb.toString();
|
|
} else if (ordinal == 4) {
|
|
StringBuilder sb2 = new StringBuilder();
|
|
sb2.append(MentionUtilsKt.CHANNELS_CHAR);
|
|
m.checkNotNull(channel);
|
|
sb2.append(ChannelUtils.c(channel));
|
|
str = sb2.toString();
|
|
} else if (ordinal != 5) {
|
|
str = "";
|
|
}
|
|
}
|
|
m.checkNotNull(channel);
|
|
str = ChannelUtils.c(channel);
|
|
} else {
|
|
m.checkNotNull(guild);
|
|
str = guild.getName();
|
|
}
|
|
ModelNotificationSettings guildNotificationSettings2 = storeState.getGuildNotificationSettings();
|
|
Integer num = null;
|
|
if (guildNotificationSettings2 == null || (channelOverrides = guildNotificationSettings2.getChannelOverrides()) == null) {
|
|
channelOverride = null;
|
|
} else {
|
|
Iterator<T> it = channelOverrides.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
obj = null;
|
|
break;
|
|
}
|
|
obj = it.next();
|
|
ModelNotificationSettings.ChannelOverride channelOverride2 = (ModelNotificationSettings.ChannelOverride) obj;
|
|
Channel channel2 = storeState.getChannel();
|
|
if (channel2 != null) {
|
|
long h = channel2.h();
|
|
m.checkNotNullExpressionValue(channelOverride2, "channelOverride");
|
|
if (h == channelOverride2.getChannelId()) {
|
|
z2 = true;
|
|
continue;
|
|
if (z2) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
z2 = false;
|
|
continue;
|
|
if (z2) {
|
|
}
|
|
}
|
|
channelOverride = (ModelNotificationSettings.ChannelOverride) obj;
|
|
}
|
|
boolean z3 = channel == null || !ChannelUtils.C(channel) ? !(channelOverride == null || !channelOverride.isMuted()) : !((joinedThread = storeState.getJoinedThread()) == null || !joinedThread.getMuted());
|
|
if (channel != null && ChannelUtils.C(channel)) {
|
|
StoreThreadsJoined.JoinedThread joinedThread2 = storeState.getJoinedThread();
|
|
if (!(joinedThread2 == null || (muteConfig = joinedThread2.getMuteConfig()) == null)) {
|
|
str2 = muteConfig.getEndTime();
|
|
if (channel == null) {
|
|
}
|
|
if (channelOverride != null) {
|
|
}
|
|
updateViewState(new ViewState.Loaded(settingsType, str, z3, channel == null && !ChannelUtils.x(channel) && (guildNotificationSettings = storeState.getGuildNotificationSettings()) != null && guildNotificationSettings.isMuted(), str2, num != null ? num.intValue() : ModelNotificationSettings.FREQUENCY_UNSET));
|
|
}
|
|
} else if (channelOverride != null) {
|
|
str2 = channelOverride.getMuteEndTime();
|
|
if (channel == null && ChannelUtils.C(channel)) {
|
|
StoreThreadsJoined.JoinedThread joinedThread3 = storeState.getJoinedThread();
|
|
if (joinedThread3 != null) {
|
|
num = Integer.valueOf(joinedThread3.getFlags());
|
|
}
|
|
num = Integer.valueOf((num != null && num.intValue() == 8) ? ModelNotificationSettings.FREQUENCY_NOTHING : (num != null && num.intValue() == 4) ? ModelNotificationSettings.FREQUENCY_MENTIONS : ModelNotificationSettings.FREQUENCY_ALL);
|
|
} else if (channelOverride != null) {
|
|
num = Integer.valueOf(channelOverride.getMessageNotifications());
|
|
}
|
|
updateViewState(new ViewState.Loaded(settingsType, str, z3, channel == null && !ChannelUtils.x(channel) && (guildNotificationSettings = storeState.getGuildNotificationSettings()) != null && guildNotificationSettings.isMuted(), str2, num != null ? num.intValue() : ModelNotificationSettings.FREQUENCY_UNSET));
|
|
}
|
|
str2 = null;
|
|
if (channel == null) {
|
|
}
|
|
if (channelOverride != null) {
|
|
}
|
|
updateViewState(new ViewState.Loaded(settingsType, str, z3, channel == null && !ChannelUtils.x(channel) && (guildNotificationSettings = storeState.getGuildNotificationSettings()) != null && guildNotificationSettings.isMuted(), str2, num != null ? num.intValue() : ModelNotificationSettings.FREQUENCY_UNSET));
|
|
}
|
|
|
|
@MainThread
|
|
public final void emitNotificationSettingsEvent(long j) {
|
|
PublishSubject<Event> publishSubject = this.eventSubject;
|
|
publishSubject.k.onNext(new Event.NavigateToChannelSettings(j));
|
|
}
|
|
|
|
public final long getChannelId() {
|
|
return this.channelId;
|
|
}
|
|
|
|
public final Clock getClock() {
|
|
return this.clock;
|
|
}
|
|
|
|
public final Config getConfig() {
|
|
return this.config;
|
|
}
|
|
|
|
public final long getGuildId() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final Observable<StoreState> getStoreStateObservable() {
|
|
return this.storeStateObservable;
|
|
}
|
|
|
|
public final StoreUserGuildSettings getStoreUserGuildSettings() {
|
|
return this.storeUserGuildSettings;
|
|
}
|
|
|
|
public final Observable<Event> observeEvents() {
|
|
PublishSubject<Event> publishSubject = this.eventSubject;
|
|
m.checkNotNullExpressionValue(publishSubject, "eventSubject");
|
|
return publishSubject;
|
|
}
|
|
|
|
@MainThread
|
|
public final void onChannelSettingsSelected() {
|
|
Config config = this.config;
|
|
if (config instanceof Config.Channel) {
|
|
emitNotificationSettingsEvent(((Config.Channel) config).getChannelId());
|
|
}
|
|
}
|
|
|
|
@MainThread
|
|
public final void selectMuteDurationMs(long j, Context context) {
|
|
m.checkNotNullParameter(context, "appContext");
|
|
ModelMuteConfig modelMuteConfig = null;
|
|
if (j != 0) {
|
|
modelMuteConfig = new ModelMuteConfig(TimeUtils.toUTCDateTime$default(Long.valueOf(this.clock.currentTimeMillis() + j), null, 2, null));
|
|
}
|
|
Config config = this.config;
|
|
if (config instanceof Config.Guild) {
|
|
this.storeUserGuildSettings.setGuildMuted(context, ((Config.Guild) config).getGuildId(), true, modelMuteConfig);
|
|
} else if (config instanceof Config.Channel) {
|
|
this.storeUserGuildSettings.setChannelMuted(context, ((Config.Channel) config).getChannelId(), true, modelMuteConfig);
|
|
}
|
|
emitDismissEvent();
|
|
}
|
|
|
|
@MainThread
|
|
public final void unmute(Context context) {
|
|
m.checkNotNullParameter(context, "appContext");
|
|
Config config = this.config;
|
|
if (config instanceof Config.Channel) {
|
|
this.storeUserGuildSettings.setChannelMuted(context, ((Config.Channel) config).getChannelId(), false, null);
|
|
emitDismissEvent();
|
|
}
|
|
}
|
|
}
|