@@ -1264,7 +1264,7 @@ $(function() {
12641264 "This site makes a lot of sound! You may want to adjust the volume before continuing." ;
12651265 document . getElementById ( "motd-text" ) . innerHTML = msg . motd ;
12661266 openModal ( "#motd" ) ;
1267- $ ( document ) . off ( "keydown" , modalHandleEsc ) ;
1267+ $ ( document ) . on ( "keydown" , modalHandleEsc ) ;
12681268 var user_interact = function ( evt ) {
12691269 if (
12701270 ( evt . path || ( evt . composedPath && evt . composedPath ( ) ) ) . includes (
@@ -1835,6 +1835,7 @@ $(function() {
18351835 var gHideChat = localStorage . hideChat == "true" ;
18361836 var gNoPreventDefault = localStorage . noPreventDefault == "true" ;
18371837 var gHideBotUsers = localStorage . hideBotUsers == "true" ;
1838+ var gCancelDMs = localStorage . cancelDMs == "true" ;
18381839 var gSnowflakes =
18391840 new Date ( ) . getMonth ( ) === 11 && localStorage . snowflakes !== "false" ;
18401841
@@ -2247,20 +2248,39 @@ $(function() {
22472248 gClient . on ( "participant removed" , ( part ) => {
22482249 if ( gIsDming && part . _id === gDmParticipant . _id ) {
22492250 chat . endDM ( ) ;
2250- chat . endDM ( ) ;
2251- }
2251+ if ( ! gCancelDMs ) {
2252+ new Notification ( { title : 'DM Cancelled' ,
2253+ html : gHasSeenDMWarning ?
2254+ `Your message is still in the chat input field, but will send as a public message.<br/>
2255+ You can disable this in Client Settings.`
2256+ : `Your message is still in the chatbox, but it will send as a public message.<br/>
2257+ You can disable this in Client Settings.<br/>
2258+ Enabling "Cancel DMs when recipient leaves" will clear your message from the text input<br/>
2259+ and unfocus the textbox when the person you're typing to leaves the channel.` ,
2260+ target : "#room" ,
2261+ duration : 20000 ,
2262+ class : "top"
2263+ } ) ;
2264+ if ( ! localStorage . hasSeenDMWarning ) gHasSeenDMWarning = true ; localStorage . hasSeenDMWarning = true ;
2265+ $ ( "#chat-input" ) . blur ( ) ;
2266+ }
2267+ if ( gCancelDMs ) {
2268+ chat . blur ( ) ;
2269+ $ ( "#chat input" ) . value = "" ;
2270+ new Notification ( { title : "DM Cancelled" ,
2271+ text : `${ part . name } left the room.` ,
2272+ target : "#room" ,
2273+ duration : 10000
2274+ } ) ;
2275+ }
2276+ }
22522277 } ) ;
22532278
22542279 //Replies
22552280
22562281 var gReplyParticipant ;
22572282 var gIsReplying = false ;
22582283 var gMessageId ;
2259- gClient . on ( `participant removed` , ( part ) => {
2260- if ( gIsReplying && part . _id === gReplyParticipant . _id ) {
2261- MPP . chat . cancelReply ( ) ;
2262- }
2263- } ) ;
22642284
22652285 // click participant names
22662286 ( function ( ) {
@@ -2805,7 +2825,8 @@ $(function() {
28052825 $ ( "#room .more" ) . fadeOut ( 250 ) ;
28062826 var selected_name = $ ( evt . target ) . attr ( "roomname" ) ;
28072827 if ( typeof selected_name != "undefined" ) {
2808- changeRoom ( selected_name , "right" ) ;
2828+ if ( ! evt . ctrlKey ) changeRoom ( selected_name , "right" ) ;
2829+ else window . open ( `?c=${ selected_name } ` )
28092830 }
28102831 return false ;
28112832 }
@@ -2861,7 +2882,7 @@ $(function() {
28612882 if ( gClient . accountInfo . type === "discord" ) {
28622883 $ ( "#account #avatar-image" ) . prop ( "src" , gClient . accountInfo . avatar ) ;
28632884 $ ( "#account #logged-in-user-text" ) . text (
2864- "@" + gClient . accountInfo . username
2885+ `@ ${ gClient . accountInfo . username } `
28652886 ) ;
28662887 }
28672888 } else {
@@ -2872,7 +2893,7 @@ $(function() {
28722893 var gModal ;
28732894
28742895 function modalHandleEsc ( evt ) {
2875- if ( evt . keyCode == 27 ) {
2896+ if ( evt . keyCode == 27 || ( evt . keyCode == 32 || evt . keyCode == 13 ) && document . activeElement . type !== "text" ) {
28762897 closeModal ( ) ;
28772898 if ( ! gNoPreventDefault ) evt . preventDefault ( ) ;
28782899 evt . stopPropagation ( ) ;
@@ -3258,7 +3279,7 @@ $(function() {
32583279 chat . endDM ( ) ;
32593280 }
32603281 if ( gIsReplying ) {
3261- chat . cancelReply ( ) ;
3282+ chat . cancelReply ( part ) ;
32623283 }
32633284 setTimeout ( function ( ) {
32643285 chat . blur ( ) ;
@@ -3344,15 +3365,14 @@ $(function() {
33443365 $ ( "#chat-input" ) [ 0 ] . placeholder = `Replying to ${ part . name } in a DM.` ;
33453366 } ,
33463367
3347- cancelReply : function ( ) {
3348- if ( gIsDming ) gIsDming = false ;
3368+ cancelReply : function ( part ) {
33493369 gIsReplying = false ;
33503370 $ ( `#msg-${ gMessageId } ` ) . css ( {
33513371 "background-color" : "unset" ,
33523372 border : "1px solid #00000000" ,
33533373 } ) ;
33543374 $ ( "#chat-input" ) [ 0 ] . placeholder = window . i18nextify . i18next . t (
3355- ` You can chat with this thing.`,
3375+ ( gIsDming ? `Direct messaging ${ part . name } ` : ` You can chat with this thing.`) ,
33563376 ) ;
33573377 } ,
33583378
@@ -3394,7 +3414,7 @@ $(function() {
33943414 } ,
33953415 ] ) ;
33963416 setTimeout ( ( ) => {
3397- MPP . chat . cancelReply ( ) ;
3417+ MPP . chat . cancelReply ( gReplyParticipant ) ;
33983418 } , 100 ) ;
33993419 } else {
34003420 gClient . sendArray ( [
@@ -3406,7 +3426,7 @@ $(function() {
34063426 } ,
34073427 ] ) ;
34083428 setTimeout ( ( ) => {
3409- MPP . chat . cancelReply ( ) ;
3429+ MPP . chat . cancelReply ( gReplyParticipant ) ;
34103430 } , 100 ) ;
34113431 }
34123432 } else {
@@ -4782,7 +4802,7 @@ $(function() {
47824802 "hide-chat" ,
47834803 "Hide chat" ,
47844804 gHideChat ,
4785- false ,
4805+ true ,
47864806 html ,
47874807 ( ) => {
47884808 gHideChat = ! gHideChat ;
@@ -4796,6 +4816,18 @@ $(function() {
47964816 } ,
47974817 ) ;
47984818
4819+ createSetting (
4820+ "cancel-dms" ,
4821+ "Cancel DMs when recipient leaves" ,
4822+ gCancelDMs ,
4823+ false ,
4824+ html ,
4825+ ( ) => {
4826+ gCancelDMs = ! gCancelDMs ;
4827+ localStorage . cancelDMs = gCancelDMs ;
4828+ } ,
4829+ ) ;
4830+
47994831 content . appendChild ( html ) ;
48004832 break ;
48014833
0 commit comments