I use this code in my Angular 5 application:
let dialogRef = this.dialog.open(DatechoiceCreationDateDialogComponent, {
data: data
});
dialogRef.afterClosed().subscribe(() => {
this.fetchEvents(); // events are fetched also if close button is pressed
})
Can I differentiate somehow if the close button is pressed because therefore I don't need to reload/fetch events?
Related
I've set up a Message Component Collector via interaction.channel.createMessageComponentCollector, so I'm able to disable buttons after 15 seconds of inactivity. My problem is that after a button is pressed I want to restart the timer for disabling the buttons.
Simplified code demonstrating what i'm trying to acheive below.
const collector = interaction.channel.createMessageComponentCollector({ filter, time: 15000 })
collector.on('collect', i => {
i.update('some updated text here')
// restart the collector timer here
})
collector.on('end', () => { /* this bit disables the buttons */ })
I've looked in the docs, and the code for the collectors themselves and they don't seem to show any way to reset them. If there is any way to do this / workaround for this that would be what I'm looking for.
In my Xamarin iOS app, I have a static helper method that displays an alert dialog. This dialog box needs to automatically go away after a few seconds if the user has still not pressed OK button. Here is the simplified code snippet:
UIAlertController dlg = UIAlertController.Create(title, text,
UIAlertControllerStyle.Alert);
dlg.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, null);
UIApplication.SharedApplication.KeyWindow.RootViewController.
PresentViewController(dlg, true, null);
Later, when the timer expires:
t.Elapsed += (s, e) => {
dlg.DismissViewController(true, null);
};
Although, the method DismissViewController is indeed getting invoked, the dialog does not disappear from the screen.
I even tried calling dlg.Dispose() but this didn't help either.
Can someone please help me understand what is it that I am missing? Regards.
The code in event Elapsed is not on the main Thread .
Invoke it on Main Thread.
t.Elapsed += (s, e) =>
{
InvokeOnMainThread(() => {
dlg.DismissViewController(true, null);
});
};
Is there a way in Electron to tell if a window was not successfully closed?
win.once("closed", () => {
// send message to the page running in the renderer process that the window was closed
});
win.close();
Assuming that I'm not cancelling the close in the close or beforeunload handler, can the window still fail to close, or can I be sure that a message will always be sent to the guest page?
I just came to this issue as well, what I did is simply wait for a few hundred milliseconds, if the callback is called, then most likely, this window has failed to close:
win.on('close', () => setTimeout(() => console.log('failed to close'), 300))
Have a look at this property in the doc:
win.closed
A Boolean that is set to true after the child window gets closed.
And this other bit too:
win.destroy()
Force closing the window, the unload and beforeunload
event won’t be emitted for the web page, and close event will also not
be emitted for this window, but it guarantees the closed event will be
emitted.
With that, you should have all the info you need to create a function that insure you that the window closes:
function forceClose(window) {
// try close first
window.close()
// force with destroy
if(!window.closed) {
window.destroy()
}
//just logging out the event
window.on('closed', (e) => {
console.log(e)
})
}
// in your code, instead of calling win.close()
forceClose(win)
When executing a dialog with the dialogApi with an executeFunction ribbon button, the executeFunction event never completes in Outlook for Windows.
In the manifest we call function "x" that triggers the dialog and adds the event handlers.
function x(evt) { _event = evt; ...}
Office.context.ui.displayDialogAsync(settings, function (asyncResult) {
_dialog = asyncResult.dialog;
_dialog.addEventHandler(Office.EventType.DialogMessageReceived, messageHandler);
_dialog.addEventHandler(Office.EventType.DialogEventReceived, eventHandler);
})
function messageHandler() { _event.completed(); }
function eventHandler() { _event.completed(); }
ExecuteFunction loader
Update:
1. In the manifest, there is a ribbon button definition that executes a function. The function accepts an event parameter passed from the ribbon button click and calls the Office.context.ui.displayDialogAsync api to open a dialog. The event parameter is save to a global variable so that it can be called later in the dialog event handlers. When clicking on the ribbon button, the dialog opens normally, however, when the dialog is closed, event.completed does not seem to get called. The attached image runs for about 10-15 minutes.
2. Code snippet is attached from the original posting.
3. Platform used is Outlook 2016 on Windows 10 with IE 11 and Edge
* Strange behavior: for debugging purposes, an arbitrary asynchronous request was being triggered on each of the event handlers. When the request is made before event.completed is called, the event gets completed successfully.
I tested the following code and it works:
var globalEvent;
function eventHandler()
{
globalEvent.completed(true);
}
function dialogCallback(asyncResult)
{
_dialog = asyncResult.value;
_dialog.addEventHandler(Office.EventType.DialogEventReceived, eventHandler);
}
function ExecuteFunctionMailRead1(event)
{
globalEvent = event;
Office.context.ui.displayDialogAsync("http://contoso.com/", {height: 30, width: 20}, dialogCallback);
}
I think the problem is that you need to do:
_dialog = asyncResult.value;
instead of
_dialog = asyncResult.dialog;
I'm trying to catch jPlayer full screen event using the following code:
mainPlayer.bind($.jPlayer.event.resize, function(event) {
alert("size changed");
});
But the event isn't fired neither when I press full screen button nor when I press ESC to exit full screen mode.
Check your mainPlayer variable and make sure it references the jQuery jPlayer object. For troubleshooting, try:
$('#yourJPlayerID').bind($.jPlayer.event.resize, function(event) {
alert("size changed");
});