mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-02 12:14:48 +02:00
19 lines
518 B
TypeScript
19 lines
518 B
TypeScript
import { EVENTS } from "@notesnook/core";
|
|
import { useEffect, useState } from "react";
|
|
import Vault from "../common/vault";
|
|
import { db } from "../common/db";
|
|
|
|
export function useVault() {
|
|
const [isLocked, setIsLocked] = useState(!db.vault.unlocked);
|
|
|
|
useEffect(() => {
|
|
db.eventManager.subscribe(EVENTS.vaultLocked, () => setIsLocked(true));
|
|
db.eventManager.subscribe(EVENTS.vaultUnlocked, () => setIsLocked(false));
|
|
}, []);
|
|
|
|
return {
|
|
isVaultLocked: isLocked,
|
|
lockVault: Vault.lockVault
|
|
};
|
|
}
|