From f1ae3ab81b29d16b2e89e423931ccbd8ace46ab3 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 9 Mar 2021 12:47:19 +1000 Subject: [PATCH] Sigils: fix default background --- .../src/views/apps/chat/components/ChatMessage.tsx | 5 ++++- pkg/interface/src/views/components/Author.tsx | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx index ac7fc2d3c2..2d4ca543aa 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx @@ -246,7 +246,10 @@ export const MessageAuthor = ({ scrollWindow, ...rest }) => { - const dark = useLocalState((state) => state.dark); + const osDark = useLocalState((state) => state.dark); + + const theme = useSettingsState(s => s.display.theme); + const dark = theme === 'dark' || (theme === 'auto' && osDark) const datestamp = moment .unix(msg['time-sent'] / 1000) diff --git a/pkg/interface/src/views/components/Author.tsx b/pkg/interface/src/views/components/Author.tsx index 720b86c3a9..ec5a418457 100644 --- a/pkg/interface/src/views/components/Author.tsx +++ b/pkg/interface/src/views/components/Author.tsx @@ -8,6 +8,7 @@ import { Group } from '@urbit/api'; import { uxToHex, cite, useShowNickname, deSig } from '~/logic/lib/util'; import useSettingsState, {selectCalmState} from "~/logic/state/settings"; +import useLocalState from "~/logic/state/local"; import OverlaySigil from './OverlaySigil'; import { Sigil } from '~/logic/lib/sigil'; import GlobalApi from '~/logic/api/global'; @@ -28,11 +29,16 @@ interface AuthorProps { export default function Author(props: AuthorProps): ReactElement { const { contacts, ship = '', date, showImage, group } = props; const history = useHistory(); + const osDark = useLocalState((state) => state.dark); + + const theme = useSettingsState(s => s.display.theme); + const dark = theme === 'dark' || (theme === 'auto' && osDark) + let contact; if (contacts) { contact = `~${deSig(ship)}` in contacts ? contacts[`~${deSig(ship)}`] : null; } - const color = contact?.color ? `#${uxToHex(contact?.color)}` : '#000000'; + const color = contact?.color ? `#${uxToHex(contact?.color)}` : dark ? '#000000' : '#FFFFFF'; const showNickname = useShowNickname(contact); const { hideAvatars } = useSettingsState(selectCalmState); const name = showNickname ? contact.nickname : cite(ship);