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

notifications - change event names to follow conventions

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