mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-29 02:10:59 -05:00
Make sure to focus window for desktop notifs.
Prevent empty pastes of files. Log push errors.
This commit is contained in:
parent
548826527c
commit
e98a962071
3 changed files with 30 additions and 23 deletions
|
@ -263,6 +263,8 @@ function MessageBox({ channel, draft, dispatcher }: Props) {
|
||||||
onChange={files => setUploadState({ type: "attached", files })}
|
onChange={files => setUploadState({ type: "attached", files })}
|
||||||
cancel={() => uploadState.type === 'uploading' && uploadState.cancel.cancel("cancel")}
|
cancel={() => uploadState.type === 'uploading' && uploadState.cancel.cancel("cancel")}
|
||||||
append={files => {
|
append={files => {
|
||||||
|
if (files.length === 0) return;
|
||||||
|
|
||||||
if (uploadState.type === 'none') {
|
if (uploadState.type === 'none') {
|
||||||
setUploadState({ type: 'attached', files });
|
setUploadState({ type: 'attached', files });
|
||||||
} else if (uploadState.type === 'attached') {
|
} else if (uploadState.type === 'attached') {
|
||||||
|
|
|
@ -136,6 +136,7 @@ function Notifier(props: Props) {
|
||||||
|
|
||||||
if (notif) {
|
if (notif) {
|
||||||
notif.addEventListener("click", () => {
|
notif.addEventListener("click", () => {
|
||||||
|
window.focus();
|
||||||
const id = msg.channel;
|
const id = msg.channel;
|
||||||
if (id !== channel_id) {
|
if (id !== channel_id) {
|
||||||
let channel = client.channels.get(id);
|
let channel = client.channels.get(id);
|
||||||
|
|
|
@ -62,6 +62,7 @@ export function Component(props: Props & WithDispatcher) {
|
||||||
disabled={typeof pushEnabled === "undefined"}
|
disabled={typeof pushEnabled === "undefined"}
|
||||||
checked={pushEnabled ?? false}
|
checked={pushEnabled ?? false}
|
||||||
onChange={async pushEnabled => {
|
onChange={async pushEnabled => {
|
||||||
|
try {
|
||||||
const reg = await navigator.serviceWorker?.getRegistration();
|
const reg = await navigator.serviceWorker?.getRegistration();
|
||||||
if (reg) {
|
if (reg) {
|
||||||
if (pushEnabled) {
|
if (pushEnabled) {
|
||||||
|
@ -89,6 +90,9 @@ export function Component(props: Props & WithDispatcher) {
|
||||||
client.req("POST", "/push/unsubscribe");
|
client.req("POST", "/push/unsubscribe");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to enable push!', err);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text id="app.settings.pages.notifications.enable_push" />
|
<Text id="app.settings.pages.notifications.enable_push" />
|
||||||
|
|
Loading…
Reference in a new issue