2021-08-03 07:33:18 +00:00
|
|
|
package com.discord.widgets.guilds.invite;
|
|
|
|
|
|
|
|
import android.content.Context;
|
2021-12-17 21:59:34 +00:00
|
|
|
import b.a.d.o;
|
|
|
|
import b.d.b.a.a;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.discord.app.AppComponent;
|
|
|
|
import com.discord.app.AppFragment;
|
|
|
|
import com.discord.models.domain.ModelInvite;
|
|
|
|
import com.discord.stores.StoreInviteSettings;
|
|
|
|
import com.discord.stores.StoreStream;
|
|
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
2021-11-02 06:38:17 +00:00
|
|
|
import d0.z.d.m;
|
2021-08-03 07:33:18 +00:00
|
|
|
import java.io.Closeable;
|
|
|
|
import kotlin.jvm.functions.Function0;
|
|
|
|
import kotlin.jvm.functions.Function1;
|
|
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
|
|
import rx.Observable;
|
|
|
|
import rx.subjects.BehaviorSubject;
|
|
|
|
/* compiled from: InviteGenerator.kt */
|
|
|
|
public final class InviteGenerator implements Closeable {
|
|
|
|
private final Observable<InviteGenerationState> generationState;
|
|
|
|
private final BehaviorSubject<InviteGenerationState> generationStateSubject;
|
|
|
|
|
|
|
|
/* compiled from: InviteGenerator.kt */
|
|
|
|
public enum GenerationState {
|
|
|
|
INIT,
|
|
|
|
GENERATING,
|
|
|
|
SUCCESS,
|
|
|
|
FAILURE
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: InviteGenerator.kt */
|
|
|
|
public static final class InviteGenerationState {
|
|
|
|
private final ModelInvite lastGeneratedInvite;
|
|
|
|
private final GenerationState state;
|
|
|
|
|
|
|
|
public InviteGenerationState() {
|
|
|
|
this(null, null, 3, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public InviteGenerationState(ModelInvite modelInvite, GenerationState generationState) {
|
|
|
|
m.checkNotNullParameter(generationState, "state");
|
|
|
|
this.lastGeneratedInvite = modelInvite;
|
|
|
|
this.state = generationState;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
|
|
public /* synthetic */ InviteGenerationState(ModelInvite modelInvite, GenerationState generationState, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this((i & 1) != 0 ? null : modelInvite, (i & 2) != 0 ? GenerationState.INIT : generationState);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ InviteGenerationState copy$default(InviteGenerationState inviteGenerationState, ModelInvite modelInvite, GenerationState generationState, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
modelInvite = inviteGenerationState.lastGeneratedInvite;
|
|
|
|
}
|
|
|
|
if ((i & 2) != 0) {
|
|
|
|
generationState = inviteGenerationState.state;
|
|
|
|
}
|
|
|
|
return inviteGenerationState.copy(modelInvite, generationState);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ModelInvite component1() {
|
|
|
|
return this.lastGeneratedInvite;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final GenerationState component2() {
|
|
|
|
return this.state;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final InviteGenerationState copy(ModelInvite modelInvite, GenerationState generationState) {
|
|
|
|
m.checkNotNullParameter(generationState, "state");
|
|
|
|
return new InviteGenerationState(modelInvite, generationState);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(obj instanceof InviteGenerationState)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
InviteGenerationState inviteGenerationState = (InviteGenerationState) obj;
|
|
|
|
return m.areEqual(this.lastGeneratedInvite, inviteGenerationState.lastGeneratedInvite) && m.areEqual(this.state, inviteGenerationState.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ModelInvite getLastGeneratedInvite() {
|
|
|
|
return this.lastGeneratedInvite;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final GenerationState getState() {
|
|
|
|
return this.state;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
ModelInvite modelInvite = this.lastGeneratedInvite;
|
|
|
|
int i = 0;
|
|
|
|
int hashCode = (modelInvite != null ? modelInvite.hashCode() : 0) * 31;
|
|
|
|
GenerationState generationState = this.state;
|
|
|
|
if (generationState != null) {
|
|
|
|
i = generationState.hashCode();
|
|
|
|
}
|
|
|
|
return hashCode + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-11-05 06:48:17 +00:00
|
|
|
StringBuilder R = a.R("InviteGenerationState(lastGeneratedInvite=");
|
|
|
|
R.append(this.lastGeneratedInvite);
|
|
|
|
R.append(", state=");
|
|
|
|
R.append(this.state);
|
|
|
|
R.append(")");
|
|
|
|
return R.toString();
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public InviteGenerator() {
|
2021-10-22 06:43:45 +00:00
|
|
|
BehaviorSubject<InviteGenerationState> l0 = BehaviorSubject.l0(new InviteGenerationState(null, null, 3, null));
|
|
|
|
this.generationStateSubject = l0;
|
|
|
|
Observable<InviteGenerationState> q = l0.q();
|
2021-10-15 06:18:26 +00:00
|
|
|
m.checkNotNullExpressionValue(q, "generationStateSubject.distinctUntilChanged()");
|
|
|
|
this.generationState = q;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$handleGeneratedInvite(InviteGenerator inviteGenerator, ModelInvite modelInvite) {
|
|
|
|
inviteGenerator.handleGeneratedInvite(modelInvite);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$handleRestCallFailed(InviteGenerator inviteGenerator) {
|
|
|
|
inviteGenerator.handleRestCallFailed();
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void handleGeneratedInvite(ModelInvite modelInvite) {
|
|
|
|
this.generationStateSubject.onNext(new InviteGenerationState(modelInvite, GenerationState.SUCCESS));
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void handleRestCallFailed() {
|
|
|
|
BehaviorSubject<InviteGenerationState> behaviorSubject = this.generationStateSubject;
|
|
|
|
m.checkNotNullExpressionValue(behaviorSubject, "generationStateSubject");
|
2021-10-22 06:43:45 +00:00
|
|
|
this.generationStateSubject.onNext(InviteGenerationState.copy$default(behaviorSubject.n0(), null, GenerationState.FAILURE, 1, null));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // java.io.Closeable, java.lang.AutoCloseable
|
|
|
|
public void close() {
|
|
|
|
this.generationStateSubject.onCompleted();
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void generate(AppFragment appFragment, long j) {
|
|
|
|
m.checkNotNullParameter(appFragment, "fragment");
|
|
|
|
BehaviorSubject<InviteGenerationState> behaviorSubject = this.generationStateSubject;
|
|
|
|
m.checkNotNullExpressionValue(behaviorSubject, "generationStateSubject");
|
2021-10-22 06:43:45 +00:00
|
|
|
this.generationStateSubject.onNext(InviteGenerationState.copy$default(behaviorSubject.n0(), null, GenerationState.GENERATING, 1, null));
|
2021-08-13 06:23:11 +00:00
|
|
|
ObservableExtensionsKt.ui$default(StoreInviteSettings.generateInvite$default(StoreStream.Companion.getInviteSettings(), j, null, 2, null), appFragment, null, 2, null).k(o.a.g(appFragment.getContext(), new InviteGenerator$generate$1(this), new InviteGenerator$generate$2(this)));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final void generateForAppComponent(AppComponent appComponent, long j) {
|
|
|
|
m.checkNotNullParameter(appComponent, "appComponent");
|
|
|
|
BehaviorSubject<InviteGenerationState> behaviorSubject = this.generationStateSubject;
|
|
|
|
m.checkNotNullExpressionValue(behaviorSubject, "generationStateSubject");
|
2021-10-22 06:43:45 +00:00
|
|
|
this.generationStateSubject.onNext(InviteGenerationState.copy$default(behaviorSubject.n0(), null, GenerationState.GENERATING, 1, null));
|
2021-08-03 07:33:18 +00:00
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationBuffered(StoreInviteSettings.generateInvite$default(StoreStream.Companion.getInviteSettings(), j, null, 2, null)), appComponent, null, 2, null), InviteGenerator.class, (Context) null, (Function1) null, new InviteGenerator$generateForAppComponent$2(this), (Function0) null, (Function0) null, new InviteGenerator$generateForAppComponent$1(this), 54, (Object) null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Observable<InviteGenerationState> getGenerationState() {
|
|
|
|
return this.generationState;
|
|
|
|
}
|
|
|
|
}
|