commit 56e237ca206be567982e084d56754727a1a951d8
parent 351073e05081f511360048a149ef7ccacd835a9e
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Wed, 18 Jan 2023 23:10:53 -0800
improve quote
Diffstat:
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/pkg/web/handlers/api/v1/topBarHandler.go b/pkg/web/handlers/api/v1/topBarHandler.go
@@ -662,11 +662,15 @@ func getQuoteTxt(roomKey string, quoted database.ChatMessage) (out string) {
isMe = true
decrypted = strings.TrimPrefix(decrypted, "/me ")
}
- startIdx := strings.LastIndex(decrypted, `” `)
- if startIdx == -1 {
- startIdx = 0
- } else {
- startIdx += len(`” `)
+
+ startIdx := 0
+ if strings.HasPrefix(decrypted, `“[`) {
+ startIdx = strings.Index(decrypted, `” `)
+ if startIdx == -1 {
+ startIdx = 0
+ } else {
+ startIdx += len(`” `)
+ }
}
decrypted = replTextPrefixSuffix(decrypted, agePrefix, ageSuffix, "[age.txt]")
@@ -688,7 +692,12 @@ func getQuoteTxt(roomKey string, quoted database.ChatMessage) (out string) {
if !isMe {
remaining += "- "
}
- remaining += utils.TruncStr2(decrypted[startIdx:], 70, "…")
+
+ toBeQuoted := decrypted[startIdx:]
+ toBeQuoted = strings.ReplaceAll(toBeQuoted, `“`, `"`)
+ toBeQuoted = strings.ReplaceAll(toBeQuoted, `”`, `"`)
+
+ remaining += utils.TruncStr2(toBeQuoted, 70, "…")
return `“[` + quoted.CreatedAt.Format("15:04:05") + "]" + remaining + `”`
}