Embed resources
This commit is contained in:
parent
8c8a1685b2
commit
04ee6b8be2
28 changed files with 60 additions and 57 deletions
|
@ -1,6 +1,7 @@
|
|||
import {formatMessage, formatTitleWithDefault, openUrl, playSound, topicShortUrl} from "./utils";
|
||||
import prefs from "./Prefs";
|
||||
import subscriptionManager from "./SubscriptionManager";
|
||||
import logo from "../img/ntfy.png";
|
||||
|
||||
class Notifier {
|
||||
async notify(subscriptionId, notification, onClickFallback) {
|
||||
|
@ -17,7 +18,7 @@ class Notifier {
|
|||
console.log(`[Notifier, ${shortUrl}] Displaying notification ${notification.id}: ${message}`);
|
||||
const n = new Notification(title, {
|
||||
body: message,
|
||||
icon: '/static/img/favicon.png'
|
||||
icon: logo
|
||||
});
|
||||
if (notification.click) {
|
||||
n.onclick = (e) => openUrl(notification.click);
|
||||
|
@ -32,7 +33,6 @@ class Notifier {
|
|||
await playSound(sound);
|
||||
} catch (e) {
|
||||
console.log(`[Notifier, ${shortUrl}] Error playing audio`, e);
|
||||
// FIXME show no sound allowed popup
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ class Prefs {
|
|||
|
||||
async sound() {
|
||||
const sound = await db.prefs.get('sound');
|
||||
return (sound) ? sound.value : "mixkit-correct-answer-tone";
|
||||
return (sound) ? sound.value : "ding";
|
||||
}
|
||||
|
||||
async setMinPriority(minPriority) {
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
import {rawEmojis} from "./emojis";
|
||||
import beep from "../sounds/beep.mp3";
|
||||
import juntos from "../sounds/juntos.mp3";
|
||||
import pristine from "../sounds/pristine.mp3";
|
||||
import ding from "../sounds/ding.mp3";
|
||||
import dadum from "../sounds/dadum.mp3";
|
||||
import pop from "../sounds/pop.mp3";
|
||||
import popSwoosh from "../sounds/pop-swoosh.mp3";
|
||||
|
||||
export const topicUrl = (baseUrl, topic) => `${baseUrl}/${topic}`;
|
||||
export const topicUrlWs = (baseUrl, topic) => `${topicUrl(baseUrl, topic)}/ws`
|
||||
|
@ -34,7 +41,6 @@ const toEmojis = (tags) => {
|
|||
else return tags.filter(tag => tag in emojis).map(tag => emojis[tag]);
|
||||
}
|
||||
|
||||
|
||||
export const formatTitleWithDefault = (m, fallback) => {
|
||||
if (m.title) {
|
||||
return formatTitle(m);
|
||||
|
@ -123,8 +129,18 @@ export const subscriptionRoute = (subscription) => {
|
|||
return `/${subscription.topic}`;
|
||||
}
|
||||
|
||||
export const sounds = {
|
||||
"beep": beep,
|
||||
"juntos": juntos,
|
||||
"pristine": pristine,
|
||||
"ding": ding,
|
||||
"dadum": dadum,
|
||||
"pop": pop,
|
||||
"pop-swoosh": popSwoosh
|
||||
};
|
||||
|
||||
export const playSound = async (sound) => {
|
||||
const audio = new Audio(`/static/sounds/${sound}.mp3`);
|
||||
const audio = new Audio(sounds[sound]);
|
||||
return audio.play();
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue