mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
Settings: Link notification sounds to playSound.
Fix: Restore hooks.ts patch, additionally use numbers.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { decodeTime } from "ulid";
|
||||
import { SoundContext } from "../Settings";
|
||||
import { AppContext } from "./RevoltClient";
|
||||
import { useTranslation } from "../../lib/i18n";
|
||||
import { Users } from "revolt.js/dist/api/objects";
|
||||
import { useContext, useEffect } from "preact/hooks";
|
||||
import { connectState } from "../../redux/connector";
|
||||
import { playSound } from "../../assets/sounds/Audio";
|
||||
import { Message, SYSTEM_USER_ID, User } from "revolt.js";
|
||||
import { NotificationOptions } from "../../redux/reducers/settings";
|
||||
import { Route, Switch, useHistory, useParams } from "react-router-dom";
|
||||
@@ -27,8 +27,6 @@ async function createNotification(title: string, options: globalThis.Notificatio
|
||||
function Notifier(props: Props) {
|
||||
const translate = useTranslation();
|
||||
const showNotification = props.options?.desktopEnabled ?? false;
|
||||
// const playIncoming = props.options?.soundEnabled ?? true;
|
||||
// const playOutgoing = props.options?.outgoingSoundEnabled ?? true;
|
||||
|
||||
const client = useContext(AppContext);
|
||||
const { guild: guild_id, channel: channel_id } = useParams<{
|
||||
@@ -36,13 +34,13 @@ function Notifier(props: Props) {
|
||||
channel: string;
|
||||
}>();
|
||||
const history = useHistory();
|
||||
const playSound = useContext(SoundContext);
|
||||
|
||||
async function message(msg: Message) {
|
||||
if (msg.author === client.user!._id) return;
|
||||
if (msg.channel === channel_id && document.hasFocus()) return;
|
||||
if (client.user?.status?.presence === Users.Presence.Busy) return;
|
||||
|
||||
// Sounds.playInbound();
|
||||
playSound('message');
|
||||
if (!showNotification) return;
|
||||
|
||||
|
||||
@@ -11,8 +11,9 @@ export interface HookContext {
|
||||
export function useForceUpdate(context?: HookContext): HookContext {
|
||||
const client = useContext(AppContext);
|
||||
if (context) return context;
|
||||
/*const H = useState(undefined);
|
||||
var updateState: (_: undefined) => void;
|
||||
|
||||
const H = useState(0);
|
||||
var updateState: (_: number) => void;
|
||||
if (Array.isArray(H)) {
|
||||
let [, u] = H;
|
||||
updateState = u;
|
||||
@@ -20,9 +21,8 @@ export function useForceUpdate(context?: HookContext): HookContext {
|
||||
console.warn('Failed to construct using useState.');
|
||||
console.warn(H);
|
||||
updateState = ()=>{};
|
||||
}*/
|
||||
}
|
||||
|
||||
const [, updateState] = useState(0);
|
||||
return { client, forceUpdate: () => updateState(Math.random()) };
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ export function useDMs(context?: HookContext) {
|
||||
|
||||
return map
|
||||
.toArray()
|
||||
.filter(x => x.channel_type === 'DirectMessage' || x.channel_type === 'Group' || x.channel_type === 'SavedMessages') as (Channels.GroupChannel | Channels.DirectMessageChannel | Channels.SavedMessagesChannel)[];
|
||||
.filter(x => (x.channel_type === 'DirectMessage' && x.active) || x.channel_type === 'Group' || x.channel_type === 'SavedMessages') as (Channels.GroupChannel | Channels.DirectMessageChannel | Channels.SavedMessagesChannel)[];
|
||||
}
|
||||
|
||||
export function useUserPermission(id: string, context?: HookContext) {
|
||||
|
||||
Reference in New Issue
Block a user