提交 12215af8 编写于 作者: B Benjamin Pasero

notifications - change event names to follow conventions

上级 cce81b98
...@@ -23,10 +23,10 @@ export class NotificationsAlerts extends Disposable { ...@@ -23,10 +23,10 @@ export class NotificationsAlerts extends Disposable {
} }
private registerListeners(): void { private registerListeners(): void {
this._register(this.model.onDidNotificationChange(e => this.onDidNotificationChange(e))); this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e)));
} }
private onDidNotificationChange(e: INotificationChangeEvent): void { private onDidChangeNotification(e: INotificationChangeEvent): void {
if (e.kind === NotificationChangeType.ADD) { if (e.kind === NotificationChangeType.ADD) {
// ARIA alert for screen readers // ARIA alert for screen readers
...@@ -46,7 +46,7 @@ export class NotificationsAlerts extends Disposable { ...@@ -46,7 +46,7 @@ export class NotificationsAlerts extends Disposable {
private triggerAriaAlert(notifiation: INotificationViewItem): void { private triggerAriaAlert(notifiation: INotificationViewItem): void {
// Trigger the alert again whenever the label changes // Trigger the alert again whenever the label changes
const listener = notifiation.onDidLabelChange(e => { const listener = notifiation.onDidChangeLabel(e => {
if (e.kind === NotificationViewItemLabelKind.MESSAGE) { if (e.kind === NotificationViewItemLabelKind.MESSAGE) {
this.doTriggerAriaAlert(notifiation); this.doTriggerAriaAlert(notifiation);
} }
...@@ -69,4 +69,4 @@ export class NotificationsAlerts extends Disposable { ...@@ -69,4 +69,4 @@ export class NotificationsAlerts extends Disposable {
alert(alertText); alert(alertText);
} }
} }
\ No newline at end of file
...@@ -58,7 +58,7 @@ export class NotificationsCenter extends Themable { ...@@ -58,7 +58,7 @@ export class NotificationsCenter extends Themable {
} }
private registerListeners(): void { private registerListeners(): void {
this._register(this.model.onDidNotificationChange(e => this.onDidNotificationChange(e))); this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e)));
this._register(this.layoutService.onLayout(dimension => this.layout(dimension))); this._register(this.layoutService.onLayout(dimension => this.layout(dimension)));
} }
...@@ -167,7 +167,7 @@ export class NotificationsCenter extends Themable { ...@@ -167,7 +167,7 @@ export class NotificationsCenter extends Themable {
return keybinding ? keybinding.getLabel() : null; return keybinding ? keybinding.getLabel() : null;
} }
private onDidNotificationChange(e: INotificationChangeEvent): void { private onDidChangeNotification(e: INotificationChangeEvent): void {
if (!this._isVisible) { if (!this._isVisible) {
return; // only if visible return; // only if visible
} }
......
...@@ -34,11 +34,11 @@ export class NotificationsStatus extends Disposable { ...@@ -34,11 +34,11 @@ export class NotificationsStatus extends Disposable {
} }
private registerListeners(): void { private registerListeners(): void {
this._register(this.model.onDidNotificationChange(e => this.onDidNotificationChange(e))); this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e)));
this._register(this.model.onDidStatusMessageChange(e => this.onDidStatusMessageChange(e))); this._register(this.model.onDidChangeStatusMessage(e => this.onDidChangeStatusMessage(e)));
} }
private onDidNotificationChange(e: INotificationChangeEvent): void { private onDidChangeNotification(e: INotificationChangeEvent): void {
if (this.isNotificationsCenterVisible) { if (this.isNotificationsCenterVisible) {
return; // no change if notification center is visible return; // no change if notification center is visible
} }
...@@ -101,7 +101,7 @@ export class NotificationsStatus extends Disposable { ...@@ -101,7 +101,7 @@ export class NotificationsStatus extends Disposable {
} }
} }
private onDidStatusMessageChange(e: IStatusMessageChangeEvent): void { private onDidChangeStatusMessage(e: IStatusMessageChangeEvent): void {
const statusItem = e.item; const statusItem = e.item;
switch (e.kind) { switch (e.kind) {
......
...@@ -90,11 +90,11 @@ export class NotificationsToasts extends Themable { ...@@ -90,11 +90,11 @@ export class NotificationsToasts extends Themable {
this.model.notifications.forEach(notification => this.addToast(notification)); this.model.notifications.forEach(notification => this.addToast(notification));
// Update toasts on notification changes // Update toasts on notification changes
this._register(this.model.onDidNotificationChange(e => this.onDidNotificationChange(e))); this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e)));
}); });
// Filter // Filter
this._register(this.model.onDidFilterChange(filter => { this._register(this.model.onDidChangeFilter(filter => {
if (filter === NotificationsFilter.SILENT || filter === NotificationsFilter.ERROR) { if (filter === NotificationsFilter.SILENT || filter === NotificationsFilter.ERROR) {
this.hide(); this.hide();
} }
...@@ -114,7 +114,7 @@ export class NotificationsToasts extends Themable { ...@@ -114,7 +114,7 @@ export class NotificationsToasts extends Themable {
]); ]);
} }
private onDidNotificationChange(e: INotificationChangeEvent): void { private onDidChangeNotification(e: INotificationChangeEvent): void {
switch (e.kind) { switch (e.kind) {
case NotificationChangeType.ADD: case NotificationChangeType.ADD:
return this.addToast(e.item); return this.addToast(e.item);
...@@ -194,12 +194,12 @@ export class NotificationsToasts extends Themable { ...@@ -194,12 +194,12 @@ export class NotificationsToasts extends Themable {
this.layoutContainer(maxDimensions.height); this.layoutContainer(maxDimensions.height);
// Update when item height changes due to expansion // Update when item height changes due to expansion
itemDisposables.add(item.onDidExpansionChange(() => { itemDisposables.add(item.onDidChangeExpansion(() => {
notificationList.updateNotificationsList(0, 1, [item]); notificationList.updateNotificationsList(0, 1, [item]);
})); }));
// Update when item height potentially changes due to label changes // Update when item height potentially changes due to label changes
itemDisposables.add(item.onDidLabelChange(e => { itemDisposables.add(item.onDidChangeLabel(e => {
if (!item.expanded) { if (!item.expanded) {
return; // dynamic height only applies to expanded notifications return; // dynamic height only applies to expanded notifications
} }
......
...@@ -345,7 +345,7 @@ export class NotificationTemplateRenderer extends Disposable { ...@@ -345,7 +345,7 @@ export class NotificationTemplateRenderer extends Disposable {
this.renderProgress(notification); this.renderProgress(notification);
// Label Change Events // Label Change Events
this.inputDisposables.add(notification.onDidLabelChange(event => { this.inputDisposables.add(notification.onDidChangeLabel(event => {
switch (event.kind) { switch (event.kind) {
case NotificationViewItemLabelKind.SEVERITY: case NotificationViewItemLabelKind.SEVERITY:
this.renderSeverity(notification); this.renderSeverity(notification);
......
...@@ -20,8 +20,8 @@ export interface INotificationsModel { ...@@ -20,8 +20,8 @@ export interface INotificationsModel {
readonly notifications: INotificationViewItem[]; readonly notifications: INotificationViewItem[];
readonly onDidNotificationChange: Event<INotificationChangeEvent>; readonly onDidChangeNotification: Event<INotificationChangeEvent>;
readonly onDidFilterChange: Event<NotificationsFilter>; readonly onDidChangeFilter: Event<NotificationsFilter>;
addNotification(notification: INotification): INotificationHandle; addNotification(notification: INotification): INotificationHandle;
...@@ -34,7 +34,7 @@ export interface INotificationsModel { ...@@ -34,7 +34,7 @@ export interface INotificationsModel {
readonly statusMessage: IStatusMessageViewItem | undefined; readonly statusMessage: IStatusMessageViewItem | undefined;
readonly onDidStatusMessageChange: Event<IStatusMessageChangeEvent>; readonly onDidChangeStatusMessage: Event<IStatusMessageChangeEvent>;
showStatusMessage(message: NotificationMessage, options?: IStatusMessageOptions): IDisposable; showStatusMessage(message: NotificationMessage, options?: IStatusMessageOptions): IDisposable;
...@@ -134,14 +134,14 @@ export class NotificationsModel extends Disposable implements INotificationsMode ...@@ -134,14 +134,14 @@ export class NotificationsModel extends Disposable implements INotificationsMode
private static readonly NO_OP_NOTIFICATION = new NoOpNotification(); private static readonly NO_OP_NOTIFICATION = new NoOpNotification();
private readonly _onDidNotificationChange = this._register(new Emitter<INotificationChangeEvent>()); private readonly _onDidChangeNotification = this._register(new Emitter<INotificationChangeEvent>());
readonly onDidNotificationChange = this._onDidNotificationChange.event; readonly onDidChangeNotification = this._onDidChangeNotification.event;
private readonly _onDidStatusMessageChange = this._register(new Emitter<IStatusMessageChangeEvent>()); private readonly _onDidChangeStatusMessage = this._register(new Emitter<IStatusMessageChangeEvent>());
readonly onDidStatusMessageChange = this._onDidStatusMessageChange.event; readonly onDidChangeStatusMessage = this._onDidChangeStatusMessage.event;
private readonly _onDidFilterChange = this._register(new Emitter<NotificationsFilter>()); private readonly _onDidChangeFilter = this._register(new Emitter<NotificationsFilter>());
readonly onDidFilterChange = this._onDidFilterChange.event; readonly onDidChangeFilter = this._onDidChangeFilter.event;
private readonly _notifications: INotificationViewItem[] = []; private readonly _notifications: INotificationViewItem[] = [];
get notifications(): INotificationViewItem[] { return this._notifications; } get notifications(): INotificationViewItem[] { return this._notifications; }
...@@ -154,7 +154,7 @@ export class NotificationsModel extends Disposable implements INotificationsMode ...@@ -154,7 +154,7 @@ export class NotificationsModel extends Disposable implements INotificationsMode
setFilter(filter: NotificationsFilter): void { setFilter(filter: NotificationsFilter): void {
this.filter = filter; this.filter = filter;
this._onDidFilterChange.fire(filter); this._onDidChangeFilter.fire(filter);
} }
addNotification(notification: INotification): INotificationHandle { addNotification(notification: INotification): INotificationHandle {
...@@ -173,7 +173,7 @@ export class NotificationsModel extends Disposable implements INotificationsMode ...@@ -173,7 +173,7 @@ export class NotificationsModel extends Disposable implements INotificationsMode
this._notifications.splice(0, 0, item); this._notifications.splice(0, 0, item);
// Events // Events
this._onDidNotificationChange.fire({ item, index: 0, kind: NotificationChangeType.ADD }); this._onDidChangeNotification.fire({ item, index: 0, kind: NotificationChangeType.ADD });
// Wrap into handle // Wrap into handle
return new NotificationHandle(item, item => this.onClose(item)); return new NotificationHandle(item, item => this.onClose(item));
...@@ -202,13 +202,13 @@ export class NotificationsModel extends Disposable implements INotificationsMode ...@@ -202,13 +202,13 @@ export class NotificationsModel extends Disposable implements INotificationsMode
const onItemChangeEvent = () => { const onItemChangeEvent = () => {
const index = this._notifications.indexOf(item); const index = this._notifications.indexOf(item);
if (index >= 0) { if (index >= 0) {
this._onDidNotificationChange.fire({ item, index, kind: NotificationChangeType.CHANGE }); this._onDidChangeNotification.fire({ item, index, kind: NotificationChangeType.CHANGE });
} }
}; };
const itemExpansionChangeListener = item.onDidExpansionChange(() => onItemChangeEvent()); const itemExpansionChangeListener = item.onDidChangeExpansion(() => onItemChangeEvent());
const itemLabelChangeListener = item.onDidLabelChange(e => { const itemLabelChangeListener = item.onDidChangeLabel(e => {
// a label change in the area of actions or the message is a change that potentially has an impact // a label change in the area of actions or the message is a change that potentially has an impact
// on the size of the notification and as such we emit a change event so that viewers can redraw // on the size of the notification and as such we emit a change event so that viewers can redraw
if (e.kind === NotificationViewItemLabelKind.ACTIONS || e.kind === NotificationViewItemLabelKind.MESSAGE) { if (e.kind === NotificationViewItemLabelKind.ACTIONS || e.kind === NotificationViewItemLabelKind.MESSAGE) {
...@@ -223,7 +223,7 @@ export class NotificationsModel extends Disposable implements INotificationsMode ...@@ -223,7 +223,7 @@ export class NotificationsModel extends Disposable implements INotificationsMode
const index = this._notifications.indexOf(item); const index = this._notifications.indexOf(item);
if (index >= 0) { if (index >= 0) {
this._notifications.splice(index, 1); this._notifications.splice(index, 1);
this._onDidNotificationChange.fire({ item, index, kind: NotificationChangeType.REMOVE }); this._onDidChangeNotification.fire({ item, index, kind: NotificationChangeType.REMOVE });
} }
}); });
...@@ -238,14 +238,14 @@ export class NotificationsModel extends Disposable implements INotificationsMode ...@@ -238,14 +238,14 @@ export class NotificationsModel extends Disposable implements INotificationsMode
// Remember as current status message and fire events // Remember as current status message and fire events
this._statusMessage = item; this._statusMessage = item;
this._onDidStatusMessageChange.fire({ kind: StatusMessageChangeType.ADD, item }); this._onDidChangeStatusMessage.fire({ kind: StatusMessageChangeType.ADD, item });
return toDisposable(() => { return toDisposable(() => {
// Only reset status message if the item is still the one we had remembered // Only reset status message if the item is still the one we had remembered
if (this._statusMessage === item) { if (this._statusMessage === item) {
this._statusMessage = undefined; this._statusMessage = undefined;
this._onDidStatusMessageChange.fire({ kind: StatusMessageChangeType.REMOVE, item }); this._onDidChangeStatusMessage.fire({ kind: StatusMessageChangeType.REMOVE, item });
} }
}); });
} }
...@@ -263,9 +263,9 @@ export interface INotificationViewItem { ...@@ -263,9 +263,9 @@ export interface INotificationViewItem {
readonly expanded: boolean; readonly expanded: boolean;
readonly canCollapse: boolean; readonly canCollapse: boolean;
readonly onDidExpansionChange: Event<void>; readonly onDidChangeExpansion: Event<void>;
readonly onDidClose: Event<void>; readonly onDidClose: Event<void>;
readonly onDidLabelChange: Event<INotificationViewItemLabelChangeEvent>; readonly onDidChangeLabel: Event<INotificationViewItemLabelChangeEvent>;
expand(): void; expand(): void;
collapse(skipEvents?: boolean): void; collapse(skipEvents?: boolean): void;
...@@ -410,14 +410,14 @@ export class NotificationViewItem extends Disposable implements INotificationVie ...@@ -410,14 +410,14 @@ export class NotificationViewItem extends Disposable implements INotificationVie
private _actions: INotificationActions | undefined; private _actions: INotificationActions | undefined;
private _progress: NotificationViewItemProgress | undefined; private _progress: NotificationViewItemProgress | undefined;
private readonly _onDidExpansionChange = this._register(new Emitter<void>()); private readonly _onDidChangeExpansion = this._register(new Emitter<void>());
readonly onDidExpansionChange = this._onDidExpansionChange.event; readonly onDidChangeExpansion = this._onDidChangeExpansion.event;
private readonly _onDidClose = this._register(new Emitter<void>()); private readonly _onDidClose = this._register(new Emitter<void>());
readonly onDidClose = this._onDidClose.event; readonly onDidClose = this._onDidClose.event;
private readonly _onDidLabelChange = this._register(new Emitter<INotificationViewItemLabelChangeEvent>()); private readonly _onDidChangeLabel = this._register(new Emitter<INotificationViewItemLabelChangeEvent>());
readonly onDidLabelChange = this._onDidLabelChange.event; readonly onDidChangeLabel = this._onDidChangeLabel.event;
static create(notification: INotification, filter: NotificationsFilter = NotificationsFilter.OFF): INotificationViewItem | undefined { static create(notification: INotification, filter: NotificationsFilter = NotificationsFilter.OFF): INotificationViewItem | undefined {
if (!notification || !notification.message || isPromiseCanceledError(notification.message)) { if (!notification || !notification.message || isPromiseCanceledError(notification.message)) {
...@@ -566,7 +566,7 @@ export class NotificationViewItem extends Disposable implements INotificationVie ...@@ -566,7 +566,7 @@ export class NotificationViewItem extends Disposable implements INotificationVie
get progress(): INotificationViewItemProgress { get progress(): INotificationViewItemProgress {
if (!this._progress) { if (!this._progress) {
this._progress = this._register(new NotificationViewItemProgress()); this._progress = this._register(new NotificationViewItemProgress());
this._register(this._progress.onDidChange(() => this._onDidLabelChange.fire({ kind: NotificationViewItemLabelKind.PROGRESS }))); this._register(this._progress.onDidChange(() => this._onDidChangeLabel.fire({ kind: NotificationViewItemLabelKind.PROGRESS })));
} }
return this._progress; return this._progress;
...@@ -586,7 +586,7 @@ export class NotificationViewItem extends Disposable implements INotificationVie ...@@ -586,7 +586,7 @@ export class NotificationViewItem extends Disposable implements INotificationVie
updateSeverity(severity: Severity): void { updateSeverity(severity: Severity): void {
this._severity = severity; this._severity = severity;
this._onDidLabelChange.fire({ kind: NotificationViewItemLabelKind.SEVERITY }); this._onDidChangeLabel.fire({ kind: NotificationViewItemLabelKind.SEVERITY });
} }
updateMessage(input: NotificationMessage): void { updateMessage(input: NotificationMessage): void {
...@@ -596,13 +596,13 @@ export class NotificationViewItem extends Disposable implements INotificationVie ...@@ -596,13 +596,13 @@ export class NotificationViewItem extends Disposable implements INotificationVie
} }
this._message = message; this._message = message;
this._onDidLabelChange.fire({ kind: NotificationViewItemLabelKind.MESSAGE }); this._onDidChangeLabel.fire({ kind: NotificationViewItemLabelKind.MESSAGE });
} }
updateActions(actions?: INotificationActions): void { updateActions(actions?: INotificationActions): void {
this.setActions(actions); this.setActions(actions);
this._onDidLabelChange.fire({ kind: NotificationViewItemLabelKind.ACTIONS }); this._onDidChangeLabel.fire({ kind: NotificationViewItemLabelKind.ACTIONS });
} }
expand(): void { expand(): void {
...@@ -611,7 +611,7 @@ export class NotificationViewItem extends Disposable implements INotificationVie ...@@ -611,7 +611,7 @@ export class NotificationViewItem extends Disposable implements INotificationVie
} }
this._expanded = true; this._expanded = true;
this._onDidExpansionChange.fire(); this._onDidChangeExpansion.fire();
} }
collapse(skipEvents?: boolean): void { collapse(skipEvents?: boolean): void {
...@@ -622,7 +622,7 @@ export class NotificationViewItem extends Disposable implements INotificationVie ...@@ -622,7 +622,7 @@ export class NotificationViewItem extends Disposable implements INotificationVie
this._expanded = false; this._expanded = false;
if (!skipEvents) { if (!skipEvents) {
this._onDidExpansionChange.fire(); this._onDidChangeExpansion.fire();
} }
} }
......
...@@ -41,7 +41,7 @@ suite('Notifications', () => { ...@@ -41,7 +41,7 @@ suite('Notifications', () => {
// Events // Events
let called = 0; let called = 0;
item1.onDidExpansionChange(() => { item1.onDidChangeExpansion(() => {
called++; called++;
}); });
...@@ -53,7 +53,7 @@ suite('Notifications', () => { ...@@ -53,7 +53,7 @@ suite('Notifications', () => {
assert.equal(called, 2); assert.equal(called, 2);
called = 0; called = 0;
item1.onDidLabelChange(e => { item1.onDidChangeLabel(e => {
if (e.kind === NotificationViewItemLabelKind.PROGRESS) { if (e.kind === NotificationViewItemLabelKind.PROGRESS) {
called++; called++;
} }
...@@ -65,7 +65,7 @@ suite('Notifications', () => { ...@@ -65,7 +65,7 @@ suite('Notifications', () => {
assert.equal(called, 2); assert.equal(called, 2);
called = 0; called = 0;
item1.onDidLabelChange(e => { item1.onDidChangeLabel(e => {
if (e.kind === NotificationViewItemLabelKind.MESSAGE) { if (e.kind === NotificationViewItemLabelKind.MESSAGE) {
called++; called++;
} }
...@@ -74,7 +74,7 @@ suite('Notifications', () => { ...@@ -74,7 +74,7 @@ suite('Notifications', () => {
item1.updateMessage('message update'); item1.updateMessage('message update');
called = 0; called = 0;
item1.onDidLabelChange(e => { item1.onDidChangeLabel(e => {
if (e.kind === NotificationViewItemLabelKind.SEVERITY) { if (e.kind === NotificationViewItemLabelKind.SEVERITY) {
called++; called++;
} }
...@@ -83,7 +83,7 @@ suite('Notifications', () => { ...@@ -83,7 +83,7 @@ suite('Notifications', () => {
item1.updateSeverity(Severity.Error); item1.updateSeverity(Severity.Error);
called = 0; called = 0;
item1.onDidLabelChange(e => { item1.onDidChangeLabel(e => {
if (e.kind === NotificationViewItemLabelKind.ACTIONS) { if (e.kind === NotificationViewItemLabelKind.ACTIONS) {
called++; called++;
} }
...@@ -146,12 +146,12 @@ suite('Notifications', () => { ...@@ -146,12 +146,12 @@ suite('Notifications', () => {
const model = new NotificationsModel(); const model = new NotificationsModel();
let lastNotificationEvent!: INotificationChangeEvent; let lastNotificationEvent!: INotificationChangeEvent;
model.onDidNotificationChange(e => { model.onDidChangeNotification(e => {
lastNotificationEvent = e; lastNotificationEvent = e;
}); });
let lastStatusMessageEvent!: IStatusMessageChangeEvent; let lastStatusMessageEvent!: IStatusMessageChangeEvent;
model.onDidStatusMessageChange(e => { model.onDidChangeStatusMessage(e => {
lastStatusMessageEvent = e; lastStatusMessageEvent = e;
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册