Skip to content

Commit

Permalink
new-version-alert (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat authored Nov 28, 2023
2 parents bc43383 + 29a67fe commit b04544c
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 16 deletions.
42 changes: 32 additions & 10 deletions frontend/Components/MenuItems/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { usernamePubKey } from '../../Functions/RelayFunctions/Users'
import ProfileData from '../ProfileData'
import { WalletContext } from '../../Contexts/WalletContext'
import { AppContext } from '../../Contexts/AppContext'
import VersionNumber from 'react-native-version-number'
import axios from 'axios'

export const MenuItems: React.FC = () => {
const [drawerItemIndex, setDrawerItemIndex] = React.useState<number>(-1)
Expand All @@ -44,6 +46,7 @@ export const MenuItems: React.FC = () => {

const [activerelays, setActiveRelays] = React.useState<number>(0)
const [loadingConnection, setLoadingConnection] = React.useState<boolean>(false)
const [newVersion, setNewVerion] = React.useState<boolean>(false)

React.useEffect(() => {
setActiveRelays(relays.filter((relay) => relay.active).length)
Expand Down Expand Up @@ -82,6 +85,16 @@ export const MenuItems: React.FC = () => {
setLoadingConnection(false)
}, [online])

React.useEffect(() => {
axios.get('https://api.github.com/repos/KoalaSat/nostros/releases/latest')
.then((response) => {
if (response) {
const tag = response.data.tag_name
setNewVerion(online && Boolean(tag) && tag !== VersionNumber.appVersion)
}
})
}, [])

return (
<>
<DrawerContentScrollView
Expand Down Expand Up @@ -219,15 +232,24 @@ export const MenuItems: React.FC = () => {
onPress={() => onPressItem('faq', 5)}
onTouchEnd={() => setDrawerItemIndex(-1)}
/>
<Drawer.Item
label={t('menuItems.reportBug')}
icon='bug-outline'
key='bug'
active={drawerItemIndex === 2}
onPress={async () =>
await Linking.openURL('https://github.com/KoalaSat/nostros/issues/new/choose')
}
/>
{newVersion && (
<Drawer.Item
label={t('menuItems.newVersion')}
icon='cellphone-arrow-down'
key='version'
active={drawerItemIndex === 2}
onPress={async () =>
await Linking.openURL('https://github.com/KoalaSat/nostros/releases/latest')
}
right={() =>
<MaterialCommunityIcons
name='exclamation-thick'
size={25}
color='#FFDCBB'
/>
}
/>
)}
</Drawer.Section>
</DrawerContentScrollView>
<Drawer.Section
Expand Down Expand Up @@ -335,7 +357,7 @@ const styles = StyleSheet.create({
verifyIcon: {
paddingTop: 6,
paddingLeft: 5,
},
}
})

export default MenuItems
3 changes: 2 additions & 1 deletion frontend/Locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@
"logout": "Abmelden",
"exports": "Export",
"online": "Online",
"offline": "Offline"
"offline": "Offline",
"newVersion": "Update"
},
"configPage": {
"signHeight": "Sign events with latest Bitcoin block",
Expand Down
3 changes: 2 additions & 1 deletion frontend/Locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@
"logout": "Logout",
"exports": "Export",
"online": "Online",
"offline": "Offline"
"offline": "Offline",
"newVersion": "Update"
},
"configPage": {
"showPublicImages": "Show images on public feed",
Expand Down
3 changes: 2 additions & 1 deletion frontend/Locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@
"logout": "Salir",
"exports": "Exportar/Importar",
"online": "Online",
"offline": "Offline"
"offline": "Offline",
"newVersion": "Update"
},
"configPage": {
"signHeight": "Firmar con el último bloque bitcoin",
Expand Down
3 changes: 2 additions & 1 deletion frontend/Locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@
"logout": "Sortir",
"exports": "Export",
"online": "Online",
"offline": "Offline"
"offline": "Offline",
"newVersion": "Update"
},
"language": {
"en": "English",
Expand Down
3 changes: 2 additions & 1 deletion frontend/Locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@
"imageHostingService": "Хостинг изображений",
"exports": "Export",
"online": "Online",
"offline": "Offline"
"offline": "Offline",
"newVersion": "Update"
},
"configPage": {
"signHeight": "Sign events with latest Bitcoin block",
Expand Down
3 changes: 2 additions & 1 deletion frontend/Locales/zhCn.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@
"logout": "退出",
"exports": "Export",
"online": "Online",
"offline": "Offline"
"offline": "Offline",
"newVersion": "Update"
},
"configPage": {
"signHeight": "用最新的比特币区块签署事件",
Expand Down
16 changes: 16 additions & 0 deletions frontend/Pages/AboutPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ export const AboutPage: React.FC = () => {
),
onPress: async () => await Linking.openURL('https://github.com/KoalaSat/nostros'),
},
{
key: 2,
title: t('menuItems.reportBug'),
left: (
<List.Icon
icon={() => (
<MaterialCommunityIcons
name='bug-outline'
size={25}
color={theme.colors.onPrimaryContainer}
/>
)}
/>
),
onPress: async () => await Linking.openURL('https://github.com/KoalaSat/nostros/issues/new/choose'),
},
{
key: 3,
title: t('aboutPage.telegram'),
Expand Down
1 change: 1 addition & 0 deletions frontend/Pages/HomeNavigator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const HomeNavigator: React.FC = () => {
const bottomSheetRelaysRef = React.useRef<RBSheet>(null)
const bottomSheetLoginRef = React.useRef<RBSheet>(null)
const Stack = React.useMemo(() => createStackNavigator(), [])

const cardStyleInterpolator = React.useMemo(
() =>
Platform.OS === 'android'
Expand Down

0 comments on commit b04544c

Please sign in to comment.