mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-03 20:48:07 +00:00
fix: Audio notification would not work without action on the dashboard (#4303)
* fixes: Audio notification would not work without an action on dashboard * fixes spec * Minor fixes * Minor fixes * Review fixes Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import { IFrameHelper } from 'widget/helpers/utils';
|
|||||||
|
|
||||||
import { showBadgeOnFavicon } from './faviconHelper';
|
import { showBadgeOnFavicon } from './faviconHelper';
|
||||||
|
|
||||||
export const initOnEvents = ['click', 'touchstart', 'keypress'];
|
export const initOnEvents = ['click', 'touchstart', 'keypress', 'keydown'];
|
||||||
export const getAlertAudio = async (baseUrl = '') => {
|
export const getAlertAudio = async (baseUrl = '') => {
|
||||||
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
||||||
const playsound = audioBuffer => {
|
const playsound = audioBuffer => {
|
||||||
@@ -53,6 +53,10 @@ export const shouldPlayAudio = (
|
|||||||
message_type: messageType,
|
message_type: messageType,
|
||||||
private: isPrivate,
|
private: isPrivate,
|
||||||
} = message;
|
} = message;
|
||||||
|
if (!isDocHidden && messageType === MESSAGE_TYPE.INCOMING) {
|
||||||
|
showBadgeOnFavicon();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const isFromCurrentUser = userId === senderId;
|
const isFromCurrentUser = userId === senderId;
|
||||||
|
|
||||||
const playAudio =
|
const playAudio =
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ describe('shouldPlayAudio', () => {
|
|||||||
message_type: 0,
|
message_type: 0,
|
||||||
private: false,
|
private: false,
|
||||||
};
|
};
|
||||||
const [conversationId, userId, isDocHiddden] = [1, 2, false];
|
const [conversationId, userId, isDocHiddden] = [1, 2, true];
|
||||||
const result = shouldPlayAudio(
|
const result = shouldPlayAudio(
|
||||||
message,
|
message,
|
||||||
conversationId,
|
conversationId,
|
||||||
|
|||||||
Reference in New Issue
Block a user