Skip to content

Commit 36e4b3c

Browse files
committed
refactor: change Notification prop name code to name type
1 parent 8899318 commit 36e4b3c

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

src/messageComposer/attachmentManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ export class AttachmentManager {
386386
this.client.notifications.addError({
387387
message: 'File is required for upload attachment',
388388
origin: { emitter: 'AttachmentManager', context: { attachment } },
389-
options: { code: 'validation:attachment:file:missing' },
389+
options: { type: 'validation:attachment:file:missing' },
390390
});
391391
return;
392392
}
@@ -458,7 +458,7 @@ export class AttachmentManager {
458458
context: { attachment, blockedAttachment: localAttachment },
459459
},
460460
options: {
461-
code: 'validation:attachment:upload:blocked',
461+
type: 'validation:attachment:upload:blocked',
462462
metadata: {
463463
reason: localAttachment.localMetadata.uploadPermissionCheck?.reason,
464464
},
@@ -497,7 +497,7 @@ export class AttachmentManager {
497497
context: { attachment, failedAttachment },
498498
},
499499
options: {
500-
code: 'api:attachment:upload:failed',
500+
type: 'api:attachment:upload:failed',
501501
metadata: { reason },
502502
originalError: error instanceof Error ? error : undefined,
503503
},

src/messageComposer/messageComposer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ export class MessageComposer extends WithSubscriptions {
675675
context: { composer: this },
676676
},
677677
options: {
678-
code: 'api:poll:create:failed',
678+
type: 'api:poll:create:failed',
679679
metadata: {
680680
reason: (error as Error).message,
681681
},

src/notifications/NotificationManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class NotificationManager {
4949
id,
5050
message,
5151
origin,
52-
code: options?.code,
52+
type: options?.type,
5353
severity,
5454
createdAt: now,
5555
expiresAt: now + duration,

src/notifications/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export type Notification = {
7878
* 'system:internal:error' // Internal system error
7979
* 'system:resource:unavailable'; // System resource unavailable
8080
*/
81-
code?: string;
81+
type?: string;
8282
/** Optional timestamp when notification should expire */
8383
expiresAt?: number;
8484
/** Optional metadata to attach to the notification */
@@ -89,7 +89,7 @@ export type Notification = {
8989

9090
/** Configuration options when creating a notification */
9191
export type NotificationOptions = Partial<
92-
Pick<Notification, 'code' | 'severity' | 'actions' | 'metadata' | 'originalError'>
92+
Pick<Notification, 'type' | 'severity' | 'actions' | 'metadata' | 'originalError'>
9393
> & {
9494
/** How long a notification should be displayed in milliseconds */
9595
duration?: number;

test/unit/MessageComposer/attachmentManager.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ describe('AttachmentManager', () => {
10481048
},
10491049
},
10501050
options: {
1051-
code: 'api:attachment:upload:failed',
1051+
type: 'api:attachment:upload:failed',
10521052
metadata: { reason: 'Upload failed' },
10531053
originalError: expect.any(Error),
10541054
},
@@ -1089,7 +1089,7 @@ describe('AttachmentManager', () => {
10891089
},
10901090
},
10911091
options: {
1092-
code: 'validation:attachment:upload:blocked',
1092+
type: 'validation:attachment:upload:blocked',
10931093
metadata: { reason: 'size_limit' },
10941094
},
10951095
});
@@ -1168,7 +1168,7 @@ describe('AttachmentManager', () => {
11681168
expect(mockClient.notifications.addError).toHaveBeenCalledWith({
11691169
message: 'File is required for upload attachment',
11701170
options: {
1171-
code: 'validation:attachment:file:missing',
1171+
type: 'validation:attachment:file:missing',
11721172
},
11731173
origin: {
11741174
emitter: 'AttachmentManager',
@@ -1202,7 +1202,7 @@ describe('AttachmentManager', () => {
12021202
expect(mockClient.notifications.addError).toHaveBeenCalledWith({
12031203
message: 'File is required for upload attachment',
12041204
options: {
1205-
code: 'validation:attachment:file:missing',
1205+
type: 'validation:attachment:file:missing',
12061206
},
12071207
origin: {
12081208
emitter: 'AttachmentManager',

test/unit/MessageComposer/messageComposer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ describe('MessageComposer', () => {
760760
context: { composer: messageComposer },
761761
},
762762
options: {
763-
code: 'api:poll:create:failed',
763+
type: 'api:poll:create:failed',
764764
metadata: {
765765
reason: 'Failed to create poll',
766766
},

0 commit comments

Comments
 (0)