mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-06-06 13:53:54 +02:00
chore(deps): replace dependency eslint-config-standard-with-typescript with eslint-config-love 43.1.0 (#1228)
* chore(deps): replace dependency eslint-config-standard-with-typescript with eslint-config-love 43.1.0 * actually apply the rules lol * rebuild --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: FabianLars <fabianlars@fabianlars.de>
This commit is contained in:
@@ -9,22 +9,28 @@ import type { Options } from "./index";
|
||||
let permissionSettable = false;
|
||||
let permissionValue = "default";
|
||||
|
||||
function isPermissionGranted() {
|
||||
async function isPermissionGranted(): Promise<boolean> {
|
||||
if (window.Notification.permission !== "default") {
|
||||
return Promise.resolve(window.Notification.permission === "granted");
|
||||
return await Promise.resolve(
|
||||
window.Notification.permission === "granted",
|
||||
);
|
||||
}
|
||||
return invoke("plugin:notification|is_permission_granted");
|
||||
return await invoke("plugin:notification|is_permission_granted");
|
||||
}
|
||||
|
||||
function setNotificationPermission(value: "granted" | "denied" | "default") {
|
||||
function setNotificationPermission(
|
||||
value: "granted" | "denied" | "default",
|
||||
): void {
|
||||
permissionSettable = true;
|
||||
// @ts-expect-error we can actually set this value on the webview
|
||||
window.Notification.permission = value;
|
||||
permissionSettable = false;
|
||||
}
|
||||
|
||||
function requestPermission() {
|
||||
return invoke<"prompt" | "default" | "granted" | "denied">(
|
||||
async function requestPermission(): Promise<
|
||||
"default" | "denied" | "granted" | "prompt"
|
||||
> {
|
||||
return await invoke<"prompt" | "default" | "granted" | "denied">(
|
||||
"plugin:notification|request_permission",
|
||||
).then((permission) => {
|
||||
setNotificationPermission(
|
||||
@@ -34,12 +40,12 @@ import type { Options } from "./index";
|
||||
});
|
||||
}
|
||||
|
||||
function sendNotification(options: string | Options) {
|
||||
async function sendNotification(options: string | Options): Promise<void> {
|
||||
if (typeof options === "object") {
|
||||
Object.freeze(options);
|
||||
}
|
||||
|
||||
return invoke("plugin:notification|notify", {
|
||||
await invoke("plugin:notification|notify", {
|
||||
options:
|
||||
typeof options === "string"
|
||||
? {
|
||||
@@ -51,8 +57,10 @@ import type { Options } from "./index";
|
||||
|
||||
// @ts-expect-error unfortunately we can't implement the whole type, so we overwrite it with our own version
|
||||
window.Notification = function (title, options) {
|
||||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
||||
const opts = options || {};
|
||||
sendNotification(
|
||||
void sendNotification(
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||
Object.assign(opts, {
|
||||
title,
|
||||
}),
|
||||
@@ -73,7 +81,7 @@ import type { Options } from "./index";
|
||||
},
|
||||
});
|
||||
|
||||
isPermissionGranted().then(function (response) {
|
||||
void isPermissionGranted().then(function (response) {
|
||||
if (response === null) {
|
||||
setNotificationPermission("default");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user