Skip to content

Commit 197990b

Browse files
committed
branch init
1 parent efa1bbb commit 197990b

13 files changed

Lines changed: 253 additions & 109 deletions

File tree

resources/sounds/3ewqsdasd.wav

147 KB
Binary file not shown.

resources/sounds/intuition-561.wav

33.2 KB
Binary file not shown.

resources/sounds/job-done-501.wav

42.1 KB
Binary file not shown.
147 KB
Binary file not shown.

src/main/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,22 @@ const getNotificationSounds = () => {
9797
return availableNotificationSounds;
9898
};
9999

100+
const openNotificationFolder = () => {
101+
const basePath = app.isPackaged
102+
? join(process.resourcesPath, "app.asar.unpacked/resources/sounds")
103+
: join(__dirname, "../../resources/sounds");
104+
105+
if (fs.existsSync(basePath)) {
106+
shell.openPath(basePath).then((result) => {
107+
if (result) {
108+
console.error("[Notification Sounds]: Error opening folder:", result);
109+
} else {
110+
console.log("[Notification Sounds]: Folder opened successfully.");
111+
}
112+
});
113+
}
114+
}
115+
100116
getNotificationSounds(); // Load initially
101117

102118
const handleNotificationSound = (soundFile) => {
@@ -128,6 +144,10 @@ ipcMain.handle("notificationSounds:getAvailable", () => {
128144
return availableNotificationSounds;
129145
});
130146

147+
ipcMain.handle("notificationSounds:openFolder", () => {
148+
openNotificationFolder();
149+
});
150+
131151
ipcMain.handle("notificationSounds:getSoundUrl", (e, { soundFile }) => {
132152
if (!soundFile) {
133153
const defaultSound = availableNotificationSounds.find((s) => s.name === "default");

src/preload/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ if (process.contextIsolated) {
186186
notificationSounds: {
187187
getAvailable: () => ipcRenderer.invoke("notificationSounds:getAvailable"),
188188
getSoundUrl: (soundFile) => ipcRenderer.invoke("notificationSounds:getSoundUrl", { soundFile }),
189+
openFolder: () => ipcRenderer.invoke("notificationSounds:openFolder"),
189190
},
190191

191192
authDialog: {
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

src/renderer/src/components/Dialogs/Settings.jsx

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import darkProfilePic from "../../assets/app/darkProfilePic.jpg";
1414
import ftkProfilePic from "../../assets/app/ftk789ProfilePic.jpg";
1515
import XLogo from "../../assets/logos/XLogo.svg?asset";
1616
import kickLogoIcon from "../../assets/logos/kickLogoIcon.svg?asset";
17+
import NotificationFilePicker from "../Shared/NotificationFilePicker";
18+
import foldeOpenIcon from "../../assets/icons/folder-open-fill.svg?asset";
19+
import playIcon from "../../assets/icons/play-fill.svg?asset";
1720

1821
const Settings = () => {
1922
const { updateSettings, settings } = useSettings();
@@ -55,6 +58,26 @@ const Settings = () => {
5558
}
5659
};
5760

61+
const [notiFiles, setNotiFiles] = useState([]);
62+
63+
const getNotiFiles = useCallback(async () => {
64+
const files = await window.app.notificationSounds.getAvailable();
65+
setNotiFiles(
66+
files.map((file) => ({
67+
value: file.value,
68+
label: file.name,
69+
})),
70+
);
71+
return files.map((file) => ({
72+
value: file.value,
73+
label: file.name,
74+
}));
75+
}, []);
76+
77+
useEffect(() => {
78+
getNotiFiles();
79+
}, [getNotiFiles]);
80+
5881
const handleAddPhrase = useCallback(
5982
(e) => {
6083
const value = e.target.value.trim();
@@ -642,6 +665,53 @@ const Settings = () => {
642665
</div>
643666

644667
<div className="settingsItem extended">
668+
<div
669+
className={clsx("settingSwitchItem", {
670+
active: settingsData?.notifications?.background,
671+
})}>
672+
<div className="settingsItemTitleWithInfo">
673+
<span className="settingsItemTitle">Notification Sound File</span>
674+
<Tooltip delayDuration={100}>
675+
<TooltipTrigger asChild>
676+
<button className="settingsInfoIcon">
677+
<img src={InfoIcon} width={14} height={14} alt="Info" />
678+
</button>
679+
</TooltipTrigger>
680+
<TooltipContent>
681+
<p>Select a custom audio file to play for notifications</p>
682+
<p>You can add new files by pressing the folder icon and dragging your audio file there</p>
683+
</TooltipContent>
684+
</Tooltip>
685+
</div>
686+
<div>
687+
<button
688+
style={{ top: "0.5rem", right: "10px", position: "relative" }}
689+
onClick={() => {
690+
window.app.notificationSounds.openFolder();
691+
}}>
692+
<img src={foldeOpenIcon}></img>
693+
</button>
694+
<button
695+
style={{ top: "0.5rem", right: "10px", position: "relative" }}
696+
onClick={() => {
697+
window.app.notificationSounds
698+
.getSoundUrl(settings?.notifications?.soundFile)
699+
.then((soundUrl) => {
700+
const audio = new Audio(soundUrl);
701+
audio.volume = settings?.notifications?.volume || 0.1;
702+
audio.play().catch((error) => {
703+
console.error("Error playing sound:", error);
704+
});
705+
})
706+
.catch((error) => {
707+
console.error("Error loading sound file:", error);
708+
});
709+
}}>
710+
<img src={playIcon}></img>
711+
</button>
712+
<NotificationFilePicker getOptions={getNotiFiles} change={changeSetting} settingsData={settingsData} />
713+
</div>
714+
</div>
645715
<div
646716
className={clsx("settingSwitchItem", {
647717
active: settingsData?.notifications?.background,

src/renderer/src/components/Messages/Message.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ const Message = ({
106106
if (
107107
settings?.notifications?.enabled &&
108108
(settings?.notifications?.background || settings?.notifications?.sound) &&
109-
settings?.notifications?.phrases?.length &&
110-
message?.sender?.slug !== username
109+
settings?.notifications?.phrases?.length
111110
) {
112111
return settings?.notifications?.phrases?.some((phrase) => {
113112
return message.content?.toLowerCase().includes(phrase.toLowerCase());

0 commit comments

Comments
 (0)