1
0
mirror of https://github.com/Kopano-dev/kopano-ol-extension.git synced 2023-10-10 13:37:40 +02:00

[KOE-12] Added debug option to disable COM code, which is the one bit that might cause a crash.

This commit is contained in:
Patrick Simpson 2017-02-28 16:08:57 +01:00
parent 7a885acb71
commit 08c771d762
2 changed files with 42 additions and 19 deletions

View File

@ -26,6 +26,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static Acacia.DebugOptions;
namespace Acacia.Features.SharedFolders namespace Acacia.Features.SharedFolders
{ {
@ -34,6 +35,19 @@ namespace Acacia.Features.SharedFolders
: :
Feature, FeatureWithRibbon, FeatureWithContextMenu Feature, FeatureWithRibbon, FeatureWithContextMenu
{ {
#region Debug options
[AcaciaOption("Disables the update of the reminders query. If this is disabled, the reminders flag on " +
"shared folders will be ignored.")]
public bool Reminders
{
get { return GetOption(OPTION_REMINDERS); }
set { SetOption(OPTION_REMINDERS, value); }
}
private static readonly BoolOption OPTION_REMINDERS = new BoolOption("Reminders", true);
#endregion
public override void Startup() public override void Startup()
{ {
RegisterButton(this, "SharedFolders", true, ManageFolders, ZPushBehaviour.Disable); RegisterButton(this, "SharedFolders", true, ManageFolders, ZPushBehaviour.Disable);

View File

@ -62,15 +62,18 @@ namespace Acacia.Features.SharedFolders
// Fetch the shares // Fetch the shares
ICollection<SharedFolder> shares = _api.GetCurrentShares(cancel); ICollection<SharedFolder> shares = _api.GetCurrentShares(cancel);
// Make sure reminders are disabled as soon as possible if (_feature.Reminders)
UpdateReminders(shares); {
// Make sure reminders are disabled as soon as possible
UpdateReminders(shares);
// Remove any reminders from the shares that are not wanted, they are stale // Remove any reminders from the shares that are not wanted, they are stale
OpenQuery()?.RemoveStaleReminders( OpenQuery()?.RemoveStaleReminders(
shares shares
.Where(x => x.IsSynced && x.SyncType.IsAppointment() && x.FlagCalendarReminders) .Where(x => x.IsSynced && x.SyncType.IsAppointment() && x.FlagCalendarReminders)
.Select(x => x.SyncId) .Select(x => x.SyncId)
); );
}
// Commit changes // Commit changes
if (_query != null) if (_query != null)
@ -90,12 +93,15 @@ namespace Acacia.Features.SharedFolders
private void UpdateReminders(ICollection<SharedFolder> shares) private void UpdateReminders(ICollection<SharedFolder> shares)
{ {
foreach(SharedFolder share in shares) if (_feature.Reminders)
{ {
Logger.Instance.Debug(this, "UpdateReminders: {0}", share); foreach (SharedFolder share in shares)
if (share.IsSynced && share.SyncType.IsAppointment())
{ {
OpenQuery()?.UpdateReminders(share.SyncId, share.FlagCalendarReminders); Logger.Instance.Debug(this, "UpdateReminders: {0}", share);
if (share.IsSynced && share.SyncType.IsAppointment())
{
OpenQuery()?.UpdateReminders(share.SyncId, share.FlagCalendarReminders);
}
} }
} }
} }
@ -104,14 +110,17 @@ namespace Acacia.Features.SharedFolders
{ {
if (_query == null) if (_query == null)
{ {
RemindersQuery query = new RemindersQuery(_feature, _account.Account.Store); if (_feature.Reminders)
if (query.Open())
{ {
_query = query; RemindersQuery query = new RemindersQuery(_feature, _account.Account.Store);
} if (query.Open())
else {
{ _query = query;
query.Dispose(); }
else
{
query.Dispose();
}
} }
} }
return _query; return _query;