fix: Use arrow function to bind methods to class (#10215)

Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
Co-authored-by: iamsivin <iamsivin@gmail.com>
This commit is contained in:
Shivam Mishra
2024-10-04 20:35:34 +05:30
committed by GitHub
parent 5b22af6af8
commit 55bf05d2d4

View File

@@ -39,13 +39,13 @@ class DashboardAudioNotificationHelper {
};
}
setInstanceValues({
setInstanceValues = ({
currentUser,
alwaysPlayAudioAlert,
alertIfUnreadConversationExist,
audioAlertType,
audioAlertTone,
}) {
}) => {
this.audioAlertType = audioAlertType;
this.playAlertOnlyWhenHidden = !alwaysPlayAudioAlert;
this.alertIfUnreadConversationExist = alertIfUnreadConversationExist;
@@ -58,9 +58,9 @@ class DashboardAudioNotificationHelper {
});
});
initFaviconSwitcher();
}
};
executeRecurringNotification() {
executeRecurringNotification = () => {
if (!window.WOOT_STORE) {
this.clearSetTimeout();
return;
@@ -81,9 +81,9 @@ class DashboardAudioNotificationHelper {
showBadgeOnFavicon();
}
this.clearSetTimeout();
}
};
clearSetTimeout() {
clearSetTimeout = () => {
if (this.recurringNotificationTimer) {
clearTimeout(this.recurringNotificationTimer);
}
@@ -91,9 +91,9 @@ class DashboardAudioNotificationHelper {
this.executeRecurringNotification,
NOTIFICATION_TIME
);
}
};
playAudioEvery30Seconds() {
playAudioEvery30Seconds = () => {
// Audio alert is disabled dismiss the timer
if (this.audioAlertType === 'none') {
return;
@@ -104,25 +104,25 @@ class DashboardAudioNotificationHelper {
}
this.clearSetTimeout();
}
};
isConversationAssignedToCurrentUser(message) {
isConversationAssignedToCurrentUser = message => {
const conversationAssigneeId = message?.conversation?.assignee_id;
return conversationAssigneeId === this.currentUserId;
}
};
// eslint-disable-next-line class-methods-use-this
isMessageFromCurrentConversation(message) {
isMessageFromCurrentConversation = message => {
return (
window.WOOT_STORE.getters.getSelectedChat?.id === message.conversation_id
);
}
};
isMessageFromCurrentUser(message) {
isMessageFromCurrentUser = message => {
return message?.sender_id === this.currentUserId;
}
};
isUserHasConversationPermission() {
isUserHasConversationPermission = () => {
const currentAccountId = window.WOOT_STORE.getters.getCurrentAccountId;
// Get the user permissions for the current account
const userPermissions = getUserPermissions(
@@ -134,16 +134,16 @@ class DashboardAudioNotificationHelper {
permission => userPermissions.includes(permission)
);
return hasRequiredPermission;
}
};
shouldNotifyOnMessage(message) {
shouldNotifyOnMessage = message => {
if (this.audioAlertType === 'mine') {
return this.isConversationAssignedToCurrentUser(message);
}
return this.audioAlertType === 'all';
}
};
onNewMessage(message) {
onNewMessage = message => {
// If the user does not have the permission to view the conversation, then dismiss the alert
if (!this.isUserHasConversationPermission()) {
return;
@@ -176,7 +176,7 @@ class DashboardAudioNotificationHelper {
window.playAudioAlert();
showBadgeOnFavicon();
this.playAudioEvery30Seconds();
}
};
}
const notifHelper = new DashboardAudioNotificationHelper();