From 3be6adcae074955f01382cc8cdaf4d7c3c70d4d4 Mon Sep 17 00:00:00 2001 From: Ryan Dowling Date: Fri, 2 Feb 2024 20:28:36 +1100 Subject: [PATCH] fix: [#865] issue adding a second account --- .vscode/settings.json | 2 +- CHANGELOG.md | 1 + .../java/com/atlauncher/data/AbstractAccount.java | 8 -------- .../gui/dialogs/LoginWithMicrosoftDialog.java | 3 ++- .../atlauncher/gui/tabs/accounts/AccountsTab.java | 13 +++++++++---- .../com/atlauncher/managers/AccountManager.java | 2 -- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index aba91d18..1e502ba5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,7 +6,7 @@ }, "[java]": { "editor.codeActionsOnSave": { - "source.organizeImports": true + "source.organizeImports": "explicit" } }, "[github-actions-workflow]": { diff --git a/CHANGELOG.md b/CHANGELOG.md index 65e3e293..0fe73773 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This changelog only contains the changes that are unreleased. For changes for in ### Fixes - Creating pack not resetting modloader when switched back to none - Issue with file downloads for non third party enabled files on CurseForge not working +- Issue adding a second account [#865] ### Misc - Remove old FTB pack installing code diff --git a/src/main/java/com/atlauncher/data/AbstractAccount.java b/src/main/java/com/atlauncher/data/AbstractAccount.java index 95573845..d8ac4302 100644 --- a/src/main/java/com/atlauncher/data/AbstractAccount.java +++ b/src/main/java/com/atlauncher/data/AbstractAccount.java @@ -228,10 +228,6 @@ public abstract class AbstractAccount implements Serializable { File file = FileSystem.SKINS.resolve((this.uuid == null ? "default" : this.getUUIDNoDashes()) + ".png") .toFile(); - if (!file.exists()) { - this.updateSkin(); // Download/update the users skin - } - // If the file doesn't exist then use the default Minecraft skin. if (file == null || !file.exists()) { return SkinUtils.getDefaultHead(); @@ -248,10 +244,6 @@ public abstract class AbstractAccount implements Serializable { public ImageIcon getMinecraftSkin() { File file = FileSystem.SKINS.resolve(this.getUUIDNoDashes() + ".png").toFile(); - if (!file.exists()) { - this.updateSkin(); // Download/update the users skin - } - // If the file doesn't exist then use the default Minecraft skin. if (file == null || !file.exists()) { return SkinUtils.getDefaultSkin(); diff --git a/src/main/java/com/atlauncher/gui/dialogs/LoginWithMicrosoftDialog.java b/src/main/java/com/atlauncher/gui/dialogs/LoginWithMicrosoftDialog.java index 87d80dd6..0728f0ec 100644 --- a/src/main/java/com/atlauncher/gui/dialogs/LoginWithMicrosoftDialog.java +++ b/src/main/java/com/atlauncher/gui/dialogs/LoginWithMicrosoftDialog.java @@ -62,7 +62,7 @@ public final class LoginWithMicrosoftDialog extends JDialog { private static final HTTPServer server = new HTTPServer(Constants.MICROSOFT_LOGIN_REDIRECT_PORT); private static final VirtualHost host = server.getVirtualHost(null); - private MicrosoftAccount account = null; + public MicrosoftAccount account = null; public LoginWithMicrosoftDialog() { this(null); @@ -192,6 +192,7 @@ public final class LoginWithMicrosoftDialog extends JDialog { profile); AccountManager.addAccount(account); + this.account = account; } } diff --git a/src/main/java/com/atlauncher/gui/tabs/accounts/AccountsTab.java b/src/main/java/com/atlauncher/gui/tabs/accounts/AccountsTab.java index f5809d82..658497b1 100644 --- a/src/main/java/com/atlauncher/gui/tabs/accounts/AccountsTab.java +++ b/src/main/java/com/atlauncher/gui/tabs/accounts/AccountsTab.java @@ -54,15 +54,15 @@ import com.atlauncher.evnt.manager.RelocalizationManager; import com.atlauncher.gui.dialogs.LoginWithMicrosoftDialog; import com.atlauncher.gui.dialogs.ProgressDialog; import com.atlauncher.gui.tabs.Tab; -import com.atlauncher.viewmodel.base.IAccountsViewModel; -import com.atlauncher.viewmodel.base.IAccountsViewModel.LoginPostResult; -import com.atlauncher.viewmodel.base.IAccountsViewModel.LoginPreCheckResult; import com.atlauncher.managers.AccountManager; import com.atlauncher.managers.DialogManager; import com.atlauncher.managers.LogManager; import com.atlauncher.utils.ComboItem; import com.atlauncher.utils.OS; import com.atlauncher.utils.SkinUtils; +import com.atlauncher.viewmodel.base.IAccountsViewModel; +import com.atlauncher.viewmodel.base.IAccountsViewModel.LoginPostResult; +import com.atlauncher.viewmodel.base.IAccountsViewModel.LoginPreCheckResult; import com.atlauncher.viewmodel.impl.AccountsViewModel; public class AccountsTab extends JPanel implements Tab, RelocalizationListener { @@ -262,9 +262,14 @@ public class AccountsTab extends JPanel implements Tab, RelocalizationListener { loginWithMicrosoftButton.addActionListener(e -> { // TODO This should be handled by some reaction via listener int numberOfAccountsBefore = viewModel.accountCount(); - new LoginWithMicrosoftDialog(); + LoginWithMicrosoftDialog dialog = new LoginWithMicrosoftDialog(); if (numberOfAccountsBefore != viewModel.accountCount()) { + // account was added, so get the skin + if (dialog.account != null) { + dialog.account.updateSkin(); + } + viewModel.pushNewAccounts(); accountsComboBox.setSelectedItem(AccountManager.getSelectedAccount()); } diff --git a/src/main/java/com/atlauncher/managers/AccountManager.java b/src/main/java/com/atlauncher/managers/AccountManager.java index 33fd927f..a9e441fb 100644 --- a/src/main/java/com/atlauncher/managers/AccountManager.java +++ b/src/main/java/com/atlauncher/managers/AccountManager.java @@ -226,8 +226,6 @@ public class AccountManager { accounts.add(account); ACCOUNTS.onNext(accounts); - account.updateSkin(); - if (accounts.size() > 1) { // not first account? ask if they want to switch to it int ret = DialogManager.optionDialog().setTitle(GetText.tr("Account Added"))