summaryrefslogtreecommitdiffstats
path: root/ui/src/components/private-message-form.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/components/private-message-form.tsx')
-rw-r--r--ui/src/components/private-message-form.tsx10
1 files changed, 9 insertions, 1 deletions
diff --git a/ui/src/components/private-message-form.tsx b/ui/src/components/private-message-form.tsx
index 10782361..6ae7efe7 100644
--- a/ui/src/components/private-message-form.tsx
+++ b/ui/src/components/private-message-form.tsx
@@ -1,6 +1,5 @@
import { Component, linkEvent } from 'inferno';
import { Prompt } from 'inferno-router';
-import { Link } from 'inferno-router';
import { Subscription } from 'rxjs';
import { retryWhen, delay, take } from 'rxjs/operators';
import {
@@ -111,8 +110,17 @@ export class PrivateMessageForm extends Component<
setupTippy();
}
+ componentDidUpdate() {
+ if (!this.state.loading && this.state.privateMessageForm.content) {
+ window.onbeforeunload = () => true;
+ } else {
+ window.onbeforeunload = undefined;
+ }
+ }
+
componentWillUnmount() {
this.subscription.unsubscribe();
+ window.onbeforeunload = null;
}
render() {