289 lines
11 KiB
Java
289 lines
11 KiB
Java
|
package com.discord.stores;
|
||
|
|
||
|
import c.d.b.a.a;
|
||
|
import com.discord.models.domain.emoji.ModelEmojiUnicode;
|
||
|
import com.discord.stores.updates.ObservationDeck;
|
||
|
import com.discord.utilities.persister.Persister;
|
||
|
import com.discord.utilities.textprocessing.node.EmojiNode;
|
||
|
import d0.e0.c;
|
||
|
import d0.g;
|
||
|
import d0.t.n0;
|
||
|
import d0.t.u;
|
||
|
import d0.z.d.a0;
|
||
|
import d0.z.d.m;
|
||
|
import java.util.HashSet;
|
||
|
import java.util.LinkedHashSet;
|
||
|
import java.util.Set;
|
||
|
import kotlin.Lazy;
|
||
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||
|
import rx.Observable;
|
||
|
/* compiled from: StoreMediaFavorites.kt */
|
||
|
public final class StoreMediaFavorites extends StoreV2 {
|
||
|
public static final Companion Companion = new Companion(null);
|
||
|
public static final String FAVORITES_CACHE_KEY = "STORE_FAVORITES";
|
||
|
private final Dispatcher dispatcher;
|
||
|
private final Set<Favorite> favorites;
|
||
|
private Set<? extends Favorite> favoritesSnapshot;
|
||
|
private final ObservationDeck observationDeck;
|
||
|
private final Persister<Set<Favorite>> persister;
|
||
|
|
||
|
/* compiled from: StoreMediaFavorites.kt */
|
||
|
public static final class Companion {
|
||
|
private Companion() {
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: StoreMediaFavorites.kt */
|
||
|
public static abstract class Favorite {
|
||
|
private static final Lazy AllTypes$delegate = g.lazy(StoreMediaFavorites$Favorite$Companion$AllTypes$2.INSTANCE);
|
||
|
public static final Companion Companion = new Companion(null);
|
||
|
private static final Set<c<? extends Favorite>> EmojiTypes = n0.setOf((Object[]) new c[]{a0.getOrCreateKotlinClass(FavCustomEmoji.class), a0.getOrCreateKotlinClass(FavUnicodeEmoji.class)});
|
||
|
|
||
|
/* compiled from: StoreMediaFavorites.kt */
|
||
|
public static final class Companion {
|
||
|
private Companion() {
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this();
|
||
|
}
|
||
|
|
||
|
public final Set<c<? extends Favorite>> getAllTypes() {
|
||
|
Lazy access$getAllTypes$cp = Favorite.access$getAllTypes$cp();
|
||
|
Companion companion = Favorite.Companion;
|
||
|
return (Set) access$getAllTypes$cp.getValue();
|
||
|
}
|
||
|
|
||
|
public final Set<c<? extends Favorite>> getEmojiTypes() {
|
||
|
return Favorite.access$getEmojiTypes$cp();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: StoreMediaFavorites.kt */
|
||
|
public static final class FavCustomEmoji extends Favorite implements FavoriteEmoji {
|
||
|
private final String emojiUniqueId;
|
||
|
|
||
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
||
|
public FavCustomEmoji(EmojiNode.EmojiIdAndType.Custom custom) {
|
||
|
this(String.valueOf(custom.getId()));
|
||
|
m.checkNotNullParameter(custom, "custom");
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
||
|
public FavCustomEmoji(String str) {
|
||
|
super(null);
|
||
|
m.checkNotNullParameter(str, "emojiUniqueId");
|
||
|
this.emojiUniqueId = str;
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ FavCustomEmoji copy$default(FavCustomEmoji favCustomEmoji, String str, int i, Object obj) {
|
||
|
if ((i & 1) != 0) {
|
||
|
str = favCustomEmoji.getEmojiUniqueId();
|
||
|
}
|
||
|
return favCustomEmoji.copy(str);
|
||
|
}
|
||
|
|
||
|
public final String component1() {
|
||
|
return getEmojiUniqueId();
|
||
|
}
|
||
|
|
||
|
public final FavCustomEmoji copy(String str) {
|
||
|
m.checkNotNullParameter(str, "emojiUniqueId");
|
||
|
return new FavCustomEmoji(str);
|
||
|
}
|
||
|
|
||
|
public boolean equals(Object obj) {
|
||
|
if (this != obj) {
|
||
|
return (obj instanceof FavCustomEmoji) && m.areEqual(getEmojiUniqueId(), ((FavCustomEmoji) obj).getEmojiUniqueId());
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
@Override // com.discord.stores.StoreMediaFavorites.FavoriteEmoji
|
||
|
public String getEmojiUniqueId() {
|
||
|
return this.emojiUniqueId;
|
||
|
}
|
||
|
|
||
|
public int hashCode() {
|
||
|
String emojiUniqueId = getEmojiUniqueId();
|
||
|
if (emojiUniqueId != null) {
|
||
|
return emojiUniqueId.hashCode();
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
public String toString() {
|
||
|
StringBuilder K = a.K("FavCustomEmoji(emojiUniqueId=");
|
||
|
K.append(getEmojiUniqueId());
|
||
|
K.append(")");
|
||
|
return K.toString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: StoreMediaFavorites.kt */
|
||
|
public static final class FavUnicodeEmoji extends Favorite implements FavoriteEmoji {
|
||
|
private final String emojiUniqueId;
|
||
|
|
||
|
/* JADX WARNING: Illegal instructions before constructor call */
|
||
|
public FavUnicodeEmoji(ModelEmojiUnicode modelEmojiUnicode) {
|
||
|
this(r2);
|
||
|
m.checkNotNullParameter(modelEmojiUnicode, "unicode");
|
||
|
String uniqueId = modelEmojiUnicode.getUniqueId();
|
||
|
m.checkNotNullExpressionValue(uniqueId, "unicode.uniqueId");
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
||
|
public FavUnicodeEmoji(String str) {
|
||
|
super(null);
|
||
|
m.checkNotNullParameter(str, "emojiUniqueId");
|
||
|
this.emojiUniqueId = str;
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ FavUnicodeEmoji copy$default(FavUnicodeEmoji favUnicodeEmoji, String str, int i, Object obj) {
|
||
|
if ((i & 1) != 0) {
|
||
|
str = favUnicodeEmoji.getEmojiUniqueId();
|
||
|
}
|
||
|
return favUnicodeEmoji.copy(str);
|
||
|
}
|
||
|
|
||
|
public final String component1() {
|
||
|
return getEmojiUniqueId();
|
||
|
}
|
||
|
|
||
|
public final FavUnicodeEmoji copy(String str) {
|
||
|
m.checkNotNullParameter(str, "emojiUniqueId");
|
||
|
return new FavUnicodeEmoji(str);
|
||
|
}
|
||
|
|
||
|
public boolean equals(Object obj) {
|
||
|
if (this != obj) {
|
||
|
return (obj instanceof FavUnicodeEmoji) && m.areEqual(getEmojiUniqueId(), ((FavUnicodeEmoji) obj).getEmojiUniqueId());
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
@Override // com.discord.stores.StoreMediaFavorites.FavoriteEmoji
|
||
|
public String getEmojiUniqueId() {
|
||
|
return this.emojiUniqueId;
|
||
|
}
|
||
|
|
||
|
public int hashCode() {
|
||
|
String emojiUniqueId = getEmojiUniqueId();
|
||
|
if (emojiUniqueId != null) {
|
||
|
return emojiUniqueId.hashCode();
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
public String toString() {
|
||
|
StringBuilder K = a.K("FavUnicodeEmoji(emojiUniqueId=");
|
||
|
K.append(getEmojiUniqueId());
|
||
|
K.append(")");
|
||
|
return K.toString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private Favorite() {
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ Favorite(DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this();
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Lazy access$getAllTypes$cp() {
|
||
|
return AllTypes$delegate;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Set access$getEmojiTypes$cp() {
|
||
|
return EmojiTypes;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: StoreMediaFavorites.kt */
|
||
|
public interface FavoriteEmoji {
|
||
|
String getEmojiUniqueId();
|
||
|
}
|
||
|
|
||
|
public StoreMediaFavorites(ObservationDeck observationDeck, Dispatcher dispatcher, Persister<Set<Favorite>> persister) {
|
||
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
||
|
m.checkNotNullParameter(dispatcher, "dispatcher");
|
||
|
m.checkNotNullParameter(persister, "persister");
|
||
|
this.observationDeck = observationDeck;
|
||
|
this.dispatcher = dispatcher;
|
||
|
this.persister = persister;
|
||
|
Set<Favorite> set = persister.get();
|
||
|
this.favoritesSnapshot = set;
|
||
|
this.favorites = u.toMutableSet(set);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
||
|
public /* synthetic */ StoreMediaFavorites(ObservationDeck observationDeck, Dispatcher dispatcher, Persister persister, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this(observationDeck, dispatcher, (i & 4) != 0 ? new Persister("STORE_FAVORITES", n0.emptySet()) : persister);
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Set access$getFavorites$p(StoreMediaFavorites storeMediaFavorites) {
|
||
|
return storeMediaFavorites.favorites;
|
||
|
}
|
||
|
|
||
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.stores.StoreMediaFavorites */
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public static /* synthetic */ Set getFavorites$default(StoreMediaFavorites storeMediaFavorites, Set set, int i, Object obj) {
|
||
|
Set<c<? extends Favorite>> set2 = set;
|
||
|
if ((i & 1) != 0) {
|
||
|
set2 = Favorite.Companion.getAllTypes();
|
||
|
}
|
||
|
return storeMediaFavorites.getFavorites(set2);
|
||
|
}
|
||
|
|
||
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.stores.StoreMediaFavorites */
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public static /* synthetic */ Observable observeFavorites$default(StoreMediaFavorites storeMediaFavorites, Set set, int i, Object obj) {
|
||
|
Set<c<? extends Favorite>> set2 = set;
|
||
|
if ((i & 1) != 0) {
|
||
|
set2 = Favorite.Companion.getAllTypes();
|
||
|
}
|
||
|
return storeMediaFavorites.observeFavorites(set2);
|
||
|
}
|
||
|
|
||
|
public final void addFavorite(Favorite favorite) {
|
||
|
m.checkNotNullParameter(favorite, "favorite");
|
||
|
this.dispatcher.schedule(new StoreMediaFavorites$addFavorite$1(this, favorite));
|
||
|
}
|
||
|
|
||
|
public final Set<Favorite> getFavorites(Set<? extends c<? extends Favorite>> set) {
|
||
|
m.checkNotNullParameter(set, "types");
|
||
|
Set<? extends Favorite> set2 = this.favoritesSnapshot;
|
||
|
LinkedHashSet linkedHashSet = new LinkedHashSet();
|
||
|
for (Object obj : set2) {
|
||
|
if (set.contains(a0.getOrCreateKotlinClass(((Favorite) obj).getClass()))) {
|
||
|
linkedHashSet.add(obj);
|
||
|
}
|
||
|
}
|
||
|
return linkedHashSet;
|
||
|
}
|
||
|
|
||
|
public final Observable<Set<Favorite>> observeFavorites(Set<? extends c<? extends Favorite>> set) {
|
||
|
m.checkNotNullParameter(set, "types");
|
||
|
Observable<Set<Favorite>> r = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreMediaFavorites$observeFavorites$1(this, set), 14, null).r();
|
||
|
m.checkNotNullExpressionValue(r, "observationDeck.connectR… .distinctUntilChanged()");
|
||
|
return r;
|
||
|
}
|
||
|
|
||
|
public final void removeFavorite(Favorite favorite) {
|
||
|
m.checkNotNullParameter(favorite, "favorite");
|
||
|
this.dispatcher.schedule(new StoreMediaFavorites$removeFavorite$1(this, favorite));
|
||
|
}
|
||
|
|
||
|
@Override // com.discord.stores.StoreV2
|
||
|
public void snapshotData() {
|
||
|
super.snapshotData();
|
||
|
HashSet hashSet = new HashSet(this.favorites);
|
||
|
this.favoritesSnapshot = hashSet;
|
||
|
this.persister.set(hashSet, true);
|
||
|
}
|
||
|
}
|