Skip to content

Commit

Permalink
error sound added
Browse files Browse the repository at this point in the history
  • Loading branch information
JasminDreasond committed Jul 8, 2024
1 parent 1d95b78 commit 7faff68
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/app/organisms/navigation/ProfileAvatarMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useState, useEffect, useRef } from 'react';
import clone from 'clone';
import jReact from '@mods/lib/jReact';
import { readImageUrl } from '@src/util/libs/mediaCache';
import { getSound } from '@src/util/soundFiles';

import IconButton from '../../atoms/button/IconButton';
import { twemojifyReact } from '../../../util/twemojify';
Expand All @@ -20,7 +21,6 @@ import { openSettings } from '../../../client/action/navigation';
import tinyAPI from '../../../util/mods';
import { enableAfkSystem } from '../../../util/userStatusEffects';
import { getUserWeb3Account } from '../../../util/web3';
import { getSound } from '../../../client/state/Notifications';

import { getAppearance, getAnimatedImageUrl } from '../../../util/libs/appearance';

Expand Down
7 changes: 7 additions & 0 deletions src/app/templates/client/Client.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
selectTab,
} from '../../../client/action/navigation';
import ElectronSidebar from './ElectronSidebar';
import { getSound } from '@src/util/soundFiles';

let versionChecked = false;

Expand Down Expand Up @@ -337,6 +338,12 @@ function Client({ isDevToolsOpen = false }) {
</>
);
} else {
const fatalBeep = getSound('fatal_beep');
if (fatalBeep) {
fatalBeep.pause();
fatalBeep.currentTime = 0;
fatalBeep.play();
}
return (
<>
<ElectronSidebar isDevToolsOpen={isDevToolsOpen} />
Expand Down
14 changes: 1 addition & 13 deletions src/client/state/Notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { cyrb128 } from '@src/util/tools';
import tinyAPI from '@src/util/mods';
import { getAppearance } from '@src/util/libs/appearance';
import attemptDecryption from '@src/util/libs/attemptDecryption';
import soundFiles from '@src/util/soundFiles';
// import { insertIntoRoomEventsDB } from '@src/util/libs/roomEventsDB';

import renderAvatar from '../../../app/atoms/avatar/render';
Expand All @@ -25,13 +26,6 @@ import { getPrivacyRefuseRoom } from '../../../app/organisms/navigation/Sidebar/
import { canSupport } from '@src/util/matrixUtil';
// import { insertEvent } from '../eventsDelay';

const soundFiles = {
notification: new Audio('./sound/notification.ogg'),
invite: new Audio('./sound/invite.ogg'),
micro_on: new Audio('./sound/micro_on.ogg'),
micro_off: new Audio('./sound/micro_off.ogg'),
};

function isNotifEvent(mEvent) {
const eType = mEvent.getType();
if (!cons.supportEventTypes.includes(eType)) return false;
Expand Down Expand Up @@ -715,10 +709,4 @@ class Notifications extends EventEmitter {
}
}

export function getSound(file) {
if (soundFiles && soundFiles[file]) {
return soundFiles[file];
}
}

export default Notifications;
15 changes: 15 additions & 0 deletions src/util/soundFiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const soundFiles = {
fatal_beep: new Audio('./sound/fatal_beep.ogg'),
notification: new Audio('./sound/notification.ogg'),
invite: new Audio('./sound/invite.ogg'),
micro_on: new Audio('./sound/micro_on.ogg'),
micro_off: new Audio('./sound/micro_off.ogg'),
};

export function getSound(file) {
if (soundFiles && soundFiles[file]) {
return soundFiles[file];
}
}

export default soundFiles;

0 comments on commit 7faff68

Please sign in to comment.