Merge pull request #325 from SableClient/fix-colors-and-threads
Fix colors and threads and things
This commit is contained in:
8 files changed
+98
-23
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix opacity rendering in name colors.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix sending scheduled file attachments.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix replies rendering new lines when messages have lists.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix threads rendering fallback replies.
|
||||
@@ -122,6 +122,8 @@ export const Reply = as<'div', ReplyProps>(
|
||||
.replaceAll(/<br\s*\/?>/gi, ' ')
|
||||
.replaceAll(/<\/p>\s*<p[^>]*>/gi, ' ')
|
||||
.replaceAll(/<\/?p[^>]*>/gi, '')
|
||||
.replaceAll(/<\/li>\s*<li[^>]*>/gi, ' ')
|
||||
.replaceAll(/<\/?(ul|ol|li|blockquote|h[1-6]|pre|div)[^>]*>/gi, '')
|
||||
.replaceAll(/(?:\r\n|\r|\n)/g, ' ');
|
||||
const parserOpts = getReactCustomHtmlParser(mx, room.roomId, {
|
||||
linkifyOpts: LINKIFY_OPTS,
|
||||
|
||||
@@ -512,28 +512,74 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
}
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
contents.map((content) =>
|
||||
mx
|
||||
.sendMessage(roomId, threadRootId ?? null, content as any)
|
||||
.then((res) => {
|
||||
debugLog.info('message', 'Uploaded file message sent', {
|
||||
roomId,
|
||||
eventId: res.event_id,
|
||||
msgtype: content.msgtype,
|
||||
});
|
||||
return res;
|
||||
const invalidate = () =>
|
||||
queryClient.invalidateQueries({ queryKey: ['delayedEvents', roomId] });
|
||||
|
||||
if (scheduledTime) {
|
||||
try {
|
||||
const delayMs = computeDelayMs(scheduledTime);
|
||||
if (editingScheduledDelayId) {
|
||||
await cancelDelayedEvent(mx, editingScheduledDelayId);
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
contents.map((content) => {
|
||||
if (isEncrypted) {
|
||||
return sendDelayedMessageE2EE(mx, roomId, room, content, delayMs);
|
||||
}
|
||||
return sendDelayedMessage(mx, roomId, content, delayMs);
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
debugLog.error('message', 'Failed to send uploaded file message', {
|
||||
roomId,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
});
|
||||
log.error('failed to send uploaded message', { roomId }, error);
|
||||
throw error;
|
||||
})
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
invalidate();
|
||||
setEditingScheduledDelayId(null);
|
||||
setScheduledTime(null);
|
||||
} catch (error) {
|
||||
debugLog.error('message', 'Failed to schedule uploaded file message', {
|
||||
roomId,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
});
|
||||
log.error('failed to schedule uploaded message', { roomId }, error);
|
||||
throw error;
|
||||
}
|
||||
} else {
|
||||
if (editingScheduledDelayId) {
|
||||
try {
|
||||
await cancelDelayedEvent(mx, editingScheduledDelayId);
|
||||
invalidate();
|
||||
setEditingScheduledDelayId(null);
|
||||
} catch {
|
||||
debugLog.error(
|
||||
'message',
|
||||
'Failed to cancel scheduled event before immediate file send',
|
||||
{ roomId }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
contents.map((content) =>
|
||||
mx
|
||||
.sendMessage(roomId, threadRootId ?? null, content as any)
|
||||
.then((res) => {
|
||||
debugLog.info('message', 'Uploaded file message sent', {
|
||||
roomId,
|
||||
eventId: res.event_id,
|
||||
msgtype: content.msgtype,
|
||||
});
|
||||
return res;
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
debugLog.error('message', 'Failed to send uploaded file message', {
|
||||
roomId,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
});
|
||||
log.error('failed to send uploaded message', { roomId }, error);
|
||||
throw error;
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCloseAutocomplete = useCallback(() => {
|
||||
|
||||
@@ -180,6 +180,11 @@ function ThreadMessage({
|
||||
|
||||
const { replyEventId } = mEvent;
|
||||
|
||||
const relation = mEvent.getRelation();
|
||||
const contentRelatesTo = mEvent.getContent()?.['m.relates_to'];
|
||||
const isFallback =
|
||||
relation?.is_falling_back === true || contentRelatesTo?.is_falling_back === true;
|
||||
|
||||
return (
|
||||
<Message
|
||||
key={mEvent.getId()}
|
||||
@@ -214,7 +219,8 @@ function ThreadMessage({
|
||||
hideReadReceipts={showHideReads}
|
||||
showDeveloperTools={showDeveloperTools}
|
||||
reply={
|
||||
replyEventId && (
|
||||
replyEventId &&
|
||||
!isFallback && (
|
||||
<Reply
|
||||
room={room}
|
||||
timelineSet={timelineSet}
|
||||
|
||||
@@ -69,7 +69,8 @@ const isValidHex = (c: any): string | undefined => {
|
||||
if (typeof c !== 'string') return undefined;
|
||||
// silly tuwunel smh
|
||||
const cleaned = c.replaceAll(/["']/g, '').trim();
|
||||
return /^#([0-9A-F]{3,6})$/i.test(cleaned) ? cleaned : undefined;
|
||||
// Strictly allow only 3 or 6 digit hex codes, aka no opacity
|
||||
return /^#([0-9A-F]{3}|[0-9A-F]{6})$/i.test(cleaned) ? cleaned : undefined;
|
||||
};
|
||||
const sanitizeFont = (f: string) => f.replaceAll(/[;{}<>]/g, '').slice(0, 32);
|
||||
|
||||
|
||||
Reference in new issue
Block a user