about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAnsh Nanda <anshnanda10@gmail.com>2023-05-25 00:18:00 -0700
committerAnsh Nanda <anshnanda10@gmail.com>2023-05-25 00:18:00 -0700
commit524f8b6abd1787e3fefc640e752e2ed1ecac5898 (patch)
treed12bcfcef4d26ac6f12f7e2aea8766ac14c148d7 /src
parent0bdb0ac006a63604f23e73330cb7d6365bb36b4b (diff)
parent93e9fa8edfe1d8a046399a2b4b31bba4d69814f8 (diff)
downloadvoidsky-524f8b6abd1787e3fefc640e752e2ed1ecac5898.tar.zst
Merge branch 'custom-algos' of https://github.com/bluesky-social/social-app into custom-algos
Diffstat (limited to 'src')
-rw-r--r--src/state/models/feeds/notifications.ts4
-rw-r--r--src/view/com/util/load-latest/LoadLatestBtn.web.tsx80
-rw-r--r--src/view/com/util/load-latest/LoadLatestBtnMobile.tsx25
-rw-r--r--src/view/screens/Home.tsx10
-rw-r--r--src/view/screens/Notifications.tsx7
5 files changed, 103 insertions, 23 deletions
diff --git a/src/state/models/feeds/notifications.ts b/src/state/models/feeds/notifications.ts
index 73424f03e..3777abb92 100644
--- a/src/state/models/feeds/notifications.ts
+++ b/src/state/models/feeds/notifications.ts
@@ -290,7 +290,9 @@ export class NotificationsFeedModel {
   }
 
   get hasNewLatest() {
-    return this.queuedNotifications && this.queuedNotifications?.length > 0
+    return Boolean(
+      this.queuedNotifications && this.queuedNotifications?.length > 0,
+    )
   }
 
   get unreadCountLabel(): string {
diff --git a/src/view/com/util/load-latest/LoadLatestBtn.web.tsx b/src/view/com/util/load-latest/LoadLatestBtn.web.tsx
index 7a3e55d7d..fefc540c0 100644
--- a/src/view/com/util/load-latest/LoadLatestBtn.web.tsx
+++ b/src/view/com/util/load-latest/LoadLatestBtn.web.tsx
@@ -3,7 +3,6 @@ import {StyleSheet, TouchableOpacity} from 'react-native'
 import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
 import {Text} from '../text/Text'
 import {usePalette} from 'lib/hooks/usePalette'
-import {UpIcon} from 'lib/icons'
 import {LoadLatestBtn as LoadLatestBtnMobile} from './LoadLatestBtnMobile'
 import {isMobileWeb} from 'platform/detection'
 
@@ -12,30 +11,60 @@ const HITSLOP = {left: 20, top: 20, right: 20, bottom: 20}
 export const LoadLatestBtn = ({
   onPress,
   label,
+  showIndicator,
+  minimalShellMode,
 }: {
   onPress: () => void
   label: string
+  showIndicator: boolean
+  minimalShellMode?: boolean
 }) => {
   const pal = usePalette('default')
   if (isMobileWeb) {
-    return <LoadLatestBtnMobile onPress={onPress} label={label} />
+    return (
+      <LoadLatestBtnMobile
+        onPress={onPress}
+        label={label}
+        showIndicator={showIndicator}
+      />
+    )
   }
   return (
-    <TouchableOpacity
-      style={[pal.view, pal.borderDark, styles.loadLatest]}
-      onPress={onPress}
-      hitSlop={HITSLOP}
-      accessibilityRole="button"
-      accessibilityLabel={label}
-      accessibilityHint="">
-      <Text type="md-bold" style={pal.text}>
-        <FontAwesomeIcon
-          icon="angle-up"
-          size={21}
-          style={[pal.text, styles.icon]}
-        />
-      </Text>
-    </TouchableOpacity>
+    <>
+      {showIndicator && (
+        <TouchableOpacity
+          style={[
+            pal.view,
+            pal.borderDark,
+            styles.loadLatestCentered,
+            minimalShellMode && styles.loadLatestCenteredMinimal,
+          ]}
+          onPress={onPress}
+          hitSlop={HITSLOP}
+          accessibilityRole="button"
+          accessibilityLabel={label}
+          accessibilityHint="">
+          <Text type="md-bold" style={pal.text}>
+            {label}
+          </Text>
+        </TouchableOpacity>
+      )}
+      <TouchableOpacity
+        style={[pal.view, pal.borderDark, styles.loadLatest]}
+        onPress={onPress}
+        hitSlop={HITSLOP}
+        accessibilityRole="button"
+        accessibilityLabel={label}
+        accessibilityHint="">
+        <Text type="md-bold" style={pal.text}>
+          <FontAwesomeIcon
+            icon="angle-up"
+            size={21}
+            style={[pal.text, styles.icon]}
+          />
+        </Text>
+      </TouchableOpacity>
+    </>
   )
 }
 
@@ -58,4 +87,21 @@ const styles = StyleSheet.create({
     position: 'relative',
     top: 2,
   },
+  loadLatestCentered: {
+    flexDirection: 'row',
+    alignItems: 'center',
+    justifyContent: 'center',
+    position: 'absolute',
+    left: '50vw',
+    // @ts-ignore web only -prf
+    transform: 'translateX(-50%)',
+    top: 60,
+    paddingHorizontal: 24,
+    paddingVertical: 14,
+    borderRadius: 30,
+    borderWidth: 1,
+  },
+  loadLatestCenteredMinimal: {
+    top: 20,
+  },
 })
