Making Share Target functional
This commit is contained in:
5
src/components/routes/404/index.tsx
Normal file
5
src/components/routes/404/index.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import { h } from "preact";
|
||||
|
||||
export default function Error404Page() {
|
||||
return <h1>Page not found!</h1>;
|
||||
}
|
@ -6,7 +6,7 @@ import Navigation from "../../../navigation";
|
||||
export default class SharePage extends Page<{ state: any }, { vault: string }> {
|
||||
text: string;
|
||||
componentWillMount() {
|
||||
let { title, text, url } = Navigation.getQuery() || {} as any;
|
||||
let { title, text, url } = this.props.state;
|
||||
let note = "";
|
||||
if (title) {
|
||||
note += title + "\n"
|
||||
@ -24,7 +24,9 @@ export default class SharePage extends Page<{ state: any }, { vault: string }> {
|
||||
|
||||
render() {
|
||||
return <VaultsPage state={undefined} selectVault onSelected={vault => {
|
||||
Navigation.setPage("/vault", { id: vault }, { entry: "true", note: this.text }, true);
|
||||
Navigation.setPage("/", undefined, undefined, true);
|
||||
Navigation.setPage("/vault", { id: vault });
|
||||
Navigation.setPage("/vault", { id: vault }, { entry: "true", note: this.text });
|
||||
}} />
|
||||
}
|
||||
}
|
||||
|
@ -74,17 +74,30 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
|
||||
}
|
||||
}
|
||||
|
||||
const deleteNote = async () => {
|
||||
Notes.delete(note._id).then(() => {
|
||||
Notifications.sendSuccess("Deleted")
|
||||
this.rawNotes = this.rawNotes.filter(e => e._id !== note._id);
|
||||
this.setState({ notes: this.state.notes.filter(e => e._id !== note._id) });
|
||||
}).catch(err => {
|
||||
Notifications.sendError(err);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
let share;
|
||||
if ((window.navigator as any).share) {
|
||||
share = <button class="uk-button" onClick={() => shareNote()}>
|
||||
share = <button class="uk-button" onClick={shareNote}>
|
||||
share
|
||||
</button>
|
||||
let context = <ContextMenu event={evt} >
|
||||
{share}
|
||||
</ContextMenu>
|
||||
|
||||
this.setState({ context });
|
||||
}
|
||||
|
||||
let context = <ContextMenu event={evt} >
|
||||
{share}
|
||||
<button class="uk-button" onClick={deleteNote}>delete</button>
|
||||
</ContextMenu>
|
||||
|
||||
this.setState({ context });
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
|
||||
{this.state.context}
|
||||
<header class="uk-background-primary">
|
||||
<span></span>
|
||||
<h3 style="display:inline" onClick={() => Navigation.setPage("/")}>Your vaults:</h3>
|
||||
<h3 style="display:inline" onClick={() => Navigation.setPage("/")}>{this.props.selectVault ? "Select Vault for share" : "Your vaults:"}</h3>
|
||||
<span></span>
|
||||
</header>
|
||||
<AddButton onClick={() => this.addButtonClick()} />
|
||||
|
Reference in New Issue
Block a user