Remove LocalStore.getFolderId()

This commit is contained in:
cketti 2021-07-18 23:20:20 +02:00
parent f09f2d4003
commit 93a1df5bd0
2 changed files with 13 additions and 33 deletions

View file

@ -289,18 +289,13 @@ public class MessagingController {
return localStore.getFolderServerId(folderId);
}
private long getFolderId(Account account, String folderServerId) throws MessagingException {
LocalStore localStore = getLocalStoreOrThrow(account);
return localStore.getFolderId(folderServerId);
}
private long getFolderIdOrThrow(Account account, String folderServerId) {
LocalStore localStore = getLocalStoreOrThrow(account);
try {
return localStore.getFolderId(folderServerId);
} catch (MessagingException e) {
throw new IllegalStateException(e);
private long getFolderId(Account account, String folderServerId) {
MessageStore messageStore = messageStoreManager.getMessageStore(account);
Long folderId = messageStore.getFolderId(folderServerId);
if (folderId == null) {
throw new IllegalStateException("Folder not found (server ID: " + folderServerId + ")");
}
return folderId;
}
public void addListener(MessagingListener listener) {
@ -604,7 +599,7 @@ public class MessagingController {
);
}
public void synchronizeMailboxBlocking(Account account, String folderServerId) throws MessagingException {
public void synchronizeMailboxBlocking(Account account, String folderServerId) {
long folderId = getFolderId(account, folderServerId);
account.setRingNotified(false);
@ -2685,7 +2680,7 @@ public class MessagingController {
@Override
public void syncStarted(@NotNull String folderServerId) {
long folderId = getFolderIdOrThrow(account, folderServerId);
long folderId = getFolderId(account, folderServerId);
for (MessagingListener messagingListener : getListeners(listener)) {
messagingListener.synchronizeMailboxStarted(account, folderId);
}
@ -2721,7 +2716,7 @@ public class MessagingController {
@Override
public void syncProgress(@NotNull String folderServerId, int completed, int total) {
long folderId = getFolderIdOrThrow(account, folderServerId);
long folderId = getFolderId(account, folderServerId);
for (MessagingListener messagingListener : getListeners(listener)) {
messagingListener.synchronizeMailboxProgress(account, folderId, completed, total);
}
@ -2755,7 +2750,7 @@ public class MessagingController {
}
String accountUuid = account.getUuid();
long folderId = getFolderIdOrThrow(account, folderServerId);
long folderId = getFolderId(account, folderServerId);
MessageReference messageReference = new MessageReference(accountUuid, folderId, messageServerId, null);
notificationController.removeNewMailNotification(account, messageReference);
}
@ -2782,7 +2777,7 @@ public class MessagingController {
@Override
public void syncFinished(@NotNull String folderServerId) {
long folderId = getFolderIdOrThrow(account, folderServerId);
long folderId = getFolderId(account, folderServerId);
for (MessagingListener messagingListener : getListeners(listener)) {
messagingListener.synchronizeMailboxFinished(account, folderId);
}
@ -2798,7 +2793,7 @@ public class MessagingController {
notifyUserIfCertificateProblem(account, exception, true);
}
long folderId = getFolderIdOrThrow(account, folderServerId);
long folderId = getFolderId(account, folderServerId);
for (MessagingListener messagingListener : getListeners(listener)) {
messagingListener.synchronizeMailboxFailed(account, folderId, message);
}
@ -2806,7 +2801,7 @@ public class MessagingController {
@Override
public void folderStatusChanged(@NotNull String folderServerId) {
long folderId = getFolderIdOrThrow(account, folderServerId);
long folderId = getFolderId(account, folderServerId);
for (MessagingListener messagingListener : getListeners(listener)) {
messagingListener.folderStatusChanged(account, folderId);
}

View file

@ -711,21 +711,6 @@ public class LocalStore {
});
}
public long getFolderId(String folderServerId) throws MessagingException {
return database.execute(false, db -> {
try (Cursor cursor = db.query("folders", new String[] { "id" },
"server_id = ?", new String[] { folderServerId },
null, null, null)
) {
if (cursor.moveToFirst()) {
return cursor.getLong(0);
} else {
throw new MessagingException("Folder not found by server ID: " + folderServerId);
}
}
});
}
public static class AttachmentInfo {
public String name;
public long size;