discord-jadx/app/src/main/java/com/discord/stores/StoreOutboundPromotions$mar...

62 lines
2.8 KiB
Java

package com.discord.stores;
import android.content.SharedPreferences;
import com.discord.api.premium.OutboundPromotion;
import com.discord.api.utcdatetime.UtcDateTime;
import com.discord.stores.StoreOutboundPromotions;
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;
/* compiled from: StoreOutboundPromotions.kt */
public final class StoreOutboundPromotions$markSeen$1 extends o implements Function0<Unit> {
public final /* synthetic */ StoreOutboundPromotions this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public StoreOutboundPromotions$markSeen$1(StoreOutboundPromotions storeOutboundPromotions) {
super(0);
this.this$0 = storeOutboundPromotions;
}
@Override // kotlin.jvm.functions.Function0
/* renamed from: invoke */
public final void mo1invoke() {
List<OutboundPromotion> validActivePromotions;
StoreOutboundPromotions.State access$getState$p = StoreOutboundPromotions.access$getState$p(this.this$0);
Object obj = null;
if (!(access$getState$p instanceof StoreOutboundPromotions.State.Loaded)) {
access$getState$p = null;
}
StoreOutboundPromotions.State.Loaded loaded = (StoreOutboundPromotions.State.Loaded) access$getState$p;
if (loaded != null && (validActivePromotions = loaded.getValidActivePromotions()) != null) {
Iterator<T> it = validActivePromotions.iterator();
if (it.hasNext()) {
obj = it.next();
if (it.hasNext()) {
UtcDateTime h = ((OutboundPromotion) obj).h();
do {
Object next = it.next();
UtcDateTime h2 = ((OutboundPromotion) next).h();
if (h.compareTo(h2) < 0) {
obj = next;
h = h2;
}
} while (it.hasNext());
}
}
OutboundPromotion outboundPromotion = (OutboundPromotion) obj;
if (outboundPromotion != null) {
SharedPreferences.Editor edit = this.this$0.getPrefs().edit();
m.checkExpressionValueIsNotNull(edit, "editor");
edit.putLong("LATEST_SEEN_PROMO_DATE", outboundPromotion.h().f());
edit.apply();
StoreOutboundPromotions storeOutboundPromotions = this.this$0;
StoreOutboundPromotions.access$setState$p(storeOutboundPromotions, new StoreOutboundPromotions.State.Loaded(validActivePromotions, StoreOutboundPromotions.access$getUnseenCount(storeOutboundPromotions, validActivePromotions)));
this.this$0.markChanged();
}
}
}
}