提交 3213a344 编写于 作者: B Benjamin Pasero

notifications - sync "do not show again" preference (#93332)

上级 7279524b
......@@ -11,6 +11,7 @@ import { Event } from 'vs/base/common/event';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IAction, Action } from 'vs/base/common/actions';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
export class NotificationService extends Disposable implements INotificationService {
......@@ -19,7 +20,10 @@ export class NotificationService extends Disposable implements INotificationServ
private _model: INotificationsModel = this._register(new NotificationsModel());
get model(): INotificationsModel { return this._model; }
constructor(@IStorageService private readonly storageService: IStorageService) {
constructor(
@IStorageService private readonly storageService: IStorageService,
@IStorageKeysSyncRegistryService private readonly storageKeysSyncRegistryService: IStorageKeysSyncRegistryService
) {
super();
}
......@@ -64,10 +68,15 @@ export class NotificationService extends Disposable implements INotificationServ
let handle: INotificationHandle;
if (notification.neverShowAgain) {
const scope = notification.neverShowAgain.scope === NeverShowAgainScope.WORKSPACE ? StorageScope.WORKSPACE : StorageScope.GLOBAL;
const id = notification.neverShowAgain.id;
// opt-in to syncing if global
if (scope === StorageScope.GLOBAL) {
this.storageKeysSyncRegistryService.registerStorageKey({ key: id, version: 1 });
}
// If the user already picked to not show the notification
// again, we return with a no-op notification here
const id = notification.neverShowAgain.id;
if (this.storageService.getBoolean(id, scope)) {
return new NoOpNotification();
}
......@@ -115,10 +124,15 @@ export class NotificationService extends Disposable implements INotificationServ
// Handle neverShowAgain option accordingly
if (options?.neverShowAgain) {
const scope = options.neverShowAgain.scope === NeverShowAgainScope.WORKSPACE ? StorageScope.WORKSPACE : StorageScope.GLOBAL;
const id = options.neverShowAgain.id;
// opt-in to syncing if global
if (scope === StorageScope.GLOBAL) {
this.storageKeysSyncRegistryService.registerStorageKey({ key: id, version: 1 });
}
// If the user already picked to not show the notification
// again, we return with a no-op notification here
const id = options.neverShowAgain.id;
if (this.storageService.getBoolean(id, scope)) {
return new NoOpNotification();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册