diff --git a/src/view/com/util/load-latest/LoadLatestBtnMobile.tsx b/src/view/com/util/load-latest/LoadLatestBtnMobile.tsx
index 5e03e2285..412b9b803 100644
--- a/src/view/com/util/load-latest/LoadLatestBtnMobile.tsx
+++ b/src/view/com/util/load-latest/LoadLatestBtnMobile.tsx
@@ -1,16 +1,26 @@
 import React from 'react'
-import {StyleSheet, TouchableOpacity} from 'react-native'
+import {StyleSheet, TouchableOpacity, View} from 'react-native'
 import {observer} from 'mobx-react-lite'
 import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
 import {useSafeAreaInsets} from 'react-native-safe-area-context'
 import {clamp} from 'lodash'
 import {useStores} from 'state/index'
 import {usePalette} from 'lib/hooks/usePalette'
+import {colors} from 'lib/styles'
 
 const HITSLOP = {left: 20, top: 20, right: 20, bottom: 20}
 
 export const LoadLatestBtn = observer(
-  ({onPress, label}: {onPress: () => void; label: string}) => {
+  ({
+    onPress,
+    label,
+    showIndicator,
+  }: {
+    onPress: () => void
+    label: string
+    showIndicator: boolean
+    minimalShellMode?: boolean // NOTE not used on mobile -prf
+  }) => {
     const store = useStores()
     const pal = usePalette('default')
     const safeAreaInsets = useSafeAreaInsets()
@@ -30,6 +40,7 @@ export const LoadLatestBtn = observer(
         accessibilityLabel={label}
         accessibilityHint="">
         <FontAwesomeIcon icon="angle-up" color={pal.colors.text} size={19} />
+        {showIndicator && <View style={[styles.indicator, pal.borderDark]} />}
       </TouchableOpacity>
     )
   },
@@ -48,4 +59,14 @@ const styles = StyleSheet.create({
     alignItems: 'center',
     justifyContent: 'center',
   },
+  indicator: {
+    position: 'absolute',
+    top: 3,
+    right: 3,
+    backgroundColor: colors.blue3,
+    width: 12,
+    height: 12,
+    borderRadius: 6,
+    borderWidth: 1,
+  },
 })
diff --git a/src/view/screens/Home.tsx b/src/view/screens/Home.tsx
index 35f7b826b..2aade5e1a 100644
--- a/src/view/screens/Home.tsx
+++ b/src/view/screens/Home.tsx
@@ -240,6 +240,7 @@ const FeedPage = observer(
       feed.refresh()
     }, [feed, scrollToTop])
 
+    const hasNew = feed.hasNewLatest && !feed.isRefreshing
     return (
       <View testID={testID} style={s.h100pct}>
         <Feed
@@ -254,8 +255,13 @@ const FeedPage = observer(
           renderEmptyState={renderEmptyState}
           headerOffset={HEADER_OFFSET}
         />
-        {isScrolledDown && (
-          <LoadLatestBtn onPress={onPressLoadLatest} label="Load new posts" />
+        {(isScrolledDown || hasNew) && (
+          <LoadLatestBtn
+            onPress={onPressLoadLatest}
+            label="Load new posts"
+            showIndicator={hasNew}
+            minimalShellMode={store.shell.minimalShellMode}
+          />
         )}
         <FAB
           testID="composeFAB"
diff --git a/src/view/screens/Notifications.tsx b/src/view/screens/Notifications.tsx
index 02a4618c3..4db1d14ae 100644
--- a/src/view/screens/Notifications.tsx
+++ b/src/view/screens/Notifications.tsx
@@ -88,6 +88,9 @@ export const NotificationsScreen = withAuthRequired(
       ),
     )
 
+    const hasNew =
+      store.me.notifications.hasNewLatest &&
+      !store.me.notifications.isRefreshing
     return (
       <View testID="notificationsScreen" style={s.hContentRegion}>
         <ViewHeader title="Notifications" canGoBack={false} />
@@ -98,10 +101,12 @@ export const NotificationsScreen = withAuthRequired(
           onScroll={onMainScroll}
           scrollElRef={scrollElRef}
         />
-        {isScrolledDown && (
+        {(isScrolledDown || hasNew) && (
           <LoadLatestBtn
             onPress={onPressLoadLatest}
             label="Load new notifications"
+            showIndicator={hasNew}
+            minimalShellMode={true}
           />
         )}
       </View>