fix: desktop interop
This commit is contained in:
@@ -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() {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user