mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-19 18:13:41 -05:00
web/timeline: add big emojis
This commit is contained in:
parent
fdec12a7a3
commit
976d1ae9cb
7 changed files with 20 additions and 7 deletions
2
go.mod
2
go.mod
|
@ -16,7 +16,7 @@ require (
|
|||
github.com/tidwall/gjson v1.18.0
|
||||
github.com/tidwall/sjson v1.2.5
|
||||
github.com/yuin/goldmark v1.7.7
|
||||
go.mau.fi/util v0.8.2-0.20241018231932-9da45c4e6e04
|
||||
go.mau.fi/util v0.8.2-0.20241027163518-38d54fc87ee3
|
||||
go.mau.fi/zeroconfig v0.1.3
|
||||
golang.org/x/crypto v0.28.0
|
||||
golang.org/x/image v0.21.0
|
||||
|
|
4
go.sum
4
go.sum
|
@ -61,8 +61,8 @@ github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
|
|||
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
|
||||
github.com/yuin/goldmark v1.7.7 h1:5m9rrB1sW3JUMToKFQfb+FGt1U7r57IHu5GrYrG2nqU=
|
||||
github.com/yuin/goldmark v1.7.7/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||
go.mau.fi/util v0.8.2-0.20241018231932-9da45c4e6e04 h1:sfTKol1VyOfKb/QilgmtTT8GlZcL790IPWX60W1EEKU=
|
||||
go.mau.fi/util v0.8.2-0.20241018231932-9da45c4e6e04/go.mod h1:T1u/rD2rzidVrBLyaUdPpZiJdP/rsyi+aTzn0D+Q6wc=
|
||||
go.mau.fi/util v0.8.2-0.20241027163518-38d54fc87ee3 h1:9dDTNcVc3y9oU9bYvjpc3xsCupwGzfyYhrppaLy6l9k=
|
||||
go.mau.fi/util v0.8.2-0.20241027163518-38d54fc87ee3/go.mod h1:T1u/rD2rzidVrBLyaUdPpZiJdP/rsyi+aTzn0D+Q6wc=
|
||||
go.mau.fi/zeroconfig v0.1.3 h1:As9wYDKmktjmNZW5i1vn8zvJlmGKHeVxHVIBMXsm4kM=
|
||||
go.mau.fi/zeroconfig v0.1.3/go.mod h1:NcSJkf180JT+1IId76PcMuLTNa1CzsFFZ0nBygIQM70=
|
||||
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
|
||||
|
|
|
@ -291,6 +291,7 @@ type LocalContent struct {
|
|||
SanitizedHTML string `json:"sanitized_html,omitempty"`
|
||||
HTMLVersion int `json:"html_version,omitempty"`
|
||||
WasPlaintext bool `json:"was_plaintext,omitempty"`
|
||||
BigEmoji bool `json:"big_emoji,omitempty"`
|
||||
}
|
||||
|
||||
type Event struct {
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"github.com/rs/zerolog"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/tidwall/sjson"
|
||||
"go.mau.fi/util/emojirunes"
|
||||
"go.mau.fi/util/exzerolog"
|
||||
"go.mau.fi/util/jsontime"
|
||||
"maunium.net/go/mautrix"
|
||||
|
@ -366,7 +367,7 @@ func (h *HiClient) calculateLocalContent(ctx context.Context, dbEvt *database.Ev
|
|||
}
|
||||
if content != nil {
|
||||
var sanitizedHTML string
|
||||
var wasPlaintext bool
|
||||
var wasPlaintext, bigEmoji bool
|
||||
var inlineImages []id.ContentURI
|
||||
if content.Format == event.FormatHTML && content.FormattedBody != "" {
|
||||
var err error
|
||||
|
@ -395,6 +396,8 @@ func (h *HiClient) calculateLocalContent(ctx context.Context, dbEvt *database.Ev
|
|||
builder.Grow(len(content.Body) + builderPreallocBuffer)
|
||||
linkifyAndWriteBytes(&builder, []byte(content.Body))
|
||||
sanitizedHTML = builder.String()
|
||||
} else if len(content.Body) < 100 && emojirunes.IsOnlyEmojis(content.Body) {
|
||||
bigEmoji = true
|
||||
}
|
||||
wasPlaintext = true
|
||||
}
|
||||
|
@ -402,6 +405,7 @@ func (h *HiClient) calculateLocalContent(ctx context.Context, dbEvt *database.Ev
|
|||
SanitizedHTML: sanitizedHTML,
|
||||
HTMLVersion: CurrentHTMLSanitizerVersion,
|
||||
WasPlaintext: wasPlaintext,
|
||||
BigEmoji: bigEmoji,
|
||||
}, inlineImages
|
||||
}
|
||||
return nil, nil
|
||||
|
|
|
@ -83,6 +83,7 @@ export interface LocalContent {
|
|||
sanitized_html?: TrustedHTML
|
||||
html_version?: number
|
||||
was_plaintext?: boolean
|
||||
big_emoji?: boolean
|
||||
}
|
||||
|
||||
export interface BaseDBEvent {
|
||||
|
|
|
@ -33,11 +33,14 @@ const TextMessageBody = ({ event, sender }: EventContentProps) => {
|
|||
classNames.push("emote-message")
|
||||
eventSenderName = sender?.content?.displayname || event.sender
|
||||
}
|
||||
if (event.local_content?.big_emoji) {
|
||||
classNames.push("big-emoji-body")
|
||||
}
|
||||
if (event.local_content?.was_plaintext) {
|
||||
classNames.push("plaintext-body")
|
||||
}
|
||||
if (event.local_content?.sanitized_html) {
|
||||
classNames.push("html-body")
|
||||
if (event.local_content.was_plaintext) {
|
||||
classNames.push("plaintext-body")
|
||||
}
|
||||
return <div
|
||||
onClick={onClickHTML}
|
||||
className={classNames.join(" ")}
|
||||
|
|
|
@ -35,6 +35,10 @@ div.message-text {
|
|||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
&.big-emoji-body {
|
||||
font-size: 3rem;
|
||||
}
|
||||
|
||||
&.notice-message {
|
||||
opacity: .6;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue