diff --git a/Spixi/Platforms/Windows/SAudioPlayer.cs b/Spixi/Platforms/Windows/SAudioPlayer.cs index 28567f8d..f9a0f789 100644 --- a/Spixi/Platforms/Windows/SAudioPlayer.cs +++ b/Spixi/Platforms/Windows/SAudioPlayer.cs @@ -1,29 +1,23 @@ -using Microsoft.VisualBasic; -using SPIXI.VoIP; +using SPIXI.VoIP; using NAudio.Wave; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using IXICore.Meta; namespace Spixi { public class SAudioPlayer : IAudioPlayer, IAudioDecoderCallback { - private WaveOut audioPlayer = null; - private IAudioDecoder audioDecoder = null; + private WaveOut? audioPlayer = null; + private IAudioDecoder? audioDecoder = null; private bool running = false; - private BufferedWaveProvider provider = null; + private BufferedWaveProvider? provider = null; int sampleRate = SPIXI.Meta.Config.VoIP_sampleRate; int bitRate = SPIXI.Meta.Config.VoIP_bitRate; int channels = SPIXI.Meta.Config.VoIP_channels; - private static SAudioPlayer _singletonInstance; + private static SAudioPlayer? _singletonInstance; public static SAudioPlayer Instance() { if (_singletonInstance == null) diff --git a/Spixi/Resources/Raw/html/css/spixiui-dark.css b/Spixi/Resources/Raw/html/css/spixiui-dark.css index 418ae89b..372cca53 100644 --- a/Spixi/Resources/Raw/html/css/spixiui-dark.css +++ b/Spixi/Resources/Raw/html/css/spixiui-dark.css @@ -1812,6 +1812,10 @@ img.emoji { background-repeat: repeat; background-size: 324px 509px; padding-top: 10px; + + display: flex; + flex-direction: column; + align-items: flex-start; } .scrollable-div { @@ -1853,6 +1857,8 @@ img.emoji { animation-duration: 0.3s; word-wrap: break-word; + word-break: break-word; + display: inline-block; } .spixi-bubble > div @@ -1862,7 +1868,7 @@ img.emoji { } .spixi-bubble.myself { - margin-left: 125px; + align-self: flex-end; margin-right: 12px; background: #305171; } @@ -2079,7 +2085,7 @@ img.emoji { padding: 10px; background-color: #2C3D4A; color: #EEF2F5; - border-bottom: 1px solid #3A6B87M; + border-bottom: 1px solid #3A6B87; font-size: 10pt; vertical-align: middle; } @@ -2091,7 +2097,7 @@ img.emoji { font-weight: bold; margin-top: 5px; vertical-align: middle; - border-bottom: 1px solid #3A6B87M; + border-bottom: 1px solid #3A6B87; display: table-cell; } diff --git a/Spixi/Resources/Raw/html/css/spixiui-light.css b/Spixi/Resources/Raw/html/css/spixiui-light.css index 8ff51f9e..199cc165 100644 --- a/Spixi/Resources/Raw/html/css/spixiui-light.css +++ b/Spixi/Resources/Raw/html/css/spixiui-light.css @@ -1807,6 +1807,10 @@ img.emoji { background-repeat: repeat; background-size: 324px 509px; padding-top: 10px; + + display: flex; + flex-direction: column; + align-items: flex-start; } .scrollable-div { @@ -1841,7 +1845,6 @@ img.emoji { color: black; margin-left: 56px; - margin-right: 85px; margin-bottom: 10px; min-width: 80px; @@ -1849,6 +1852,8 @@ img.emoji { animation-duration: 0.3s; word-wrap: break-word; + word-break: break-word; + display: inline-block; } .spixi-bubble > div @@ -1858,8 +1863,8 @@ img.emoji { } .spixi-bubble.myself { - margin-left: 125px; - margin-right: 11px; + align-self: flex-end; + margin-right: 12px; background: #AAD7F0; } diff --git a/Spixi/Resources/Raw/html/js/chat.js b/Spixi/Resources/Raw/html/js/chat.js index ec011d8b..3f699094 100644 --- a/Spixi/Resources/Raw/html/js/chat.js +++ b/Spixi/Resources/Raw/html/js/chat.js @@ -573,9 +573,60 @@ function addText(id, address, nick, avatar, text, time, className) { messagesEl.appendChild(bubbleEl); + adjustLastestBubbles(); + scrollToBottom(); } +// TODO: optimize and merge this function with addText +function adjustLastestBubbles() { + var messagesEl = document.getElementById("messages"); + var bubbles = messagesEl.querySelectorAll(".spixi-bubble"); + + if (bubbles.length < 2) { + return; + } + + var currentBubble = bubbles[bubbles.length - 1]; + var previousBubble = bubbles[bubbles.length - 2]; + + var isCurrentMyself = currentBubble.classList.contains('myself'); + var isPreviousMyself = previousBubble.classList.contains('myself'); + + if (isCurrentMyself === isPreviousMyself) { + if (!isCurrentMyself) { + var currentNick = currentBubble.querySelector('.nick'); + var previousNick = previousBubble.querySelector('.nick'); + + if (currentNick && previousNick) { + var currentAddress = currentNick.getAttribute('address'); + var previousAddress = previousNick.getAttribute('address'); + + if (currentAddress && previousAddress && currentAddress === previousAddress) { + var currentAvatar = currentBubble.querySelector('.avatar'); + if (currentAvatar) { + currentAvatar.remove(); + } + currentNick.textContent = ''; + previousBubble.style.marginBottom = "2px"; + } else { + previousBubble.style.marginBottom = "10px"; + } + } else { + var currentAvatar = currentBubble.querySelector('.avatar'); + if (currentAvatar) { + currentAvatar.remove(); + } + previousBubble.style.marginBottom = "2px"; + } + } else { + previousBubble.style.marginBottom = "2px"; + } + } else { + previousBubble.style.marginBottom = "10px"; + } +} + function addMe(id, address, nick, avatar, text, time, sent, confirmed, read, paid) { var additionalClasses = ""; if (confirmed == "True") { diff --git a/Spixi/Spixi.csproj b/Spixi/Spixi.csproj index 38f3ebc4..610bb3a2 100644 --- a/Spixi/Spixi.csproj +++ b/Spixi/Spixi.csproj @@ -216,7 +216,7 @@ - +