Skip to content

Commit 2b3dec2

Browse files
[mirotalkc2c] - feat(emoji): make emoticon conversion an opt-in setting
1 parent 88dd1ea commit 2b3dec2

7 files changed

Lines changed: 84 additions & 70 deletions

File tree

‎.env.template‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ====================================================
2-
# MiroTalk C2C v.1.4.85 - Environment Configuration
2+
# MiroTalk C2C v.1.4.86 - Environment Configuration
33
# ====================================================
44

55
# App environment

‎backend/server.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @link Live demo: https://c2c.mirotalk.com
88
* @license Open source: AGPLv3 | Commercial/closed source (official channel): https://docs.mirotalk.com/sites/c2c/
99
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
10-
* @version 1.4.85
10+
* @version 1.4.86
1111
*/
1212

1313
require('dotenv').config();

‎frontend/html/client.html‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,12 @@ <h1>Preparing your call</h1>
314314
<label for="switchLightTheme"><i class="fas fa-sun"></i> Light theme</label>
315315
<input id="switchLightTheme" class="toggle" type="checkbox" />
316316
</div>
317+
<div class="settings-toggle-row">
318+
<label for="switchConvertEmoticons"
319+
><i class="fas fa-smile"></i> Convert emoticons to emoji</label
320+
>
321+
<input id="switchConvertEmoticons" class="toggle" type="checkbox" />
322+
</div>
317323
<div id="noiseSuppressionDiv" class="settings-toggle-row">
318324
<label id="labelNoiseSuppression" for="switchNoiseSuppression"
319325
><i class="fas fa-ear-listen"></i> Noise suppression</label

‎frontend/js/client.js‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @link Live demo: https://c2c.mirotalk.com
88
* @license Open source: AGPLv3 | Commercial/closed source (official channel): https://docs.mirotalk.com/sites/c2c/
99
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
10-
* @version 1.4.85
10+
* @version 1.4.86
1111
*/
1212

1313
const savedTheme = window.localStorage.getItem('home-theme');
@@ -71,6 +71,7 @@ const maxVideoQualityDiv = document.getElementById('maxVideoQualityDiv');
7171
const pushToTalkDiv = document.getElementById('pushToTalkDiv');
7272
const noiseSuppressionDiv = document.getElementById('noiseSuppressionDiv');
7373
const switchLightTheme = document.getElementById('switchLightTheme');
74+
const switchConvertEmoticons = document.getElementById('switchConvertEmoticons');
7475
const switchNoiseSuppression = document.getElementById('switchNoiseSuppression');
7576
const switchMaxVideoQuality = document.getElementById('switchMaxVideoQuality');
7677
const switchKeepAspectRatio = document.getElementById('switchKeepAspectRatio');
@@ -180,6 +181,7 @@ const chatInputEmoji = {
180181
':N': '🥶',
181182
':J': '🥴',
182183
};
184+
const chatInputEmoticons = Object.keys(chatInputEmoji).sort((a, b) => b.length - a.length);
183185

