Skip to content

Commit

Permalink
fix: crash on launch when no account
Browse files Browse the repository at this point in the history
  • Loading branch information
dic1911 committed Dec 5, 2024
1 parent 4db0553 commit 7a770f3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.telegram.messenger.Utilities;
import org.telegram.messenger.browser.Browser;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.LaunchActivity;
import org.telegram.ui.LauncherIconController;
import org.unifiedpush.android.connector.UnifiedPush;
Expand Down Expand Up @@ -771,10 +772,13 @@ public static void applyPerformanceClassOverride(Integer c) {
public static void init() {
initStrings();
try {
SharedConfig.loadConfig();
if (lastCrashError.String() != null && !lastCrashError.String().isBlank()) {
final String errStr = lastCrashError.String();
AndroidUtilities.runOnUIThread(() -> {
Context context = LaunchActivity.getLastFragment().getContext();
BaseFragment fragment = LaunchActivity.getLastFragment();
if (fragment == null || SharedConfig.activeAccounts.isEmpty()) return;
Context context = fragment.getContext();
new AlertDialog.Builder(context)
.setTitle(LocaleController.getString(useOldName.Bool() ? R.string.CrashDialogTitle : R.string.CrashDialogMomoTitle))
.setMessage(LocaleController.getString(R.string.CrashDialogMessage))
Expand Down Expand Up @@ -803,7 +807,9 @@ public static void init() {
return;

AndroidUtilities.runOnUIThread(() -> {
Context context = LaunchActivity.getLastFragment().getContext();
BaseFragment fragment = LaunchActivity.getLastFragment();
if (fragment == null || SharedConfig.activeAccounts.isEmpty()) return;
Context context = fragment.getContext();
new AlertDialog.Builder(context)
.setTitle(LocaleController.getString(R.string.SetupUnifiedPush))
.setMessage(LocaleController.getString(R.string.SetupUnifiedPushInfo))
Expand Down

0 comments on commit 7a770f3

Please sign in to comment.