267 lines
11 KiB
Java
267 lines
11 KiB
Java
package com.discord.stores;
|
|
|
|
import android.content.Context;
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
import c.d.b.a.a;
|
|
import c0.z.d.m;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.models.domain.ModelInvite;
|
|
import com.discord.models.experiments.domain.Experiment;
|
|
import com.discord.restapi.RestAPIParams;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.rest.RestAPI;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import java.util.Map;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
import rx.subjects.BehaviorSubject;
|
|
/* compiled from: StoreInviteSettings.kt */
|
|
public final class StoreInviteSettings extends Store {
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final String LOCATION_DEEPLINK = "Deeplink";
|
|
public static final String LOCATION_JOIN = "Join Guild Modal";
|
|
private ModelInvite.Settings inviteSettings = new ModelInvite.Settings(86400);
|
|
private final BehaviorSubject<ModelInvite.Settings> inviteSettingsSubject = BehaviorSubject.l0(this.inviteSettings);
|
|
private final BehaviorSubject<InviteCode> pendingInviteCodeSubject = BehaviorSubject.l0(null);
|
|
|
|
/* compiled from: StoreInviteSettings.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreInviteSettings.kt */
|
|
public static final class InviteCode implements Parcelable {
|
|
public static final Parcelable.Creator<InviteCode> CREATOR = new Creator();
|
|
private final Long eventId;
|
|
private final String inviteCode;
|
|
private final String source;
|
|
|
|
public static class Creator implements Parcelable.Creator<InviteCode> {
|
|
@Override // android.os.Parcelable.Creator
|
|
public final InviteCode createFromParcel(Parcel parcel) {
|
|
m.checkNotNullParameter(parcel, "in");
|
|
return new InviteCode(parcel.readString(), parcel.readString(), parcel.readInt() != 0 ? Long.valueOf(parcel.readLong()) : null);
|
|
}
|
|
|
|
@Override // android.os.Parcelable.Creator
|
|
public final InviteCode[] newArray(int i) {
|
|
return new InviteCode[i];
|
|
}
|
|
}
|
|
|
|
public InviteCode(String str, String str2, Long l) {
|
|
m.checkNotNullParameter(str, "inviteCode");
|
|
m.checkNotNullParameter(str2, "source");
|
|
this.inviteCode = str;
|
|
this.source = str2;
|
|
this.eventId = l;
|
|
}
|
|
|
|
public static /* synthetic */ InviteCode copy$default(InviteCode inviteCode, String str, String str2, Long l, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
str = inviteCode.inviteCode;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
str2 = inviteCode.source;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
l = inviteCode.eventId;
|
|
}
|
|
return inviteCode.copy(str, str2, l);
|
|
}
|
|
|
|
public final String component1() {
|
|
return this.inviteCode;
|
|
}
|
|
|
|
public final String component2() {
|
|
return this.source;
|
|
}
|
|
|
|
public final Long component3() {
|
|
return this.eventId;
|
|
}
|
|
|
|
public final InviteCode copy(String str, String str2, Long l) {
|
|
m.checkNotNullParameter(str, "inviteCode");
|
|
m.checkNotNullParameter(str2, "source");
|
|
return new InviteCode(str, str2, l);
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public int describeContents() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof InviteCode)) {
|
|
return false;
|
|
}
|
|
InviteCode inviteCode = (InviteCode) obj;
|
|
return m.areEqual(this.inviteCode, inviteCode.inviteCode) && m.areEqual(this.source, inviteCode.source) && m.areEqual(this.eventId, inviteCode.eventId);
|
|
}
|
|
|
|
public final Long getEventId() {
|
|
return this.eventId;
|
|
}
|
|
|
|
public final String getInviteCode() {
|
|
return this.inviteCode;
|
|
}
|
|
|
|
public final String getSource() {
|
|
return this.source;
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public int hashCode() {
|
|
String str = this.inviteCode;
|
|
int i = 0;
|
|
int hashCode = (str != null ? str.hashCode() : 0) * 31;
|
|
String str2 = this.source;
|
|
int hashCode2 = (hashCode + (str2 != null ? str2.hashCode() : 0)) * 31;
|
|
Long l = this.eventId;
|
|
if (l != null) {
|
|
i = l.hashCode();
|
|
}
|
|
return hashCode2 + i;
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public String toString() {
|
|
StringBuilder O = a.O("InviteCode(inviteCode=");
|
|
O.append(this.inviteCode);
|
|
O.append(", source=");
|
|
O.append(this.source);
|
|
O.append(", eventId=");
|
|
return a.E(O, this.eventId, ")");
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
m.checkNotNullParameter(parcel, "parcel");
|
|
parcel.writeString(this.inviteCode);
|
|
parcel.writeString(this.source);
|
|
Long l = this.eventId;
|
|
if (l != null) {
|
|
parcel.writeInt(1);
|
|
parcel.writeLong(l.longValue());
|
|
return;
|
|
}
|
|
parcel.writeInt(0);
|
|
}
|
|
}
|
|
|
|
public static /* synthetic */ Observable generateInvite$default(StoreInviteSettings storeInviteSettings, long j, ModelInvite.Settings settings, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
settings = storeInviteSettings.inviteSettings;
|
|
}
|
|
return storeInviteSettings.generateInvite(j, settings);
|
|
}
|
|
|
|
public static /* synthetic */ Experiment getInviteGuildExperiment$default(StoreInviteSettings storeInviteSettings, long j, boolean z2, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
z2 = false;
|
|
}
|
|
return storeInviteSettings.getInviteGuildExperiment(j, z2);
|
|
}
|
|
|
|
public static /* synthetic */ void setInviteCode$default(StoreInviteSettings storeInviteSettings, String str, String str2, Long l, int i, Object obj) {
|
|
if ((i & 4) != 0) {
|
|
l = null;
|
|
}
|
|
storeInviteSettings.setInviteCode(str, str2, l);
|
|
}
|
|
|
|
public final void clearInviteCode() {
|
|
this.pendingInviteCodeSubject.onNext(null);
|
|
}
|
|
|
|
public final Observable<ModelInvite> generateInvite(long j) {
|
|
return generateInvite$default(this, j, null, 2, null);
|
|
}
|
|
|
|
public final synchronized Observable<ModelInvite> generateInvite(long j, ModelInvite.Settings settings) {
|
|
m.checkNotNullParameter(settings, "settings");
|
|
return ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().postChannelInvite(j, new RestAPIParams.Invite(settings.getMaxAge(), settings.getMaxUses(), settings.isTemporary(), null)), false, 1, null);
|
|
}
|
|
|
|
public final Observable<ModelInvite> generateInviteDefaultChannel(long j) {
|
|
Observable<ModelInvite> z2 = getInvitableChannels(j).F(StoreInviteSettings$generateInviteDefaultChannel$1.INSTANCE).F(StoreInviteSettings$generateInviteDefaultChannel$2.INSTANCE).F(StoreInviteSettings$generateInviteDefaultChannel$3.INSTANCE).Z(1).z(new StoreInviteSettings$generateInviteDefaultChannel$4(this, j));
|
|
m.checkNotNullExpressionValue(z2, "getInvitableChannels(gui…le.just(null)\n }");
|
|
return z2;
|
|
}
|
|
|
|
public final Observable<Map<Long, Channel>> getInvitableChannels(long j) {
|
|
StoreStream.Companion companion = StoreStream.Companion;
|
|
Observable<Map<Long, Channel>> j2 = Observable.j(companion.getChannels().observeGuildAndPrivateChannels(), companion.getPermissions().observeAllPermissions(), new StoreInviteSettings$getInvitableChannels$1(j));
|
|
m.checkNotNullExpressionValue(j2, "Observable\n .comb… }\n }\n }");
|
|
return j2;
|
|
}
|
|
|
|
public final Observable<ModelInvite> getInvite() {
|
|
Observable<ModelInvite> F = getInviteCode().z(StoreInviteSettings$getInvite$1.INSTANCE).F(StoreInviteSettings$getInvite$2.INSTANCE);
|
|
m.checkNotNullExpressionValue(F, "getInviteCode()\n .f…-> null\n }\n }");
|
|
return F;
|
|
}
|
|
|
|
public final Observable<InviteCode> getInviteCode() {
|
|
Observable<InviteCode> q = this.pendingInviteCodeSubject.q();
|
|
m.checkNotNullExpressionValue(q, "pendingInviteCodeSubject.distinctUntilChanged()");
|
|
return q;
|
|
}
|
|
|
|
public final Experiment getInviteGuildExperiment(long j, boolean z2) {
|
|
return StoreStream.Companion.getExperiments().getGuildExperiment("2021-03_android_extend_invite_expiration", j, z2);
|
|
}
|
|
|
|
public final ModelInvite.Settings getInviteSettings(long j) {
|
|
Experiment inviteGuildExperiment$default = getInviteGuildExperiment$default(this, j, false, 2, null);
|
|
return (inviteGuildExperiment$default == null || inviteGuildExperiment$default.getBucket() != 1) ? new ModelInvite.Settings(86400) : new ModelInvite.Settings(ModelInvite.Settings.SEVEN_DAYS);
|
|
}
|
|
|
|
public final Observable<ModelInvite.Settings> getInviteSettings() {
|
|
BehaviorSubject<ModelInvite.Settings> behaviorSubject = this.inviteSettingsSubject;
|
|
m.checkNotNullExpressionValue(behaviorSubject, "inviteSettingsSubject");
|
|
Observable<ModelInvite.Settings> q = ObservableExtensionsKt.computationLatest(behaviorSubject).q();
|
|
m.checkNotNullExpressionValue(q, "inviteSettingsSubject\n … .distinctUntilChanged()");
|
|
return q;
|
|
}
|
|
|
|
public final void handleGuildSelected(long j) {
|
|
setInviteSettings(getInviteSettings(j));
|
|
}
|
|
|
|
public final void setInviteCode(String str, String str2, Long l) {
|
|
m.checkNotNullParameter(str, "inviteCode");
|
|
m.checkNotNullParameter(str2, "source");
|
|
this.pendingInviteCodeSubject.onNext(new InviteCode(str, str2, l));
|
|
}
|
|
|
|
public final synchronized void setInviteSettings(ModelInvite.Settings settings) {
|
|
m.checkNotNullParameter(settings, "settings");
|
|
this.inviteSettings = settings;
|
|
this.inviteSettingsSubject.onNext(settings);
|
|
}
|
|
|
|
public final void trackWithInvite$app_productionBetaRelease(Class<?> cls, Function1<? super ModelInvite, Unit> function1) {
|
|
m.checkNotNullParameter(cls, "clazz");
|
|
m.checkNotNullParameter(function1, "trackBlock");
|
|
Observable<ModelInvite> x2 = getInvite().x(StoreInviteSettings$trackWithInvite$1.INSTANCE);
|
|
m.checkNotNullExpressionValue(x2, "getInvite()\n .filter { it != null }");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.computationLatest(ObservableExtensionsKt.takeSingleUntilTimeout$default(x2, 250, false, 2, null)), cls, (Context) null, (Function1) null, new StoreInviteSettings$trackWithInvite$2(function1), (Function0) null, (Function0) null, function1, 54, (Object) null);
|
|
}
|
|
}
|