|
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | 6 | import { Disposable, } from 'vs/base/common/lifecycle'; |
| 7 | +import { IUserData, IUserDataSyncStoreService } from 'vs/platform/userDataSync/common/userDataSync'; |
| 8 | +import { IProductService } from 'vs/platform/product/common/productService'; |
7 | 9 | import { Emitter, Event } from 'vs/base/common/event'; |
8 | | -import { IUserDataSyncStore, IUserData, UserDataSyncStoreError, toUserDataSyncStoreErrorCode, IUserDataSyncStoreService } from 'vs/platform/userDataSync/common/userDataSync'; |
9 | | -import { ILogService } from 'vs/platform/log/common/log'; |
10 | 10 |
|
11 | 11 | export class UserDataSyncStoreService extends Disposable implements IUserDataSyncStoreService { |
12 | 12 |
|
13 | 13 | _serviceBrand: any; |
14 | 14 |
|
15 | | - private userDataSyncStore: IUserDataSyncStore | null = null; |
| 15 | + get enabled(): boolean { return !!this.productService.settingsSyncStoreUrl; } |
16 | 16 |
|
17 | | - get enabled(): boolean { return !!this.userDataSyncStore; } |
18 | | - private readonly _onDidChangeEnablement: Emitter<boolean> = this._register(new Emitter<boolean>()); |
19 | | - readonly onDidChangeEnablement: Event<boolean> = this._onDidChangeEnablement.event; |
| 17 | + private _loggedIn: boolean = false; |
| 18 | + get loggedIn(): boolean { return this._loggedIn; } |
| 19 | + private readonly _onDidChangeLoggedIn: Emitter<boolean> = this._register(new Emitter<boolean>()); |
| 20 | + readonly onDidChangeLoggedIn: Event<boolean> = this._onDidChangeLoggedIn.event; |
20 | 21 |
|
21 | 22 | constructor( |
22 | | - @ILogService private logService: ILogService |
| 23 | + @IProductService private readonly productService: IProductService, |
23 | 24 | ) { |
24 | 25 | super(); |
25 | 26 | } |
26 | 27 |
|
27 | | - registerUserDataSyncStore(userDataSyncStore: IUserDataSyncStore): void { |
28 | | - if (this.userDataSyncStore) { |
29 | | - this.logService.warn(`A user data sync store '${this.userDataSyncStore.name}' already registered. Hence ignoring the newly registered '${userDataSyncStore.name}' store.`); |
30 | | - return; |
31 | | - } |
32 | | - this.userDataSyncStore = userDataSyncStore; |
33 | | - this._onDidChangeEnablement.fire(true); |
| 28 | + async login(): Promise<void> { |
34 | 29 | } |
35 | 30 |
|
36 | | - deregisterUserDataSyncStore(): void { |
37 | | - this.userDataSyncStore = null; |
38 | | - this._onDidChangeEnablement.fire(false); |
| 31 | + async logout(): Promise<void> { |
39 | 32 | } |
40 | 33 |
|
41 | | - read(key: string): Promise<IUserData | null> { |
42 | | - if (!this.userDataSyncStore) { |
43 | | - throw new Error('No user sync store exists.'); |
| 34 | + async read(key: string): Promise<IUserData | null> { |
| 35 | + if (!this.enabled) { |
| 36 | + return Promise.reject(new Error('No settings sync store url configured.')); |
44 | 37 | } |
45 | | - return this.userDataSyncStore.read(key) |
46 | | - .then(null, error => Promise.reject(new UserDataSyncStoreError(error.message, toUserDataSyncStoreErrorCode(error)))); |
| 38 | + return null; |
47 | 39 | } |
48 | 40 |
|
49 | | - write(key: string, content: string, ref: string | null): Promise<string> { |
50 | | - if (!this.userDataSyncStore) { |
51 | | - throw new Error('No user sync store exists.'); |
| 41 | + async write(key: string, content: string, ref: string | null): Promise<string> { |
| 42 | + if (!this.enabled) { |
| 43 | + return Promise.reject(new Error('No settings sync store url configured.')); |
52 | 44 | } |
53 | | - return this.userDataSyncStore.write(key, content, ref) |
54 | | - .then(null, error => Promise.reject(new UserDataSyncStoreError(error.message, toUserDataSyncStoreErrorCode(error)))); |
| 45 | + return ''; |
55 | 46 | } |
56 | 47 |
|
57 | 48 | } |
0 commit comments