diff --git a/src/components/ui/DateDivider.tsx b/src/components/ui/DateDivider.tsx index ec0a54d0..24de9173 100644 --- a/src/components/ui/DateDivider.tsx +++ b/src/components/ui/DateDivider.tsx @@ -14,7 +14,7 @@ const Base = styled.div<{ unread?: boolean }>` margin-top: -2px; font-size: 0.6875rem; line-height: 0.6875rem; - padding: 2px 0 2px 0; + padding-inline-start: 5px; padding-inline-end: 5px; color: var(--tertiary-foreground); background: var(--primary-background); @@ -30,7 +30,8 @@ const Base = styled.div<{ unread?: boolean }>` const Unread = styled.div` background: var(--accent); color: white; - padding: 5px 8px; + font-size: 7px; + padding: 2px 6px; border-radius: 60px; font-weight: 600; `; diff --git a/src/mobx/stores/helpers/STheme.ts b/src/mobx/stores/helpers/STheme.ts index 4316a91e..b2b20c4c 100644 --- a/src/mobx/stores/helpers/STheme.ts +++ b/src/mobx/stores/helpers/STheme.ts @@ -201,10 +201,12 @@ export default class STheme { } } -function getContrastingColour(hex: string, fallback = "black"): string { +function getContrastingColour(hex: string, fallback?: string): string { + if (typeof hex !== "string") return "black"; + // TODO: Switch to color-parse // Try parse hex value. - hex = hex.replace("#", ""); + hex = hex.replace(/#/g, ""); const r = parseInt(hex.substr(0, 2), 16) / 255; const g = parseInt(hex.substr(2, 2), 16) / 255; const b = parseInt(hex.substr(4, 2), 16) / 255; diff --git a/src/pages/channels/Channel.tsx b/src/pages/channels/Channel.tsx index 17efb460..b7fc03bb 100644 --- a/src/pages/channels/Channel.tsx +++ b/src/pages/channels/Channel.tsx @@ -21,7 +21,7 @@ import MessageBox from "../../components/common/messaging/MessageBox"; import JumpToBottom from "../../components/common/messaging/bars/JumpToBottom"; import NewMessages from "../../components/common/messaging/bars/NewMessages"; import TypingIndicator from "../../components/common/messaging/bars/TypingIndicator"; -import Header, { PageHeader } from "../../components/ui/Header"; +import { PageHeader } from "../../components/ui/Header"; import RightSidebar from "../../components/navigation/RightSidebar"; import ChannelHeader from "./ChannelHeader"; @@ -130,7 +130,7 @@ const TextChannel = observer(({ channel }: { channel: ChannelI }) => { - + diff --git a/src/pages/channels/messaging/MessageArea.tsx b/src/pages/channels/messaging/MessageArea.tsx index 3c690cbb..1b2c0278 100644 --- a/src/pages/channels/messaging/MessageArea.tsx +++ b/src/pages/channels/messaging/MessageArea.tsx @@ -51,13 +51,14 @@ const Area = styled.div` `; interface Props { + last_id?: string; channel: Channel; } export const MessageAreaWidthContext = createContext(0); export const MESSAGE_AREA_PADDING = 82; -export const MessageArea = observer(({ channel }: Props) => { +export const MessageArea = observer(({ last_id, channel }: Props) => { const history = useHistory(); const status = useContext(StatusContext); const { focusTaken } = useContext(IntermediateContext); @@ -323,6 +324,7 @@ export const MessageArea = observer(({ channel }: Props) => { )} {renderer.state === "RENDER" && ( diff --git a/src/pages/channels/messaging/MessageRenderer.tsx b/src/pages/channels/messaging/MessageRenderer.tsx index 2a7f629c..7ed45c59 100644 --- a/src/pages/channels/messaging/MessageRenderer.tsx +++ b/src/pages/channels/messaging/MessageRenderer.tsx @@ -30,6 +30,7 @@ import ConversationStart from "./ConversationStart"; import MessageEditor from "./MessageEditor"; interface Props { + last_id?: string; highlight?: string; renderer: ChannelRenderer; } @@ -45,7 +46,7 @@ const BlockedMessage = styled.div` } `; -export default observer(({ renderer, highlight }: Props) => { +export default observer(({ last_id, renderer, highlight }: Props) => { const client = useClient(); const userId = client.user!._id; const queue = useApplicationState().queue; @@ -94,6 +95,7 @@ export default observer(({ renderer, highlight }: Props) => { } let head = true; + let divided = false; function compare( current: string, curAuthor: string, @@ -107,16 +109,25 @@ export default observer(({ renderer, highlight }: Props) => { btime = decodeTime(previous), bdate = new Date(btime); + let unread = false; + if (!divided && last_id && previous >= last_id) { + unread = true; + divided = true; + } + + head = false; if ( + unread || adate.getFullYear() !== bdate.getFullYear() || adate.getMonth() !== bdate.getMonth() || adate.getDate() !== bdate.getDate() ) { - render.push(); + render.push(); head = true; } head = + head || curAuthor !== prevAuthor || Math.abs(btime - atime) >= 420000 || !isEqual(currentMasq, previousMasq);