Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Windows
pEp for Outlook
Commits
2f8e1862
Commit
2f8e1862
authored
Sep 27, 2021
by
Thomas
Browse files
Invalidate UI while waiting for API calls to finish
parent
b721e3b0
Changes
4
Hide whitespace changes
Inline
Side-by-side
DPE/DistributedPolicyEngine.cs
View file @
2f8e1862
...
@@ -256,8 +256,14 @@ namespace pEp.DPE
...
@@ -256,8 +256,14 @@ namespace pEp.DPE
throw
ex
;
throw
ex
;
}
}
this
.
UpdatePatchMailItem
(
patch
,
PatchStatus
.
Rejected
);
if
(
this
.
UpdatePatchMailItem
(
patch
,
PatchStatus
.
Rejected
))
AdapterExtensions
.
ShowNotification
(
"Patch rejected"
,
patch
.
CommitMessage
);
{
AdapterExtensions
.
ShowNotification
(
"Patch rejected"
,
patch
.
CommitMessage
);
}
else
{
throw
new
Exception
(
"Error updating patch mail item."
);
}
}
}
/// <summary>
/// <summary>
...
@@ -281,6 +287,11 @@ namespace pEp.DPE
...
@@ -281,6 +287,11 @@ namespace pEp.DPE
omi
.
SetUserProperty
(
MailItemExtensions
.
USER_PROPERTY_KEY_DPE_PATCH_EDIT_DATE
,
DateTime
.
UtcNow
);
omi
.
SetUserProperty
(
MailItemExtensions
.
USER_PROPERTY_KEY_DPE_PATCH_EDIT_DATE
,
DateTime
.
UtcNow
);
omi
.
Save
();
omi
.
Save
();
}
}
else
{
Log
.
Error
(
"UpdatePatchMailItem: patch mail item not found."
);
return
false
;
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
...
@@ -328,9 +339,15 @@ namespace pEp.DPE
...
@@ -328,9 +339,15 @@ namespace pEp.DPE
{
{
throw
ex
;
throw
ex
;
}
}
this
.
UpdatePatchMailItem
(
patch
,
PatchStatus
.
Supported
);
if
(
this
.
UpdatePatchMailItem
(
patch
,
PatchStatus
.
Supported
))
AdapterExtensions
.
ShowNotification
(
"Patch supported"
,
patch
.
CommitMessage
);
{
AdapterExtensions
.
ShowNotification
(
"Patch supported"
,
patch
.
CommitMessage
);
}
else
{
throw
new
Exception
(
"Error updating patch mail item."
);
}
}
}
/// <summary>
/// <summary>
...
...
UI/ViewModels/FormControlPatchViewModel.cs
View file @
2f8e1862
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
using
pEp.UI.Models
;
using
pEp.UI.Models
;
using
System
;
using
System
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Windows.Documents
;
using
System.Windows.Documents
;
using
System.Windows.Input
;
using
System.Windows.Media
;
using
System.Windows.Media
;
namespace
pEp.UI.ViewModels
namespace
pEp.UI.ViewModels
...
@@ -18,6 +18,7 @@ namespace pEp.UI.ViewModels
...
@@ -18,6 +18,7 @@ namespace pEp.UI.ViewModels
private
FlowDocument
_DisplayDiff
=
null
;
private
FlowDocument
_DisplayDiff
=
null
;
private
DateTime
?
_EditDate
=
null
;
private
DateTime
?
_EditDate
=
null
;
private
string
_Explanation
=
null
;
private
string
_Explanation
=
null
;
private
bool
_IsLoading
=
false
;
private
DistributedPolicyEngine
.
PatchStatus
_Status
=
DistributedPolicyEngine
.
PatchStatus
.
Open
;
private
DistributedPolicyEngine
.
PatchStatus
_Status
=
DistributedPolicyEngine
.
PatchStatus
.
Open
;
#
endregion
#
endregion
...
@@ -75,6 +76,11 @@ namespace pEp.UI.ViewModels
...
@@ -75,6 +76,11 @@ namespace pEp.UI.ViewModels
/// </summary>
/// </summary>
public
string
Explanation
{
get
=>
this
.
_Explanation
;
set
=>
this
.
SetProperty
(
ref
this
.
_Explanation
,
value
);
}
public
string
Explanation
{
get
=>
this
.
_Explanation
;
set
=>
this
.
SetProperty
(
ref
this
.
_Explanation
,
value
);
}
/// <summary>
/// Gets or sets whether the screen is loading.
/// </summary>
public
bool
IsLoading
{
get
=>
this
.
_IsLoading
;
set
=>
this
.
SetProperty
(
ref
this
.
_IsLoading
,
value
);
}
/// <summary>
/// <summary>
/// Gets whether the OK button is visible.
/// Gets whether the OK button is visible.
/// </summary>
/// </summary>
...
@@ -167,27 +173,55 @@ namespace pEp.UI.ViewModels
...
@@ -167,27 +173,55 @@ namespace pEp.UI.ViewModels
#
region
Methods
#
region
Methods
/// <summary>
/// <summary>
///
Rejects this patch
.
///
Executes a patch task (support/reject) and shows an error message if necessary
.
/// </summary>
/// </summary>
/// <param name="parameter">The command parameter.</param>
/// <param name="patchTask">The task to execute.</param>
private
async
void
RejectPatch
(
object
parameter
)
/// <returns>True if the patch task was executed successfully, otherwise false.</returns>
private
async
Task
<
bool
>
ExecutePatchTask
(
Task
patchTask
)
{
{
try
try
{
{
await
Globals
.
ThisAddIn
.
DistributedPolicyEngine
.
Reject
(
this
.
patch
,
new
PEPIdentity
());
// Block UI and show loading cursor
this
.
IsLoading
=
true
;
Mouse
.
OverrideCursor
=
Cursors
.
Wait
;
// Execute the task
await
patchTask
;
// Unblock UI again
this
.
IsLoading
=
false
;
Mouse
.
OverrideCursor
=
null
;
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
this
.
IsLoading
=
false
;
Mouse
.
OverrideCursor
=
null
;
Log
.
Error
(
"Error occured. "
+
ex
);
// Get the innermost exception message and show message box
while
(
ex
.
InnerException
!=
null
)
while
(
ex
.
InnerException
!=
null
)
{
{
ex
=
ex
.
InnerException
;
ex
=
ex
.
InnerException
;
}
}
CustomMessageBox
.
ShowDialog
(
ex
.
Message
,
"Error"
,
"OK"
);
CustomMessageBox
.
ShowDialog
(
ex
.
Message
,
"Error"
,
"OK"
);
return
;
return
false
;
}
}
this
.
UpdateView
(
DistributedPolicyEngine
.
PatchStatus
.
Rejected
);
return
true
;
}
/// <summary>
/// Rejects this patch.
/// </summary>
/// <param name="parameter">The command parameter.</param>
private
async
void
RejectPatch
(
object
parameter
)
{
if
(
await
this
.
ExecutePatchTask
(
Globals
.
ThisAddIn
.
DistributedPolicyEngine
.
Reject
(
this
.
patch
,
new
PEPIdentity
())))
{
this
.
UpdateView
(
DistributedPolicyEngine
.
PatchStatus
.
Rejected
);
}
}
}
/// <summary>
/// <summary>
...
@@ -225,24 +259,10 @@ namespace pEp.UI.ViewModels
...
@@ -225,24 +259,10 @@ namespace pEp.UI.ViewModels
/// <param name="parameter">The command parameter.</param>
/// <param name="parameter">The command parameter.</param>
private
async
void
SupportPatch
(
object
parameter
)
private
async
void
SupportPatch
(
object
parameter
)
{
{
try
if
(
await
this
.
ExecutePatchTask
(
Globals
.
ThisAddIn
.
DistributedPolicyEngine
.
Support
(
this
.
patch
,
new
PEPIdentity
())))
{
await
Globals
.
ThisAddIn
.
DistributedPolicyEngine
.
Support
(
this
.
patch
,
new
PEPIdentity
());
}
catch
(
Exception
ex
)
{
{
Log
.
Error
(
"SupportPatch: Error occured. "
+
ex
);
this
.
UpdateView
(
DistributedPolicyEngine
.
PatchStatus
.
Supported
);
while
(
ex
.
InnerException
!=
null
)
{
ex
=
ex
.
InnerException
;
}
CustomMessageBox
.
ShowDialog
(
ex
.
Message
,
"Error"
,
"OK"
);
return
;
}
}
this
.
UpdateView
(
DistributedPolicyEngine
.
PatchStatus
.
Supported
);
}
}
/// <summary>
/// <summary>
...
...
UI/ViewModels/OptionsViewModel.cs
View file @
2f8e1862
...
@@ -214,7 +214,7 @@ namespace pEp.UI.ViewModels
...
@@ -214,7 +214,7 @@ namespace pEp.UI.ViewModels
{
{
if
(
this
.
_CommandButtonNewPatch
==
null
)
if
(
this
.
_CommandButtonNewPatch
==
null
)
{
{
this
.
_CommandButtonNewPatch
=
new
RelayCommand
(
p
=>
PatchDialog
.
ShowDialog
(
PatchDialog
.
PatchAction
.
NewPatch
,
new
Patch
(),
true
));
this
.
_CommandButtonNewPatch
=
new
RelayCommand
(
async
p
=>
await
PatchDialog
.
ShowDialog
(
PatchDialog
.
PatchAction
.
NewPatch
,
new
Patch
(),
true
));
}
}
return
this
.
_CommandButtonNewPatch
;
return
this
.
_CommandButtonNewPatch
;
...
...
UI/Views/FormControlPatchView.xaml
View file @
2f8e1862
...
@@ -41,6 +41,16 @@
...
@@ -41,6 +41,16 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
</Grid.RowDefinitions>
<Rectangle Grid.Column="0"
Grid.ColumnSpan="3"
Grid.Row="0"
Grid.RowSpan="8"
Grid.ZIndex="100"
Fill="White"
Opacity="0.6"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Visibility="{Binding IsLoading, Converter={StaticResource BoolToVisibility}}" />
<Label Grid.Column="0"
<Label Grid.Column="0"
Grid.ColumnSpan="2"
Grid.ColumnSpan="2"
Grid.Row="0"
Grid.Row="0"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment