651 lines
29 KiB
Java
651 lines
29 KiB
Java
package com.discord.stores;
|
|
|
|
import android.content.Context;
|
|
import com.discord.api.guild.Guild;
|
|
import com.discord.api.guildscheduledevent.GuildScheduledEvent;
|
|
import com.discord.api.guildscheduledevent.GuildScheduledEventRsvpUser;
|
|
import com.discord.api.guildscheduledevent.GuildScheduledEventStatus;
|
|
import com.discord.api.guildscheduledevent.GuildScheduledEventUserUpdate;
|
|
import com.discord.api.permission.Permission;
|
|
import com.discord.models.domain.ModelPayload;
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
import com.discord.utilities.permissions.PermissionUtils;
|
|
import com.discord.utilities.rest.RestAPI;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.time.Clock;
|
|
import d0.t.h0;
|
|
import d0.t.n;
|
|
import d0.t.n0;
|
|
import d0.t.o;
|
|
import d0.z.d.m;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: StoreGuildScheduledEvents.kt */
|
|
public final class StoreGuildScheduledEvents extends StoreV2 {
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final long FETCH_GUILD_EVENTS_THRESHOLD = 1800000;
|
|
private final Clock clock;
|
|
private final Dispatcher dispatcher;
|
|
private final HashMap<Long, List<GuildScheduledEvent>> guildScheduledEvents = new HashMap<>();
|
|
private final HashMap<Long, Long> guildScheduledEventsFetchTimestamps = new HashMap<>();
|
|
private Map<Long, ? extends List<GuildScheduledEvent>> guildScheduledEventsSnapshot = h0.emptyMap();
|
|
private boolean isUsersForGuildEventError;
|
|
private boolean isUsersForGuildEventFetching;
|
|
private final ObservationDeck observationDeck;
|
|
private final StorePermissions permissionsStore;
|
|
private final HashSet<Long> rsvpsAwaitingNetwork = new HashSet<>();
|
|
private HashSet<Long> rsvpsAwaitingSnapshot = new HashSet<>();
|
|
private final HashMap<Long, Set<Long>> userGuildScheduledEventIds = new HashMap<>();
|
|
private Map<Long, ? extends Set<Long>> userGuildScheduledEventIdsSnapshot = h0.emptyMap();
|
|
private final HashSet<Long> userGuildScheduledEventsFetches = new HashSet<>();
|
|
private final StoreUser userStore;
|
|
private final HashMap<Long, List<GuildScheduledEventRsvpUser>> usersForGuildEvent = new HashMap<>();
|
|
|
|
/* compiled from: StoreGuildScheduledEvents.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
public StoreGuildScheduledEvents(Dispatcher dispatcher, ObservationDeck observationDeck, StorePermissions storePermissions, StoreUser storeUser, Clock clock) {
|
|
m.checkNotNullParameter(dispatcher, "dispatcher");
|
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
|
m.checkNotNullParameter(storePermissions, "permissionsStore");
|
|
m.checkNotNullParameter(storeUser, "userStore");
|
|
m.checkNotNullParameter(clock, "clock");
|
|
this.dispatcher = dispatcher;
|
|
this.observationDeck = observationDeck;
|
|
this.permissionsStore = storePermissions;
|
|
this.userStore = storeUser;
|
|
this.clock = clock;
|
|
}
|
|
|
|
public static final /* synthetic */ GuildScheduledEvent access$findEventFromStore(StoreGuildScheduledEvents storeGuildScheduledEvents, GuildScheduledEvent guildScheduledEvent) {
|
|
return storeGuildScheduledEvents.findEventFromStore(guildScheduledEvent);
|
|
}
|
|
|
|
public static final /* synthetic */ Clock access$getClock$p(StoreGuildScheduledEvents storeGuildScheduledEvents) {
|
|
return storeGuildScheduledEvents.clock;
|
|
}
|
|
|
|
public static final /* synthetic */ Dispatcher access$getDispatcher$p(StoreGuildScheduledEvents storeGuildScheduledEvents) {
|
|
return storeGuildScheduledEvents.dispatcher;
|
|
}
|
|
|
|
public static final /* synthetic */ HashMap access$getGuildScheduledEvents$p(StoreGuildScheduledEvents storeGuildScheduledEvents) {
|
|
return storeGuildScheduledEvents.guildScheduledEvents;
|
|
}
|
|
|
|
public static final /* synthetic */ HashMap access$getGuildScheduledEventsFetchTimestamps$p(StoreGuildScheduledEvents storeGuildScheduledEvents) {
|
|
return storeGuildScheduledEvents.guildScheduledEventsFetchTimestamps;
|
|
}
|
|
|
|
public static final /* synthetic */ HashSet access$getRsvpsAwaitingNetwork$p(StoreGuildScheduledEvents storeGuildScheduledEvents) {
|
|
return storeGuildScheduledEvents.rsvpsAwaitingNetwork;
|
|
}
|
|
|
|
public static final /* synthetic */ HashMap access$getUserGuildScheduledEventIds$p(StoreGuildScheduledEvents storeGuildScheduledEvents) {
|
|
return storeGuildScheduledEvents.userGuildScheduledEventIds;
|
|
}
|
|
|
|
public static final /* synthetic */ HashSet access$getUserGuildScheduledEventsFetches$p(StoreGuildScheduledEvents storeGuildScheduledEvents) {
|
|
return storeGuildScheduledEvents.userGuildScheduledEventsFetches;
|
|
}
|
|
|
|
public static final /* synthetic */ HashMap access$getUsersForGuildEvent$p(StoreGuildScheduledEvents storeGuildScheduledEvents) {
|
|
return storeGuildScheduledEvents.usersForGuildEvent;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleFetchRsvpUsersFailure(StoreGuildScheduledEvents storeGuildScheduledEvents) {
|
|
storeGuildScheduledEvents.handleFetchRsvpUsersFailure();
|
|
}
|
|
|
|
public static final /* synthetic */ boolean access$isUsersForGuildEventError$p(StoreGuildScheduledEvents storeGuildScheduledEvents) {
|
|
return storeGuildScheduledEvents.isUsersForGuildEventError;
|
|
}
|
|
|
|
public static final /* synthetic */ boolean access$isUsersForGuildEventFetching$p(StoreGuildScheduledEvents storeGuildScheduledEvents) {
|
|
return storeGuildScheduledEvents.isUsersForGuildEventFetching;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setUsersForGuildEventError$p(StoreGuildScheduledEvents storeGuildScheduledEvents, boolean z2) {
|
|
storeGuildScheduledEvents.isUsersForGuildEventError = z2;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setUsersForGuildEventFetching$p(StoreGuildScheduledEvents storeGuildScheduledEvents, boolean z2) {
|
|
storeGuildScheduledEvents.isUsersForGuildEventFetching = z2;
|
|
}
|
|
|
|
private final void addUserRsvpForEvent(long j, long j2) {
|
|
if (this.userGuildScheduledEventIds.containsKey(Long.valueOf(j))) {
|
|
Set<Long> set = this.userGuildScheduledEventIds.get(Long.valueOf(j));
|
|
if (set != null) {
|
|
set.add(Long.valueOf(j2));
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
this.userGuildScheduledEventIds.put(Long.valueOf(j), n0.mutableSetOf(Long.valueOf(j2)));
|
|
}
|
|
|
|
private final GuildScheduledEvent findEventFromStore(GuildScheduledEvent guildScheduledEvent) {
|
|
GuildScheduledEvent findEventFromStore = findEventFromStore(guildScheduledEvent.g(), Long.valueOf(guildScheduledEvent.f()));
|
|
return findEventFromStore != null ? findEventFromStore : guildScheduledEvent;
|
|
}
|
|
|
|
public static /* synthetic */ GuildScheduledEvent findEventFromStore$default(StoreGuildScheduledEvents storeGuildScheduledEvents, long j, Long l, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
l = null;
|
|
}
|
|
return storeGuildScheduledEvents.findEventFromStore(j, l);
|
|
}
|
|
|
|
public static /* synthetic */ List getGuildScheduledEvents$default(StoreGuildScheduledEvents storeGuildScheduledEvents, long j, boolean z2, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
z2 = true;
|
|
}
|
|
return storeGuildScheduledEvents.getGuildScheduledEvents(j, z2);
|
|
}
|
|
|
|
private final void handleFetchRsvpUsersFailure() {
|
|
this.dispatcher.schedule(new StoreGuildScheduledEvents$handleFetchRsvpUsersFailure$1(this));
|
|
}
|
|
|
|
public static /* synthetic */ Observable observeGuildScheduledEvents$default(StoreGuildScheduledEvents storeGuildScheduledEvents, long j, boolean z2, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
z2 = true;
|
|
}
|
|
return storeGuildScheduledEvents.observeGuildScheduledEvents(j, z2);
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:15:0x004d */
|
|
/* JADX WARNING: Removed duplicated region for block: B:16:0x0060 */
|
|
private final void processGuildScheduledEventCreateOrUpdate(GuildScheduledEvent guildScheduledEvent) {
|
|
int i;
|
|
int i2;
|
|
GuildScheduledEvent guildScheduledEvent2;
|
|
GuildScheduledEvent guildScheduledEvent3 = guildScheduledEvent;
|
|
long f = guildScheduledEvent.f();
|
|
List<GuildScheduledEvent> list = this.guildScheduledEvents.get(Long.valueOf(f));
|
|
if (list != null) {
|
|
Iterator<GuildScheduledEvent> it = list.iterator();
|
|
int i3 = 0;
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
if (it.next().g() == guildScheduledEvent.g()) {
|
|
i = i3;
|
|
break;
|
|
}
|
|
i3++;
|
|
}
|
|
if (this.guildScheduledEvents.get(Long.valueOf(f)) != null) {
|
|
this.guildScheduledEvents.put(Long.valueOf(f), n.mutableListOf(guildScheduledEvent3));
|
|
} else if (i == -1) {
|
|
List<GuildScheduledEvent> list2 = this.guildScheduledEvents.get(Long.valueOf(f));
|
|
if (list2 != null) {
|
|
list2.add(guildScheduledEvent3);
|
|
}
|
|
} else {
|
|
List<GuildScheduledEvent> list3 = this.guildScheduledEvents.get(Long.valueOf(f));
|
|
Integer l = (list3 == null || (guildScheduledEvent2 = list3.get(i)) == null) ? null : guildScheduledEvent2.l();
|
|
if (guildScheduledEvent.l() == null) {
|
|
i2 = i;
|
|
guildScheduledEvent3 = GuildScheduledEvent.a(guildScheduledEvent, 0, 0, null, null, null, null, null, null, null, null, null, null, null, null, null, l, null, 98303);
|
|
} else {
|
|
i2 = i;
|
|
}
|
|
List<GuildScheduledEvent> list4 = this.guildScheduledEvents.get(Long.valueOf(f));
|
|
if (list4 != null) {
|
|
list4.set(i2, guildScheduledEvent3);
|
|
}
|
|
}
|
|
markChanged();
|
|
}
|
|
i = -1;
|
|
if (this.guildScheduledEvents.get(Long.valueOf(f)) != null) {
|
|
}
|
|
markChanged();
|
|
}
|
|
|
|
@StoreThread
|
|
private final void processRsvpCreate(GuildScheduledEvent guildScheduledEvent, long j) {
|
|
long g = guildScheduledEvent.g();
|
|
if (!isRsvpedToEvent(guildScheduledEvent.f(), g) || j != this.userStore.getMe().getId()) {
|
|
this.rsvpsAwaitingSnapshot.add(Long.valueOf(g));
|
|
addUserRsvpForEvent(guildScheduledEvent.f(), guildScheduledEvent.g());
|
|
Integer l = guildScheduledEvent.l();
|
|
GuildScheduledEvent a = GuildScheduledEvent.a(guildScheduledEvent, 0, 0, null, null, null, null, null, null, null, null, null, null, null, null, null, Integer.valueOf(l != null ? l.intValue() + 1 : 1), null, 98303);
|
|
List<GuildScheduledEvent> list = this.guildScheduledEvents.get(Long.valueOf(a.f()));
|
|
if (list != null) {
|
|
m.checkNotNullExpressionValue(list, "eventList");
|
|
Iterator<GuildScheduledEvent> it = list.iterator();
|
|
int i = 0;
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
i = -1;
|
|
break;
|
|
}
|
|
if (it.next().g() == g) {
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
if (i != -1) {
|
|
list.set(i, a);
|
|
} else {
|
|
list.add(a);
|
|
}
|
|
} else {
|
|
this.guildScheduledEvents.put(Long.valueOf(guildScheduledEvent.f()), n.mutableListOf(a));
|
|
}
|
|
markChanged();
|
|
}
|
|
}
|
|
|
|
public static /* synthetic */ void processRsvpCreate$default(StoreGuildScheduledEvents storeGuildScheduledEvents, GuildScheduledEvent guildScheduledEvent, long j, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
j = storeGuildScheduledEvents.userStore.getMe().getId();
|
|
}
|
|
storeGuildScheduledEvents.processRsvpCreate(guildScheduledEvent, j);
|
|
}
|
|
|
|
@StoreThread
|
|
private final void processRsvpDelete(GuildScheduledEvent guildScheduledEvent, long j) {
|
|
long g = guildScheduledEvent.g();
|
|
if (isRsvpedToEvent(guildScheduledEvent.f(), g) || j != this.userStore.getMe().getId()) {
|
|
this.rsvpsAwaitingSnapshot.add(Long.valueOf(g));
|
|
removeUserRsvpForEvent(guildScheduledEvent.f(), g);
|
|
List<GuildScheduledEvent> list = this.guildScheduledEvents.get(Long.valueOf(guildScheduledEvent.f()));
|
|
if (list != null) {
|
|
m.checkNotNullExpressionValue(list, "eventList");
|
|
Iterator<GuildScheduledEvent> it = list.iterator();
|
|
int i = 0;
|
|
int i2 = 0;
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
i2 = -1;
|
|
break;
|
|
}
|
|
if (it.next().g() == g) {
|
|
break;
|
|
}
|
|
i2++;
|
|
}
|
|
Integer valueOf = Integer.valueOf(i2);
|
|
if (!(valueOf.intValue() != -1)) {
|
|
valueOf = null;
|
|
}
|
|
if (valueOf != null) {
|
|
int intValue = valueOf.intValue();
|
|
Integer l = guildScheduledEvent.l();
|
|
if (l != null) {
|
|
i = l.intValue() - 1;
|
|
}
|
|
list.set(intValue, GuildScheduledEvent.a(guildScheduledEvent, 0, 0, null, null, null, null, null, null, null, null, null, null, null, null, null, Integer.valueOf(i), null, 98303));
|
|
}
|
|
}
|
|
markChanged();
|
|
}
|
|
}
|
|
|
|
public static /* synthetic */ void processRsvpDelete$default(StoreGuildScheduledEvents storeGuildScheduledEvents, GuildScheduledEvent guildScheduledEvent, long j, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
j = storeGuildScheduledEvents.userStore.getMe().getId();
|
|
}
|
|
storeGuildScheduledEvents.processRsvpDelete(guildScheduledEvent, j);
|
|
}
|
|
|
|
private final void removeUserRsvpForEvent(long j, long j2) {
|
|
Set<Long> set = this.userGuildScheduledEventIds.get(Long.valueOf(j));
|
|
if (set != null) {
|
|
set.remove(Long.valueOf(j2));
|
|
}
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:17:0x0063 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:18:0x0073 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:21:0x0088 */
|
|
public final void addGuildScheduledEventFromInvite(GuildScheduledEvent guildScheduledEvent) {
|
|
int i;
|
|
m.checkNotNullParameter(guildScheduledEvent, "guildScheduledEvent");
|
|
long f = guildScheduledEvent.f();
|
|
List<GuildScheduledEvent> list = this.guildScheduledEvents.get(Long.valueOf(f));
|
|
if (list != null) {
|
|
Iterator<GuildScheduledEvent> it = list.iterator();
|
|
i = 0;
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
if (it.next().g() == guildScheduledEvent.g()) {
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
if (i != -1 && !this.guildScheduledEvents.containsKey(Long.valueOf(f))) {
|
|
this.guildScheduledEvents.put(Long.valueOf(f), n.mutableListOf(guildScheduledEvent));
|
|
} else if (i != -1) {
|
|
((List) h0.getValue(this.guildScheduledEvents, Long.valueOf(f))).add(guildScheduledEvent);
|
|
} else {
|
|
((List) h0.getValue(this.guildScheduledEvents, Long.valueOf(f))).set(i, guildScheduledEvent);
|
|
}
|
|
if (guildScheduledEvent.m() != null) {
|
|
addUserRsvpForEvent(f, guildScheduledEvent.g());
|
|
}
|
|
markChanged();
|
|
}
|
|
i = -1;
|
|
if (i != -1) {
|
|
}
|
|
if (i != -1) {
|
|
}
|
|
if (guildScheduledEvent.m() != null) {
|
|
}
|
|
markChanged();
|
|
}
|
|
|
|
public final void fetchGuildScheduledEventUserCounts(long j) {
|
|
List<GuildScheduledEvent> list = this.guildScheduledEvents.get(Long.valueOf(j));
|
|
if (!(list == null || list.isEmpty())) {
|
|
Long l = this.guildScheduledEventsFetchTimestamps.get(Long.valueOf(j));
|
|
if (l == null || this.clock.currentTimeMillis() - l.longValue() >= FETCH_GUILD_EVENTS_THRESHOLD) {
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().getGuildScheduledEvents(j, true), false, 1, null), StoreGuildScheduledEvents.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new StoreGuildScheduledEvents$fetchGuildScheduledEventUserCounts$1(this, j), 62, (Object) null);
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void fetchRsvpUsers(long j) {
|
|
this.isUsersForGuildEventFetching = true;
|
|
this.isUsersForGuildEventError = false;
|
|
markChanged();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().getGuildScheduledEventUsers(j, 100, true), false, 1, null), StoreGuildScheduledEvents.class, (Context) null, (Function1) null, new StoreGuildScheduledEvents$fetchRsvpUsers$1(this), (Function0) null, (Function0) null, new StoreGuildScheduledEvents$fetchRsvpUsers$2(this, j), 54, (Object) null);
|
|
}
|
|
|
|
public final void fetchUserGuildScheduledEvents(long j) {
|
|
List<GuildScheduledEvent> list = this.guildScheduledEvents.get(Long.valueOf(j));
|
|
if (!(list == null || list.isEmpty()) && !this.userGuildScheduledEventsFetches.contains(Long.valueOf(j))) {
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().getUserGuildScheduledEvents(j), false, 1, null), StoreGuildScheduledEvents.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new StoreGuildScheduledEvents$fetchUserGuildScheduledEvents$1(this, j), 62, (Object) null);
|
|
}
|
|
}
|
|
|
|
public final GuildScheduledEvent findEventFromStore(long j, Long l) {
|
|
boolean z2;
|
|
GuildScheduledEvent guildScheduledEvent;
|
|
Object obj;
|
|
boolean z3;
|
|
Object obj2 = null;
|
|
if (l != null) {
|
|
List list = (List) this.guildScheduledEventsSnapshot.get(Long.valueOf(l.longValue()));
|
|
if (list != null) {
|
|
Iterator it = list.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
obj = null;
|
|
break;
|
|
}
|
|
obj = it.next();
|
|
if (j == ((GuildScheduledEvent) obj).g()) {
|
|
z3 = true;
|
|
continue;
|
|
} else {
|
|
z3 = false;
|
|
continue;
|
|
}
|
|
if (z3) {
|
|
break;
|
|
}
|
|
}
|
|
guildScheduledEvent = (GuildScheduledEvent) obj;
|
|
} else {
|
|
guildScheduledEvent = null;
|
|
}
|
|
if (guildScheduledEvent != null) {
|
|
return guildScheduledEvent;
|
|
}
|
|
}
|
|
Iterator it2 = o.flatten(this.guildScheduledEventsSnapshot.values()).iterator();
|
|
while (true) {
|
|
if (!it2.hasNext()) {
|
|
break;
|
|
}
|
|
Object next = it2.next();
|
|
if (j == ((GuildScheduledEvent) next).g()) {
|
|
z2 = true;
|
|
continue;
|
|
} else {
|
|
z2 = false;
|
|
continue;
|
|
}
|
|
if (z2) {
|
|
obj2 = next;
|
|
break;
|
|
}
|
|
}
|
|
return (GuildScheduledEvent) obj2;
|
|
}
|
|
|
|
public final GuildScheduledEvent getActiveEventForChannel(Long l, Long l2) {
|
|
boolean z2;
|
|
Object obj = null;
|
|
if (l == null || l2 == null) {
|
|
return null;
|
|
}
|
|
Iterator it = getGuildScheduledEvents$default(this, l.longValue(), false, 2, null).iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
Object next = it.next();
|
|
GuildScheduledEvent guildScheduledEvent = (GuildScheduledEvent) next;
|
|
if (!m.areEqual(guildScheduledEvent.b(), l2) || guildScheduledEvent.k() != GuildScheduledEventStatus.ACTIVE) {
|
|
z2 = false;
|
|
continue;
|
|
} else {
|
|
z2 = true;
|
|
continue;
|
|
}
|
|
if (z2) {
|
|
obj = next;
|
|
break;
|
|
}
|
|
}
|
|
return (GuildScheduledEvent) obj;
|
|
}
|
|
|
|
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: java.util.Map<java.lang.Long, ? extends java.util.List<com.discord.api.guildscheduledevent.GuildScheduledEvent>>, java.util.Map<java.lang.Long, java.util.List<com.discord.api.guildscheduledevent.GuildScheduledEvent>> */
|
|
public final Map<Long, List<GuildScheduledEvent>> getAllGuildScheduledEvents() {
|
|
return this.guildScheduledEventsSnapshot;
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:19:0x005d A[SYNTHETIC] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:21:0x001d A[SYNTHETIC] */
|
|
public final List<GuildScheduledEvent> getGuildScheduledEvents(long j, boolean z2) {
|
|
Map<Long, Long> permissionsByChannel = this.permissionsStore.getPermissionsByChannel();
|
|
List list = (List) this.guildScheduledEventsSnapshot.get(Long.valueOf(j));
|
|
if (list == null) {
|
|
return n.emptyList();
|
|
}
|
|
ArrayList arrayList = new ArrayList();
|
|
for (Object obj : list) {
|
|
GuildScheduledEvent guildScheduledEvent = (GuildScheduledEvent) obj;
|
|
boolean z3 = false;
|
|
if (z2) {
|
|
if (guildScheduledEvent.k() != GuildScheduledEventStatus.COMPLETED) {
|
|
if (guildScheduledEvent.b() != null) {
|
|
Long l = permissionsByChannel.get(guildScheduledEvent.b());
|
|
if (l != null) {
|
|
z3 = PermissionUtils.can(Permission.VIEW_CHANNEL, Long.valueOf(l.longValue()));
|
|
}
|
|
}
|
|
}
|
|
if (!z3) {
|
|
arrayList.add(obj);
|
|
}
|
|
}
|
|
z3 = true;
|
|
if (!z3) {
|
|
}
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
public final boolean getIsUsersForGuildEventError() {
|
|
return this.isUsersForGuildEventError;
|
|
}
|
|
|
|
public final boolean getIsUsersForGuildEventFetching() {
|
|
return this.isUsersForGuildEventFetching;
|
|
}
|
|
|
|
public final Set<Long> getUserGuildScheduledEventIds(long j) {
|
|
Set<Long> set = (Set) this.userGuildScheduledEventIdsSnapshot.get(Long.valueOf(j));
|
|
return set != null ? set : n0.emptySet();
|
|
}
|
|
|
|
public final List<GuildScheduledEventRsvpUser> getUsersForGuildEvent(long j) {
|
|
List<GuildScheduledEventRsvpUser> list = this.usersForGuildEvent.get(Long.valueOf(j));
|
|
return list != null ? list : n.emptyList();
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleConnectionOpen(ModelPayload modelPayload) {
|
|
m.checkNotNullParameter(modelPayload, "payload");
|
|
this.guildScheduledEventsFetchTimestamps.clear();
|
|
this.userGuildScheduledEventsFetches.clear();
|
|
List<Guild> guilds = modelPayload.getGuilds();
|
|
m.checkNotNullExpressionValue(guilds, "payload.guilds");
|
|
for (Guild guild : guilds) {
|
|
List<GuildScheduledEvent> n = guild.n();
|
|
if (n != null) {
|
|
for (GuildScheduledEvent guildScheduledEvent : n) {
|
|
processGuildScheduledEventCreateOrUpdate(guildScheduledEvent);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildCreate(Guild guild) {
|
|
m.checkNotNullParameter(guild, "guild");
|
|
List<GuildScheduledEvent> n = guild.n();
|
|
if (n != null) {
|
|
for (GuildScheduledEvent guildScheduledEvent : n) {
|
|
processGuildScheduledEventCreateOrUpdate(guildScheduledEvent);
|
|
}
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildRemove(long j) {
|
|
this.guildScheduledEvents.remove(Long.valueOf(j));
|
|
this.guildScheduledEventsFetchTimestamps.remove(Long.valueOf(j));
|
|
this.userGuildScheduledEventIds.remove(Long.valueOf(j));
|
|
this.userGuildScheduledEventsFetches.remove(Long.valueOf(j));
|
|
markChanged();
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildScheduledEventCreate(GuildScheduledEvent guildScheduledEvent) {
|
|
m.checkNotNullParameter(guildScheduledEvent, "guildScheduledEvent");
|
|
processGuildScheduledEventCreateOrUpdate(guildScheduledEvent);
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildScheduledEventDelete(GuildScheduledEvent guildScheduledEvent) {
|
|
List<GuildScheduledEvent> list;
|
|
m.checkNotNullParameter(guildScheduledEvent, "guildScheduledEvent");
|
|
List<GuildScheduledEvent> list2 = this.guildScheduledEvents.get(Long.valueOf(guildScheduledEvent.f()));
|
|
if (list2 != null) {
|
|
Iterator<GuildScheduledEvent> it = list2.iterator();
|
|
int i = 0;
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
i = -1;
|
|
break;
|
|
}
|
|
if (it.next().g() == guildScheduledEvent.g()) {
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
if (!(i == -1 || (list = this.guildScheduledEvents.get(Long.valueOf(guildScheduledEvent.f()))) == null)) {
|
|
list.remove(i);
|
|
}
|
|
removeUserRsvpForEvent(guildScheduledEvent.f(), guildScheduledEvent.g());
|
|
markChanged();
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildScheduledEventUpdate(GuildScheduledEvent guildScheduledEvent) {
|
|
m.checkNotNullParameter(guildScheduledEvent, "guildScheduledEvent");
|
|
processGuildScheduledEventCreateOrUpdate(guildScheduledEvent);
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildScheduledEventUserCreate(GuildScheduledEventUserUpdate guildScheduledEventUserUpdate) {
|
|
m.checkNotNullParameter(guildScheduledEventUserUpdate, "guildScheduledEventUserUpdate");
|
|
GuildScheduledEvent findEventFromStore$default = findEventFromStore$default(this, guildScheduledEventUserUpdate.a(), null, 2, null);
|
|
if (findEventFromStore$default != null) {
|
|
processRsvpCreate(findEventFromStore$default, guildScheduledEventUserUpdate.b());
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildScheduledEventUserDelete(GuildScheduledEventUserUpdate guildScheduledEventUserUpdate) {
|
|
m.checkNotNullParameter(guildScheduledEventUserUpdate, "guildScheduledEventUserUpdate");
|
|
GuildScheduledEvent findEventFromStore$default = findEventFromStore$default(this, guildScheduledEventUserUpdate.a(), null, 2, null);
|
|
if (findEventFromStore$default != null) {
|
|
processRsvpDelete(findEventFromStore$default, guildScheduledEventUserUpdate.b());
|
|
}
|
|
}
|
|
|
|
public final boolean isRsvpedToEvent(long j, long j2) {
|
|
Set set = (Set) this.userGuildScheduledEventIdsSnapshot.get(Long.valueOf(j));
|
|
if (set == null) {
|
|
set = n0.emptySet();
|
|
}
|
|
return set.contains(Long.valueOf(j2));
|
|
}
|
|
|
|
public final Observable<GuildScheduledEvent> observeGuildScheduledEvent(Long l, Long l2) {
|
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreGuildScheduledEvents$observeGuildScheduledEvent$1(this, l, l2), 14, null);
|
|
}
|
|
|
|
public final Observable<List<GuildScheduledEvent>> observeGuildScheduledEvents(long j, boolean z2) {
|
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreGuildScheduledEvents$observeGuildScheduledEvents$1(this, j, z2), 14, null);
|
|
}
|
|
|
|
@Override // com.discord.stores.StoreV2
|
|
public void snapshotData() {
|
|
super.snapshotData();
|
|
this.guildScheduledEventsSnapshot = new HashMap(this.guildScheduledEvents);
|
|
this.userGuildScheduledEventIdsSnapshot = new HashMap(this.userGuildScheduledEventIds);
|
|
this.rsvpsAwaitingSnapshot.clear();
|
|
}
|
|
|
|
public final void toggleRsvpGuildScheduledEvent(GuildScheduledEvent guildScheduledEvent) {
|
|
m.checkNotNullParameter(guildScheduledEvent, "guildScheduledEvent");
|
|
GuildScheduledEvent findEventFromStore = findEventFromStore(guildScheduledEvent);
|
|
long g = findEventFromStore.g();
|
|
if (!this.rsvpsAwaitingNetwork.contains(Long.valueOf(g)) && !this.rsvpsAwaitingSnapshot.contains(Long.valueOf(g))) {
|
|
this.rsvpsAwaitingNetwork.add(Long.valueOf(g));
|
|
this.dispatcher.schedule(new StoreGuildScheduledEvents$toggleRsvpGuildScheduledEvent$1(this, guildScheduledEvent, g, findEventFromStore));
|
|
}
|
|
}
|
|
}
|