Fetch folder list when creating an account
This commit is contained in:
parent
46cdbd556e
commit
a1a090f77e
3 changed files with 23 additions and 2 deletions
|
@ -364,8 +364,24 @@ public class MessagingController {
|
|||
put("refreshFolderList", null, () -> refreshFolderListSynchronous(account));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void refreshFolderListSynchronous(Account account) {
|
||||
public void refreshFolderListBlocking(Account account) {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
putBackground("refreshFolderListBlocking", null, () -> {
|
||||
try {
|
||||
refreshFolderListSynchronous(account);
|
||||
} finally {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
latch.await();
|
||||
} catch (Exception e) {
|
||||
Timber.e(e, "Interrupted while awaiting latch release");
|
||||
}
|
||||
}
|
||||
|
||||
void refreshFolderListSynchronous(Account account) {
|
||||
try {
|
||||
if (isAuthenticationProblem(account, true)) {
|
||||
Timber.d("Authentication will fail. Skip refreshing the folder list.");
|
||||
|
|
|
@ -8,6 +8,7 @@ import app.k9mail.feature.account.setup.AccountSetupExternalContract.AccountCrea
|
|||
import com.fsck.k9.Account.FolderMode
|
||||
import com.fsck.k9.Core
|
||||
import com.fsck.k9.Preferences
|
||||
import com.fsck.k9.controller.MessagingController
|
||||
import com.fsck.k9.logging.Timber
|
||||
import com.fsck.k9.mail.ServerSettings
|
||||
import com.fsck.k9.mail.store.imap.ImapStoreSettings.autoDetectNamespace
|
||||
|
@ -27,6 +28,7 @@ class AccountCreator(
|
|||
private val localFoldersCreator: SpecialLocalFoldersCreator,
|
||||
private val preferences: Preferences,
|
||||
private val context: Context,
|
||||
private val messagingController: MessagingController,
|
||||
private val coroutineDispatcher: CoroutineDispatcher = Dispatchers.IO,
|
||||
) : AccountSetupExternalContract.AccountCreator {
|
||||
|
||||
|
@ -73,6 +75,8 @@ class AccountCreator(
|
|||
|
||||
Core.setServicesEnabled(context)
|
||||
|
||||
messagingController.refreshFolderListBlocking(newAccount)
|
||||
|
||||
return newAccount.uuid
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ val newAccountModule = module {
|
|||
localFoldersCreator = get(),
|
||||
preferences = get(),
|
||||
context = androidApplication(),
|
||||
messagingController = get(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue