Refactored all synchronizers to deal with some of the chronic issues.
This commit is contained in:
@@ -599,4 +599,24 @@ public class AccountService : BaseDatabaseService, IAccountService
|
||||
|
||||
return account?.Preferences?.IsNotificationsEnabled ?? false;
|
||||
}
|
||||
|
||||
public async Task UpdateLastFolderStructureSyncDateAsync(Guid accountId)
|
||||
{
|
||||
var account = await GetAccountAsync(accountId);
|
||||
if (account == null) return;
|
||||
|
||||
account.LastFolderStructureSyncDate = DateTime.UtcNow;
|
||||
await Connection.UpdateAsync(account, typeof(MailAccount)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<bool> ShouldSyncFolderStructureAsync(Guid accountId, TimeSpan syncInterval)
|
||||
{
|
||||
var account = await GetAccountAsync(accountId);
|
||||
if (account == null) return true;
|
||||
|
||||
if (!account.LastFolderStructureSyncDate.HasValue)
|
||||
return true;
|
||||
|
||||
return DateTime.UtcNow - account.LastFolderStructureSyncDate.Value > syncInterval;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1124,6 +1124,18 @@ public class MailService : BaseDatabaseService, IMailService
|
||||
return new GmailArchiveComparisonResult(addedMails, removedMails);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<string>> GetRecentMailIdsForFolderAsync(Guid folderId, int count)
|
||||
{
|
||||
var recentMails = await Connection.Table<MailCopy>()
|
||||
.Where(a => a.FolderId == folderId)
|
||||
.OrderByDescending(a => a.CreationDate)
|
||||
.Take(count)
|
||||
.ToListAsync()
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return recentMails.Select(m => m.Id);
|
||||
}
|
||||
|
||||
public async Task<List<MailCopy>> GetMailItemsAsync(IEnumerable<string> mailCopyIds)
|
||||
{
|
||||
if (!mailCopyIds.Any()) return [];
|
||||
|
||||
Reference in New Issue
Block a user