Use async
This commit is contained in:
parent
7de1c01fe8
commit
94944a9e2a
|
@ -45,7 +45,7 @@ namespace Dino.Plugins.WindowsNotification {
|
||||||
// https://docs.microsoft.com/en-us/previous-versions/windows/apps/hh761494(v=win.10)
|
// https://docs.microsoft.com/en-us/previous-versions/windows/apps/hh761494(v=win.10)
|
||||||
// Eventually modern adaptive templates might be desired:
|
// Eventually modern adaptive templates might be desired:
|
||||||
// https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/adaptive-interactive-toasts?tabs=builder-syntax
|
// https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/adaptive-interactive-toasts?tabs=builder-syntax
|
||||||
public ToastNotification Build() {
|
public async ToastNotification Build() {
|
||||||
ToastTemplateType templateType = _header != null ? ToastTemplateType.ToastText02 : ToastTemplateType.ToastText01;
|
ToastTemplateType templateType = _header != null ? ToastTemplateType.ToastText02 : ToastTemplateType.ToastText01;
|
||||||
if (_imagePath != null) {
|
if (_imagePath != null) {
|
||||||
if (templateType == ToastTemplateType.ToastText02) {
|
if (templateType == ToastTemplateType.ToastText02) {
|
||||||
|
@ -55,7 +55,7 @@ namespace Dino.Plugins.WindowsNotification {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var template = BuildStanzaFromXml(ToastNotificationManager.GetTemplateContent(templateType));
|
var template = yield BuildStanzaFromXml(ToastNotificationManager.GetTemplateContent(templateType));
|
||||||
{ // add header and body
|
{ // add header and body
|
||||||
var attributes = new Gee.ArrayList<StanzaAttribute>();
|
var attributes = new Gee.ArrayList<StanzaAttribute>();
|
||||||
attributes.add(new StanzaAttribute.build("", "id", "1"));
|
attributes.add(new StanzaAttribute.build("", "id", "1"));
|
||||||
|
@ -105,17 +105,10 @@ namespace Dino.Plugins.WindowsNotification {
|
||||||
return new ToastNotification(xml);
|
return new ToastNotification(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
private StanzaNode BuildStanzaFromXml(string xml) {
|
private async StanzaNode BuildStanzaFromXml(string xml) {
|
||||||
var reader = new Xmpp.StanzaReader.for_string(xml);
|
var reader = new Xmpp.StanzaReader.for_string(xml);
|
||||||
|
|
||||||
StanzaNode root_node = null;
|
StanzaNode root_node = yield reader.read_node();
|
||||||
var loop = new MainLoop();
|
|
||||||
reader.read_node
|
|
||||||
.begin((obj, res) => {
|
|
||||||
root_node = reader.read_node.end(res);
|
|
||||||
loop.quit();
|
|
||||||
});
|
|
||||||
loop.run();
|
|
||||||
|
|
||||||
ExecuteOnAllSubNodes(root_node, (node) => {
|
ExecuteOnAllSubNodes(root_node, (node) => {
|
||||||
node.ns_uri = "";
|
node.ns_uri = "";
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace Dino.Plugins.WindowsNotification {
|
||||||
string body = Markup.escape_text(conversation.counterpart.to_string());
|
string body = Markup.escape_text(conversation.counterpart.to_string());
|
||||||
|
|
||||||
var image_path = get_avatar(conversation);
|
var image_path = get_avatar(conversation);
|
||||||
var notification = new ToastNotificationBuilder()
|
var notification = yield new ToastNotificationBuilder()
|
||||||
.SetHeader(summary)
|
.SetHeader(summary)
|
||||||
.SetBody(body)
|
.SetBody(body)
|
||||||
.SetImage(image_path)
|
.SetImage(image_path)
|
||||||
|
@ -108,7 +108,7 @@ namespace Dino.Plugins.WindowsNotification {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var notification = new ToastNotificationBuilder()
|
var notification = yield new ToastNotificationBuilder()
|
||||||
.SetHeader(summary)
|
.SetHeader(summary)
|
||||||
.SetBody(body)
|
.SetBody(body)
|
||||||
.Build();
|
.Build();
|
||||||
|
@ -130,7 +130,7 @@ namespace Dino.Plugins.WindowsNotification {
|
||||||
string body = _("%s invited you to %s").printf(inviter_display_name, display_room);
|
string body = _("%s invited you to %s").printf(inviter_display_name, display_room);
|
||||||
|
|
||||||
var image_path = get_avatar(direct_conversation);
|
var image_path = get_avatar(direct_conversation);
|
||||||
var notification = new ToastNotificationBuilder()
|
var notification = yield new ToastNotificationBuilder()
|
||||||
.SetHeader(summary)
|
.SetHeader(summary)
|
||||||
.SetBody(body)
|
.SetBody(body)
|
||||||
.SetImage(image_path)
|
.SetImage(image_path)
|
||||||
|
@ -167,7 +167,7 @@ namespace Dino.Plugins.WindowsNotification {
|
||||||
string body = _("%s requests the permission to write in %s").printf(display_name, display_room);
|
string body = _("%s requests the permission to write in %s").printf(display_name, display_room);
|
||||||
|
|
||||||
var image_path = get_avatar(conversation);
|
var image_path = get_avatar(conversation);
|
||||||
var notification = new ToastNotificationBuilder()
|
var notification = yield new ToastNotificationBuilder()
|
||||||
.SetHeader(summary)
|
.SetHeader(summary)
|
||||||
.SetBody(body)
|
.SetBody(body)
|
||||||
.SetImage(image_path)
|
.SetImage(image_path)
|
||||||
|
@ -201,7 +201,7 @@ namespace Dino.Plugins.WindowsNotification {
|
||||||
}
|
}
|
||||||
|
|
||||||
var image_path = get_avatar(conversation);
|
var image_path = get_avatar(conversation);
|
||||||
var notification = new ToastNotificationBuilder()
|
var notification = yield new ToastNotificationBuilder()
|
||||||
.SetHeader(conversation_display_name)
|
.SetHeader(conversation_display_name)
|
||||||
.SetBody(body)
|
.SetBody(body)
|
||||||
.SetImage(image_path)
|
.SetImage(image_path)
|
||||||
|
|
Loading…
Reference in a new issue