Skip to content

Commit 35eff5c

Browse files
committed
🐰
1 parent fee2570 commit 35eff5c

File tree

6 files changed

+40
-61
lines changed

6 files changed

+40
-61
lines changed

v2/internal/frontend/desktop/darwin/Application.m

+6-25
Original file line numberDiff line numberDiff line change
@@ -389,42 +389,25 @@ void CheckNotificationAuthorization(void *inctx, int channelID) {
389389

390390
void SendNotification(void *inctx, int channelID, const char *identifier, const char *title, const char *subtitle, const char *body, const char *data_json) {
391391
WailsContext *ctx = (__bridge WailsContext*)inctx;
392-
NSString *_identifier = safeInit(identifier);
393-
NSString *_title = safeInit(title);
394-
NSString *_subtitle = safeInit(subtitle);
395-
NSString *_body = safeInit(body);
396-
NSString *_data_json = safeInit(data_json);
397-
398-
[ctx SendNotification:channelID :[_identifier UTF8String] :[_title UTF8String] :[_subtitle UTF8String] :[_body UTF8String] :[_data_json UTF8String]];
392+
[ctx SendNotification:channelID :identifier :title :subtitle :body :data_json];
399393
}
400394

401395
void SendNotificationWithActions(void *inctx, int channelID, const char *identifier, const char *title, const char *subtitle, const char *body, const char *categoryId, const char *actions_json) {
402396
WailsContext *ctx = (__bridge WailsContext*)inctx;
403-
NSString *_identifier = safeInit(identifier);
404-
NSString *_title = safeInit(title);
405-
NSString *_subtitle = safeInit(subtitle);
406-
NSString *_body = safeInit(body);
407-
NSString *_categoryId = safeInit(categoryId);
408-
NSString *_actions_json = safeInit(actions_json);
409397

410-
[ctx SendNotificationWithActions:channelID :[_identifier UTF8String] :[_title UTF8String] :[_subtitle UTF8String] :[_body UTF8String] :[_categoryId UTF8String] :[_actions_json UTF8String]];
398+
[ctx SendNotificationWithActions:channelID :identifier :title :subtitle :body :categoryId :actions_json];
411399
}
412400

413401
void RegisterNotificationCategory(void *inctx, int channelID, const char *categoryId, const char *actions_json, bool hasReplyField, const char *replyPlaceholder, const char *replyButtonTitle) {
414402
WailsContext *ctx = (__bridge WailsContext*)inctx;
415-
NSString *_categoryId = safeInit(categoryId);
416-
NSString *_actions_json = safeInit(actions_json);
417-
NSString *_replyPlaceholder = safeInit(replyPlaceholder);
418-
NSString *_replyButtonTitle = safeInit(replyButtonTitle);
419403

420-
[ctx RegisterNotificationCategory:channelID :[_categoryId UTF8String] :[_actions_json UTF8String] :hasReplyField :[_replyPlaceholder UTF8String] :[_replyButtonTitle UTF8String]];
404+
[ctx RegisterNotificationCategory:channelID :categoryId :actions_json :hasReplyField :replyPlaceholder :replyButtonTitle];
421405
}
422406

423407
void RemoveNotificationCategory(void *inctx, int channelID, const char *categoryId) {
424408
WailsContext *ctx = (__bridge WailsContext*)inctx;
425-
NSString *_categoryId = safeInit(categoryId);
426409

427-
[ctx RemoveNotificationCategory:channelID :[_categoryId UTF8String]];
410+
[ctx RemoveNotificationCategory:channelID :categoryId];
428411
}
429412

430413
void RemoveAllPendingNotifications(void *inctx) {
@@ -434,8 +417,7 @@ void RemoveAllPendingNotifications(void *inctx) {
434417

435418
void RemovePendingNotification(void *inctx, const char *identifier) {
436419
WailsContext *ctx = (__bridge WailsContext*)inctx;
437-
NSString *_identifier = safeInit(identifier);
438-
[ctx RemovePendingNotification:[_identifier UTF8String]];
420+
[ctx RemovePendingNotification:identifier];
439421
}
440422

441423
void RemoveAllDeliveredNotifications(void *inctx) {
@@ -445,8 +427,7 @@ void RemoveAllDeliveredNotifications(void *inctx) {
445427

446428
void RemoveDeliveredNotification(void *inctx, const char *identifier) {
447429
WailsContext *ctx = (__bridge WailsContext*)inctx;
448-
NSString *_identifier = safeInit(identifier);
449-
[ctx RemoveDeliveredNotification:[_identifier UTF8String]];
430+
[ctx RemoveDeliveredNotification:identifier];
450431
}
451432

452433

v2/internal/frontend/desktop/darwin/WailsContext.m

-3
Original file line numberDiff line numberDiff line change
@@ -790,9 +790,6 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
790790
completionHandler();
791791
}
792792

793-
static dispatch_once_t onceToken;
794-
795-
796793
- (bool) EnsureDelegateInitialized {
797794
if (@available(macOS 10.14, *)) {
798795
static dispatch_once_t onceToken;

v2/internal/frontend/desktop/linux/notifications.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,13 @@ func (f *Frontend) loadCategories() error {
390390
return fmt.Errorf("failed to read notification categories from disk: %w", err)
391391
}
392392

393-
categories := make(map[string]frontend.NotificationCategory)
393+
_categories := make(map[string]frontend.NotificationCategory)
394394
if err := json.Unmarshal(categoriesData, &categories); err != nil {
395395
return fmt.Errorf("failed to unmarshal notification categories: %w", err)
396396
}
397397

398398
categoriesLock.Lock()
399-
categories = categories
399+
categories = _categories
400400
categoriesLock.Unlock()
401401

402402
return nil

v2/internal/frontend/desktop/windows/notifications.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ func (f *Frontend) SendNotificationWithActions(options frontend.NotificationOpti
183183

184184
if options.CategoryID == "" || !categoryExists {
185185
fmt.Printf("Category '%s' not found, sending basic notification without actions\n", options.CategoryID)
186+
return f.SendNotification(options)
186187
}
187188

188189
n := toast.Notification{
@@ -351,7 +352,7 @@ func loadCategoriesFromRegistry() error {
351352
}
352353

353354
_categories := make(map[string]frontend.NotificationCategory)
354-
if err := json.Unmarshal([]byte(data), &categories); err != nil {
355+
if err := json.Unmarshal([]byte(data), &_categories); err != nil {
355356
return fmt.Errorf("failed to parse notification categories from registry: %w", err)
356357
}
357358

v2/pkg/commands/build/build.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,12 @@ func execBuildApplication(builder Builder, options *Options) (string, error) {
360360
pterm.Println("Done.")
361361
}
362362

363-
if runtime.GOOS == "darwin" {
363+
if runtime.GOOS == "darwin" && options.Platform == "darwin" {
364364
// On macOS, self-sign the .app bundle so notifications work
365365
printBulletPoint("Self-signing application: ")
366366
cmd := exec.Command("codesign", "--force", "--deep", "--sign", "-", options.CompiledBinary)
367367
if out, err := cmd.CombinedOutput(); err != nil {
368-
fmt.Println("Codesign failed:", string(out))
368+
return "", fmt.Errorf("codesign failed: %v – %s", err, out)
369369
}
370370
pterm.Println("Done.")
371371
}

v2/pkg/runtime/notifications.go

+28-28
Original file line numberDiff line numberDiff line change
@@ -23,71 +23,71 @@ type NotificationResponse = frontend.NotificationResponse
2323
type NotificationResult = frontend.NotificationResult
2424

2525
func InitializeNotifications(ctx context.Context) error {
26-
frontend := getFrontend(ctx)
27-
return frontend.InitializeNotifications()
26+
appFrontend := getFrontend(ctx)
27+
return appFrontend.InitializeNotifications()
2828
}
2929

3030
func IsNotificationAvailable(ctx context.Context) bool {
31-
frontend := getFrontend(ctx)
32-
return frontend.IsNotificationAvailable()
31+
appFrontend := getFrontend(ctx)
32+
return appFrontend.IsNotificationAvailable()
3333
}
3434

3535
func RequestNotificationAuthorization(ctx context.Context) (bool, error) {
36-
frontend := getFrontend(ctx)
37-
return frontend.RequestNotificationAuthorization()
36+
appFrontend := getFrontend(ctx)
37+
return appFrontend.RequestNotificationAuthorization()
3838
}
3939

4040
func CheckNotificationAuthorization(ctx context.Context) (bool, error) {
41-
frontend := getFrontend(ctx)
42-
return frontend.CheckNotificationAuthorization()
41+
appFrontend := getFrontend(ctx)
42+
return appFrontend.CheckNotificationAuthorization()
4343
}
4444

4545
func SendNotification(ctx context.Context, options frontend.NotificationOptions) error {
46-
frontend := getFrontend(ctx)
47-
return frontend.SendNotification(options)
46+
appFrontend := getFrontend(ctx)
47+
return appFrontend.SendNotification(options)
4848
}
4949

5050
func SendNotificationWithActions(ctx context.Context, options frontend.NotificationOptions) error {
51-
frontend := getFrontend(ctx)
52-
return frontend.SendNotificationWithActions(options)
51+
appFrontend := getFrontend(ctx)
52+
return appFrontend.SendNotificationWithActions(options)
5353
}
5454

5555
func RegisterNotificationCategory(ctx context.Context, category frontend.NotificationCategory) error {
56-
frontend := getFrontend(ctx)
57-
return frontend.RegisterNotificationCategory(category)
56+
appFrontend := getFrontend(ctx)
57+
return appFrontend.RegisterNotificationCategory(category)
5858
}
5959

6060
func RemoveNotificationCategory(ctx context.Context, categoryId string) error {
61-
frontend := getFrontend(ctx)
62-
return frontend.RemoveNotificationCategory(categoryId)
61+
appFrontend := getFrontend(ctx)
62+
return appFrontend.RemoveNotificationCategory(categoryId)
6363
}
6464

6565
func RemoveAllPendingNotifications(ctx context.Context) error {
66-
frontend := getFrontend(ctx)
67-
return frontend.RemoveAllPendingNotifications()
66+
appFrontend := getFrontend(ctx)
67+
return appFrontend.RemoveAllPendingNotifications()
6868
}
6969

7070
func RemovePendingNotification(ctx context.Context, identifier string) error {
71-
frontend := getFrontend(ctx)
72-
return frontend.RemovePendingNotification(identifier)
71+
appFrontend := getFrontend(ctx)
72+
return appFrontend.RemovePendingNotification(identifier)
7373
}
7474

7575
func RemoveAllDeliveredNotifications(ctx context.Context) error {
76-
frontend := getFrontend(ctx)
77-
return frontend.RemoveAllDeliveredNotifications()
76+
appFrontend := getFrontend(ctx)
77+
return appFrontend.RemoveAllDeliveredNotifications()
7878
}
7979

8080
func RemoveDeliveredNotification(ctx context.Context, identifier string) error {
81-
frontend := getFrontend(ctx)
82-
return frontend.RemoveDeliveredNotification(identifier)
81+
appFrontend := getFrontend(ctx)
82+
return appFrontend.RemoveDeliveredNotification(identifier)
8383
}
8484

8585
func RemoveNotification(ctx context.Context, identifier string) error {
86-
frontend := getFrontend(ctx)
87-
return frontend.RemoveNotification(identifier)
86+
appFrontend := getFrontend(ctx)
87+
return appFrontend.RemoveNotification(identifier)
8888
}
8989

9090
func OnNotificationResponse(ctx context.Context, callback func(result frontend.NotificationResult)) {
91-
frontend := getFrontend(ctx)
92-
frontend.OnNotificationResponse(callback)
91+
appFrontend := getFrontend(ctx)
92+
appFrontend.OnNotificationResponse(callback)
9393
}

0 commit comments

Comments
 (0)