From fa6ced456503344729c4f9b1f018c213397c4593 Mon Sep 17 00:00:00 2001 From: flashwave Date: Wed, 28 Aug 2024 21:10:30 +0000 Subject: [PATCH] Work in progress message list rewrite. --- src/mami.css/input.css | 4 +- src/mami.css/main.css | 4 + src/mami.js/avatar.js | 11 + src/mami.js/{chatform => chat}/form.jsx | 8 +- src/mami.js/chat/garbparse.jsx | 37 +++ src/mami.js/{chatform => chat}/input.jsx | 36 ++- src/mami.js/{chatform => chat}/markup.jsx | 0 src/mami.js/chat/messages.jsx | 117 +++++++++ src/mami.js/chat/msg-act.jsx | 82 +++++++ src/mami.js/chat/msg-text.jsx | 89 +++++++ src/mami.js/colpick/picker.jsx | 3 + src/mami.js/emotes/picker.jsx | 67 ++++-- src/mami.js/main.js | 110 +++++---- src/mami.js/messages.js | 74 ------ src/mami.js/sidebar/act-clear-backlog.jsx | 3 +- src/mami.js/sidebar/pan-uploads.jsx | 175 ++++++++++---- src/mami.js/sidebar/pan-users.jsx | 121 ++++++---- src/mami.js/sockchat/handlers.js | 231 ++---------------- src/mami.js/ui/chat-interface.js | 7 +- src/mami.js/ui/chat-layout.js | 4 +- src/mami.js/ui/messages.jsx | 255 +++----------------- src/mami.js/users.js | 183 -------------- src/mami.js/weeb.js | 8 +- src/proto.js/sockchat/authed.js | 280 ++++++++++++++++------ src/proto.js/sockchat/ctx.js | 3 + src/proto.js/sockchat/proto.js | 39 +++ src/proto.js/sockchat/unauthed.js | 18 +- src/proto.js/sockchat/utils.js | 3 +- 28 files changed, 1009 insertions(+), 963 deletions(-) create mode 100644 src/mami.js/avatar.js rename src/mami.js/{chatform => chat}/form.jsx (70%) create mode 100644 src/mami.js/chat/garbparse.jsx rename src/mami.js/{chatform => chat}/input.jsx (86%) rename src/mami.js/{chatform => chat}/markup.jsx (100%) create mode 100644 src/mami.js/chat/messages.jsx create mode 100644 src/mami.js/chat/msg-act.jsx create mode 100644 src/mami.js/chat/msg-text.jsx delete mode 100644 src/mami.js/messages.js delete mode 100644 src/mami.js/users.js diff --git a/src/mami.css/input.css b/src/mami.css/input.css index a16d8da..6e54496 100644 --- a/src/mami.css/input.css +++ b/src/mami.css/input.css @@ -12,6 +12,7 @@ height: 40px; max-height: 140px; resize: none; + width: 0; } .input__text, @@ -32,9 +33,6 @@ cursor: pointer } -.input__menus { -} - .input__menu { display: flex; flex-wrap: wrap; diff --git a/src/mami.css/main.css b/src/mami.css/main.css index b211d3e..30206bc 100644 --- a/src/mami.css/main.css +++ b/src/mami.css/main.css @@ -40,6 +40,10 @@ a:hover { visibility: none !important; } +.invisible { + visibility: none !important; +} + .sjis { font-family: IPAMonaPGothic, 'IPA モナー Pゴシック', Monapo, Mona, 'MS PGothic', 'MS Pゴシック', monospace; font-size: 16px; diff --git a/src/mami.js/avatar.js b/src/mami.js/avatar.js new file mode 100644 index 0000000..f5dfe2e --- /dev/null +++ b/src/mami.js/avatar.js @@ -0,0 +1,11 @@ +const MamiFormatUserAvatarUrl = (userId, res = 0, changeTime = null) => { + const template = futami.get('avatar') ?? ''; + if(template.length < 1) + return ''; + + changeTime ??= Date.now(); + + return template.replace('{user:id}', userId) + .replace('{resolution}', res) + .replace('{user:avatar_change}', changeTime); +}; diff --git a/src/mami.js/chatform/form.jsx b/src/mami.js/chat/form.jsx similarity index 70% rename from src/mami.js/chatform/form.jsx rename to src/mami.js/chat/form.jsx index 7660ece..7260307 100644 --- a/src/mami.js/chatform/form.jsx +++ b/src/mami.js/chat/form.jsx @@ -1,8 +1,8 @@ -#include chatform/input.jsx -#include chatform/markup.jsx +#include chat/input.jsx +#include chat/markup.jsx -const MamiChatForm = function(eventTarget) { - const input = new MamiChatFormInput(eventTarget); +const MamiChatForm = function(findUserInfosByName, findEmoteByName, eventTarget) { + const input = new MamiChatFormInput(findUserInfosByName, findEmoteByName, eventTarget); const markup = new MamiChatFormMarkup; const html =
{ diff --git a/src/mami.js/chat/garbparse.jsx b/src/mami.js/chat/garbparse.jsx new file mode 100644 index 0000000..6b995a0 --- /dev/null +++ b/src/mami.js/chat/garbparse.jsx @@ -0,0 +1,37 @@ +#include parsing.js +#include url.js +#include weeb.js +#include ui/emotes.js + +// replace this with better parsing, read the fucking book already +const MamiMolestMessageContents = (info, textElem, userNameElem) => { + const hasTextElem = textElem instanceof Element; + + if(hasTextElem) { + Umi.UI.Emoticons.Parse(textElem, info.sender); + Umi.Parsing.Parse(textElem, info); + + const textSplit = textElem.innerText.split(' '); + for(const textPart of textSplit) { + const uri = Umi.URI.Parse(textPart); + + if(uri !== null && uri.Slashes !== null) { + const anchorElem = {textPart}; + textElem.innerHTML = textElem.innerHTML.replace(textPart.replace(/&/g, '&'), anchorElem.outerHTML); + } + } + } + + if(mami.settings.get('weeaboo')) { + if(userNameElem instanceof Element) + userNameElem.appendChild($t(Weeaboo.getNameSuffix(info.sender))); + + if(hasTextElem) { + textElem.appendChild($t(Weeaboo.getTextSuffix(info.sender))); + + const kaomoji = Weeaboo.getRandomKaomoji(true, info); + if(kaomoji) + textElem.append(` ${kaomoji}`); + } + } +}; diff --git a/src/mami.js/chatform/input.jsx b/src/mami.js/chat/input.jsx similarity index 86% rename from src/mami.js/chatform/input.jsx rename to src/mami.js/chat/input.jsx index f2fdf86..a26f9af 100644 --- a/src/mami.js/chatform/input.jsx +++ b/src/mami.js/chat/input.jsx @@ -1,7 +1,4 @@ -#include emotes.js -#include users.js - -const MamiChatFormInput = function(eventTarget) { +const MamiChatFormInput = function(findUserInfosByName, findEmoteByName, eventTarget) { const textElem =