fix: desktop interop

This commit is contained in:
Baptiste Grob
2020-09-03 23:33:11 +02:00
parent 568fb14f3a
commit 35fe78e49e
4 changed files with 47 additions and 58 deletions

View File

@@ -1,13 +1,24 @@
import { PurePayload, Environment } from "snjs";
/** Platform-specific (i-e Electron/browser) behavior is handled by a Bridge object. */
export interface Bridge {
environment: Environment,
getKeychainValue(): Promise<unknown>;
setKeychainValue(value: any): Promise<void>;
clearKeychainValue(): Promise<void>;
extensionsServerHost?: string;
syncComponents(payloads: PurePayload[]): void;
onMajorDataChange(): void;
onInitialDataLoad(): void;
onSearch(text?: string): void;
}
const KEYCHAIN_STORAGE_KEY = 'keychain';
export class BrowserBridge implements Bridge {
environment = Environment.Web;
async getKeychainValue(): Promise<unknown> {
const value = localStorage.getItem(KEYCHAIN_STORAGE_KEY);
@@ -23,4 +34,15 @@ export class BrowserBridge implements Bridge {
async clearKeychainValue(): Promise<void> {
localStorage.removeItem(KEYCHAIN_STORAGE_KEY);
}
/** No-ops */
syncComponents() {
}
onMajorDataChange() {
}
onInitialDataLoad() {
}
onSearch() {
}
}