Add alert sound on note share - plays for recipients only, fix favicon 404

This commit is contained in:
2026-01-16 01:44:57 +00:00
parent 7c4459fd47
commit 95888562a0
2 changed files with 64 additions and 33 deletions
+49 -14
View File
@@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prism Notes</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='75' font-size='75'>📝</text></svg>">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
@@ -2795,23 +2796,57 @@
const noteRecord = await pb.collection(NOTES_COLLECTION).create(payload);
// Create alerts for each shared_with user
// TEST: Play alert sound only if current user is in shared_with
if (selectedUsers.length > 0) {
console.log(`📢 Creating alerts for ${selectedUsers.length} users...`);
for (const user of selectedUsers) {
try {
const alertRecord = await pb.collection('Alerts').create({
note_id: noteRecord.id,
note_title: noteTitle || '(untitled)',
shared_name: user.name,
created_by: displayNameCache,
created_at: new Date().toISOString(),
read: false,
try {
console.log(`🔔 Checking if current user (${userEmailCache}) is in shared_with...`);
let currentUserIsRecipient = false;
for (const user of selectedUsers) {
const firstName = user.name.split(' ')[0];
const records = await pb.collection('Associations').getList(1, 50, {
filter: `first_name = "${firstName}"`,
});
console.log(`✓ Alert created for ${user.name}:`, alertRecord.id);
} catch (alertErr) {
console.error(`Error creating alert for ${user.name}:`, alertErr);
if (records.items.length > 0) {
const match = records.items.find(r => r.emailtext === userEmailCache);
if (match) {
currentUserIsRecipient = true;
console.log(`✓ Found match: ${user.name} (${match.emailtext})`);
break;
}
}
}
if (currentUserIsRecipient) {
console.log('🔔 Current user is a recipient - playing alert sound');
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
if (audioContext.state === 'suspended') {
await audioContext.resume();
}
const now = audioContext.currentTime;
const playBell = (startTime, volume = 1) => {
const osc = audioContext.createOscillator();
const gain = audioContext.createGain();
osc.connect(gain);
gain.connect(audioContext.destination);
osc.frequency.setValueAtTime(1000, startTime);
osc.frequency.exponentialRampToValueAtTime(600, startTime + 0.15);
gain.gain.setValueAtTime(0.8 * volume, startTime);
gain.gain.exponentialRampToValueAtTime(0.01, startTime + 0.2);
osc.start(startTime);
osc.stop(startTime + 0.2);
};
playBell(now, 1);
playBell(now + 0.2, 0.7);
console.log('✓ Alert sound played');
} else {
console.log(' Current user is the creator - no alert sound');
}
} catch (err) {
console.error('Error playing alert sound:', err);
}
}