about summary refs log tree commit diff
path: root/src/lib
diff options
context:
space:
mode:
authorJaz <ericvolp12@gmail.com>2023-05-17 21:19:20 -0700
committerGitHub <noreply@github.com>2023-05-17 21:19:20 -0700
commit7f76c2d67e62ba2d10e8b17673a7bbcf7248564f (patch)
treeece7f72b04ee4bb39d4118b0b520683deddaa972 /src/lib
parentac3a95dc7228ad3d1d1cb7c5e7e26968009173bb (diff)
parent0ca096138a690f036828c49f9e95cf394b1a4339 (diff)
downloadvoidsky-7f76c2d67e62ba2d10e8b17673a7bbcf7248564f.tar.zst
Merge branch 'main' into inherit_system_theme
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/hooks/useSetTitle.ts8
-rw-r--r--src/lib/hooks/useUnreadCountLabel.ts19
-rw-r--r--src/lib/icons.tsx29
3 files changed, 35 insertions, 21 deletions
diff --git a/src/lib/hooks/useSetTitle.ts b/src/lib/hooks/useSetTitle.ts
index 85ba44d29..c5c7a5ca1 100644
--- a/src/lib/hooks/useSetTitle.ts
+++ b/src/lib/hooks/useSetTitle.ts
@@ -3,11 +3,15 @@ import {useNavigation} from '@react-navigation/native'
 
 import {NavigationProp} from 'lib/routes/types'
 import {bskyTitle} from 'lib/strings/headings'
-import {useUnreadCountLabel} from './useUnreadCountLabel'
+import {useStores} from 'state/index'
 
+/**
+ * Requires consuming component to be wrapped in `observer`:
+ * https://stackoverflow.com/a/71488009
+ */
 export function useSetTitle(title?: string) {
   const navigation = useNavigation<NavigationProp>()
-  const unreadCountLabel = useUnreadCountLabel()
+  const {unreadCountLabel} = useStores().me.notifications
   useEffect(() => {
     if (title) {
       navigation.setOptions({title: bskyTitle(title, unreadCountLabel)})
diff --git a/src/lib/hooks/useUnreadCountLabel.ts b/src/lib/hooks/useUnreadCountLabel.ts
deleted file mode 100644
index e2bf77885..000000000
--- a/src/lib/hooks/useUnreadCountLabel.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import {useEffect, useReducer} from 'react'
-import {DeviceEventEmitter} from 'react-native'
-import {useStores} from 'state/index'
-
-export function useUnreadCountLabel() {
-  // HACK: We don't have anything like Redux selectors,
-  // and we don't want to use <RootStoreContext.Consumer />
-  // to react to the whole store
-  const [, forceUpdate] = useReducer(x => x + 1, 0)
-  useEffect(() => {
-    const subscription = DeviceEventEmitter.addListener(
-      'unread-notifications',
-      forceUpdate,
-    )
-    return () => subscription?.remove()
-  }, [forceUpdate])
-
-  return useStores().me.notifications.unreadCountLabel
-}
diff --git a/src/lib/icons.tsx b/src/lib/icons.tsx
index 606d27ea4..06f195011 100644
--- a/src/lib/icons.tsx
+++ b/src/lib/icons.tsx
@@ -322,6 +322,35 @@ export function MoonIcon({
 
 // Copyright (c) 2020 Refactoring UI Inc.
 // https://github.com/tailwindlabs/heroicons/blob/master/LICENSE
+export function SunIcon({
+  style,
+  size,
+  strokeWidth = 1.5,
+}: {
+  style?: StyleProp<ViewStyle>
+  size?: string | number
+  strokeWidth?: number
+}) {
+  return (
+    <Svg
+      fill="none"
+      viewBox="0 0 24 24"
+      width={size || 32}
+      height={size || 32}
+      strokeWidth={strokeWidth}
+      stroke="currentColor"
+      style={style}>
+      <Path
+        d="M12 3V5.25M18.364 5.63604L16.773 7.22703M21 12H18.75M18.364 18.364L16.773 16.773M12 18.75V21M7.22703 16.773L5.63604 18.364M5.25 12H3M7.22703 7.22703L5.63604 5.63604M15.75 12C15.75 14.0711 14.0711 15.75 12 15.75C9.92893 15.75 8.25 14.0711 8.25 12C8.25 9.92893 9.92893 8.25 12 8.25C14.0711 8.25 15.75 9.92893 15.75 12Z"
+        strokeLinecap="round"
+        strokeLinejoin="round"
+      />
+    </Svg>
+  )
+}
+
+// Copyright (c) 2020 Refactoring UI Inc.
+// https://github.com/tailwindlabs/heroicons/blob/master/LICENSE
 export function UserIcon({
   style,
   size,