From 878bf9ac43c9b2be940cc1527823e6a8e5079b40 Mon Sep 17 00:00:00 2001 From: LAGonauta Date: Tue, 23 Mar 2021 20:19:04 -0300 Subject: [PATCH] Allow null header, body, applogo, and image on notification builder --- .../src/toast_notification_builder.vala | 16 ++++++++-------- .../src/win_notification_provider.vala | 12 ++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/plugins/windows-notification/src/toast_notification_builder.vala b/plugins/windows-notification/src/toast_notification_builder.vala index a993955c..c976c9bc 100644 --- a/plugins/windows-notification/src/toast_notification_builder.vala +++ b/plugins/windows-notification/src/toast_notification_builder.vala @@ -41,31 +41,31 @@ namespace Dino.Plugins.WindowsNotification { return this; } - public ToastNotificationBuilder SetHeader(string header) { + public ToastNotificationBuilder SetHeader(string? header) { _header = header; return this; } - public ToastNotificationBuilder SetBody(string body) { + public ToastNotificationBuilder SetBody(string? body) { _body = body; return this; } - public ToastNotificationBuilder SetAppLogo(string applogo_path) { + public ToastNotificationBuilder SetAppLogo(string? applogo_path) { _appLogo = applogo_path; return this; } + public ToastNotificationBuilder SetInlineImage(string? image_path) { + _inlineImage = image_path; + return this; + } + public ToastNotificationBuilder SetScenario(Scenario scenario) { _scenario = scenario; return this; } - public ToastNotificationBuilder SetInlineImage(string image_path) { - _inlineImage = image_path; - return this; - } - public async ToastNotification Build() { if (!_supportsModernFeatures) { return yield BuildFromLegacyTemplate(); diff --git a/plugins/windows-notification/src/win_notification_provider.vala b/plugins/windows-notification/src/win_notification_provider.vala index d860fad8..bec7f59a 100644 --- a/plugins/windows-notification/src/win_notification_provider.vala +++ b/plugins/windows-notification/src/win_notification_provider.vala @@ -206,16 +206,12 @@ namespace Dino.Plugins.WindowsNotification { } var image_path = get_avatar(conversation); - var builder = new ToastNotificationBuilder() + var notification = yield new ToastNotificationBuilder() .SetHeader(conversation_display_name) .SetBody(body) - .SetAppLogo(image_path); - - if (inlineImagePath != null) { - builder.SetInlineImage(inlineImagePath); - } - - var notification = yield builder.Build(); + .SetAppLogo(image_path) + .SetInlineImage(inlineImagePath) + .Build(); var notification_id = generate_id(); notification.Activated((argument, user_input) => {