Use folder database ID for PendingMarkAllAsRead
This commit is contained in:
parent
c98943e983
commit
4e2d084401
3 changed files with 21 additions and 19 deletions
|
@ -955,13 +955,18 @@ public class MessagingController {
|
||||||
}
|
}
|
||||||
|
|
||||||
void processPendingMarkAllAsRead(PendingMarkAllAsRead command, Account account) throws MessagingException {
|
void processPendingMarkAllAsRead(PendingMarkAllAsRead command, Account account) throws MessagingException {
|
||||||
String folder = command.folder;
|
LocalStore localStore = localStoreProvider.getInstance(account);
|
||||||
LocalFolder localFolder = null;
|
LocalFolder localFolder = localStore.getFolder(command.folderId);
|
||||||
|
|
||||||
|
String folderServerId;
|
||||||
try {
|
try {
|
||||||
LocalStore localStore = localStoreProvider.getInstance(account);
|
|
||||||
localFolder = localStore.getFolder(folder);
|
|
||||||
localFolder.open();
|
localFolder.open();
|
||||||
List<? extends Message> messages = localFolder.getMessages(null, false);
|
folderServerId = localFolder.getServerId();
|
||||||
|
|
||||||
|
Timber.i("Marking all messages in %s:%s as read", account, folderServerId);
|
||||||
|
|
||||||
|
// TODO: Make this one database UPDATE operation
|
||||||
|
List<LocalMessage> messages = localFolder.getMessages(null, false);
|
||||||
for (Message message : messages) {
|
for (Message message : messages) {
|
||||||
if (!message.isSet(Flag.SEEN)) {
|
if (!message.isSet(Flag.SEEN)) {
|
||||||
message.setFlag(Flag.SEEN, true);
|
message.setFlag(Flag.SEEN, true);
|
||||||
|
@ -969,22 +974,20 @@ public class MessagingController {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MessagingListener l : getListeners()) {
|
for (MessagingListener l : getListeners()) {
|
||||||
l.folderStatusChanged(account, folder);
|
l.folderStatusChanged(account, folderServerId);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
closeFolder(localFolder);
|
localFolder.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend backend = getBackend(account);
|
Backend backend = getBackend(account);
|
||||||
if (backend.getSupportsSeenFlag()) {
|
if (backend.getSupportsSeenFlag()) {
|
||||||
backend.markAllAsRead(folder);
|
backend.markAllAsRead(folderServerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markAllMessagesRead(final Account account, final String folder) {
|
public void markAllMessagesRead(Account account, long folderId) {
|
||||||
Timber.i("Marking all messages in %s:%s as read", account.getDescription(), folder);
|
PendingCommand command = PendingMarkAllAsRead.create(folderId);
|
||||||
|
|
||||||
PendingCommand command = PendingMarkAllAsRead.create(folder);
|
|
||||||
queuePendingCommand(account, command);
|
queuePendingCommand(account, command);
|
||||||
processPendingCommands(account);
|
processPendingCommands(account);
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,16 +178,15 @@ public class MessagingControllerCommands {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PendingMarkAllAsRead extends PendingCommand {
|
public static class PendingMarkAllAsRead extends PendingCommand {
|
||||||
public final String folder;
|
public final long folderId;
|
||||||
|
|
||||||
|
|
||||||
public static PendingMarkAllAsRead create(String folder) {
|
public static PendingMarkAllAsRead create(long folderId) {
|
||||||
checkNotNull(folder);
|
return new PendingMarkAllAsRead(folderId);
|
||||||
return new PendingMarkAllAsRead(folder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PendingMarkAllAsRead(String folder) {
|
private PendingMarkAllAsRead(long folderId) {
|
||||||
this.folder = folder;
|
this.folderId = folderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2343,7 +2343,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
|
||||||
|
|
||||||
private void markAllAsRead() {
|
private void markAllAsRead() {
|
||||||
if (isMarkAllAsReadSupported()) {
|
if (isMarkAllAsReadSupported()) {
|
||||||
messagingController.markAllMessagesRead(account, folderServerId);
|
messagingController.markAllMessagesRead(account, currentFolder.databaseId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue