37 lines
1.0 KiB
TypeScript
Executable File
37 lines
1.0 KiB
TypeScript
Executable File
import { h } from "preact"
|
|
import { Page } from "../../../page";
|
|
import Notes, { IVault, BaseNote } from "../../../notes";
|
|
import Navigation from "../../../navigation";
|
|
import EntryComponent from "./Entry";
|
|
import EntryList from "./EntryList";
|
|
|
|
import "./vault.scss"
|
|
|
|
export interface VaultProps {
|
|
state: { id: string };
|
|
hidden: { entry: string, id: string };
|
|
}
|
|
|
|
export default class VaultPage extends Page<VaultProps, { entries: BaseNote[] }> {
|
|
vault: Promise<IVault>
|
|
constructor(props: VaultProps) {
|
|
super(props);
|
|
this.state = { entries: [] };
|
|
}
|
|
|
|
async componentWillMount() {
|
|
this.vault = Notes.getVault(this.props.state.id, Notes.getVaultKey(this.props.state.id))
|
|
|
|
this.vault.catch(err => {
|
|
Navigation.setPage("/")
|
|
})
|
|
}
|
|
|
|
render() {
|
|
if (this.props.hidden && this.props.hidden.entry === "true") {
|
|
return <EntryComponent vault={this.vault} id={this.props.hidden.id} />
|
|
} else {
|
|
return <EntryList vault={this.vault} />
|
|
}
|
|
}
|
|
} |