184186
const isVideoPIPSupported = document.pictureInPictureEnabled;
185187
const isWebRTCSupported = checkWebRTCSupported();
@@ -206,7 +208,6 @@ let isSpaceDown = false;
206208
let pushToTalkAudioContext = null;
207209
let isMyAudioActiveBefore = false;
208210
let isMyVideoActiveBefore = false;
209-
let isChatPasteTxt = false;
210211
let noiseProcessor = null;
211212
let noiseSuppressionRequest = 0;
212213
let noiseSuppressionConstraints = Promise.resolve();
@@ -1473,6 +1474,11 @@ function handleEvents() {
14731474
window.localStorage.setItem('home-theme', theme);
14741475
playSound('switch');
14751476
};
1477+
switchConvertEmoticons.onchange = (e) => {
1478+
localStorageConfig.chat.settings.convert_emoticons = e.currentTarget.checked;
1479+
saveLocalStorageConfig();
1480+
playSound('switch');
1481+
};
14761482
//switchMaxVideoQuality.checked = localStorageConfig.video.settings.best_quality;
14771483
switchMaxVideoQuality.onchange = (e) => {
14781484
localStorageConfig.video.settings.best_quality = e.currentTarget.checked;
@@ -1564,18 +1570,15 @@ function handleEvents() {
15641570
chatSendBtn.click();
15651571
}
15661572
};
1567-
chatInput.oninput = function () {
1568-
if (isChatPasteTxt) return;
1569-
for (let i in chatInputEmoji) {
1570-
let regex = new RegExp(i.replace(/([()[{*+.$^\\|?])/g, '\\$1'), 'gim');
1571-
this.value = this.value.replace(regex, chatInputEmoji[i]);
1573+
chatInput.oninput = function (event) {
1574+
if (localStorageConfig.chat.settings.convert_emoticons && event.inputType !== 'insertFromPaste') {
1575+
for (const emoticon of chatInputEmoticons) {
1576+
const regex = new RegExp(emoticon.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gi');
1577+
this.value = this.value.replace(regex, chatInputEmoji[emoticon]);
1578+
}
15721579
}
15731580
checkLineBreaks();
15741581
};
1575-
chatInput.onpaste = () => {
1576-
isChatPasteTxt = true;
1577-
checkLineBreaks();
1578-
};
15791582
leaveBtn.onclick = () => {
15801583
endCall();
15811584
};
@@ -2426,6 +2429,7 @@ function loadLocalStorageConfig() {
24262429
audioOutputSource.selectedIndex = localStorageConfig?.speaker?.devices?.select?.index ?? 0;
24272430
}
24282431
switchNoiseSuppression.checked = localStorageConfig?.audio?.settings?.noise_suppression ?? false;
2432+
switchConvertEmoticons.checked = localStorageConfig.chat.settings.convert_emoticons;
24292433
switchMaxVideoQuality.checked = localStorageConfig.video.settings.best_quality;
24302434
switchKeepAspectRatio.checked = localStorageConfig.video.settings.aspect_ratio;
24312435
screenCameraSelect.value = getScreenCameraPosition();
@@ -2943,7 +2947,6 @@ function sendMessage() {
29432947

29442948
function emitDcMsg(msg) {
29452949
if (msg) {
2946-
isChatPasteTxt = false;
29472950
console.log('Send msg: ' + msg);
29482951
appendMessage(peerName, msg);
29492952
Object.keys(dataChannels).map((peerId) =>

‎frontend/js/storage.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ class LocalStorage {
5757
screen_camera: 'off', // camera bubble over the shared screen: off | bottom-right | bottom-left | top-right | top-left
5858
},
5959
},
60+
chat: {
61+
settings: {
62+
convert_emoticons: false,
63+
},
64+
},
6065
};
6166
}
6267

‎package-lock.json‎

Lines changed: 52 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mirotalkc2c",
3-
"version": "1.4.85",
3+
"version": "1.4.86",
44
"description": "A free WebRTC Cam-2-Cam browser-based video calls",
55
"main": "server.js",
66
"scripts": {
@@ -40,7 +40,7 @@
4040
"dependencies": {
4141
"@mattermost/client": "11.9.0",
4242
"@ngrok/ngrok": "1.7.0",
43-
"@sentry/node": "^11.9.0",
43+
"@sentry/node": "^11.10.0",
4444
"colors": "^1.4.0",
4545
"compression": "^1.8.2",
4646
"cors": "^2.8.6",
@@ -53,11 +53,11 @@
5353
"httpolyglot": "0.1.2",
5454
"js-yaml": "^5.5.0",
5555
"jsdom": "^30.1.3",
56-
"nodemailer": "^10.2.1",
56+
"nodemailer": "^10.3.1",
5757
"socket.io": "^4.8.4",
5858
"swagger-ui-express": "5.0.1",
5959
"uuid": "14.0.3",
60-
"xss": "^1.0.16"
60+
"xss": "^1.0.17"
6161
},
6262
"devDependencies": {
6363
"mocha": "^12.0.3",

0 commit comments

Comments
 (0)