mirror of
https://github.com/anultravioletaurora/Jellify.git
synced 2025-12-21 05:20:06 -06:00
feat:Force OTA (#632)
This commit is contained in:
@@ -79,7 +79,7 @@
|
||||
"react-native-mmkv": "3.3.3",
|
||||
"react-native-nitro-image": "0.8.1",
|
||||
"react-native-nitro-modules": "^0.31.3",
|
||||
"react-native-nitro-ota": "^0.3.0",
|
||||
"react-native-nitro-ota": "^0.4.0",
|
||||
"react-native-nitro-web-image": "0.8.1",
|
||||
"react-native-pager-view": "^6.9.1",
|
||||
"react-native-reanimated": "4.1.3",
|
||||
|
||||
@@ -30,11 +30,23 @@ get_random_sentence() {
|
||||
done
|
||||
}
|
||||
|
||||
# Function to generate a random 3-digit alphanumeric string
|
||||
get_random_alphanum() {
|
||||
local chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
local result=""
|
||||
for i in {1..3}; do
|
||||
result="${result}${chars:RANDOM%${#chars}:1}"
|
||||
done
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
new_sentence=$(get_random_sentence)
|
||||
alphanum_suffix=$(get_random_alphanum)
|
||||
version_string="${new_sentence} (${alphanum_suffix})"
|
||||
|
||||
# Write atomically
|
||||
tmp="${FILE}.tmp.$$"
|
||||
echo "$new_sentence" > "$tmp"
|
||||
echo "$version_string" > "$tmp"
|
||||
mv "$tmp" "$FILE"
|
||||
|
||||
echo "✅ Updated $FILE with: \"$new_sentence\""
|
||||
echo "✅ Updated $FILE with: \"$version_string\""
|
||||
@@ -26,6 +26,23 @@ const { downloadUrl, versionUrl } = githubOTA({
|
||||
|
||||
const otaManager = new OTAUpdateManager(downloadUrl, versionUrl)
|
||||
|
||||
export const downloadUpdate = (showCatchAlert: boolean = false) => {
|
||||
otaManager
|
||||
.downloadUpdate()
|
||||
.then(() => {
|
||||
Alert.alert('Jellify has been updated!', 'Restart to apply the changes', [
|
||||
{ text: 'OK', onPress: () => reloadApp() },
|
||||
{ text: 'Cancel', style: 'cancel' },
|
||||
])
|
||||
})
|
||||
.catch((error) => {
|
||||
if (showCatchAlert) {
|
||||
Alert.alert('Either the update is not available or there is an error')
|
||||
}
|
||||
console.error('Error downloading update:', error)
|
||||
})
|
||||
}
|
||||
|
||||
const GitUpdateModal = () => {
|
||||
const progress = useSharedValue(0)
|
||||
const [loading, setLoading] = React.useState(false)
|
||||
@@ -47,21 +64,7 @@ const GitUpdateModal = () => {
|
||||
.checkForUpdates()
|
||||
.then((update) => {
|
||||
if (update) {
|
||||
otaManager
|
||||
.downloadUpdate()
|
||||
.then(() => {
|
||||
Alert.alert(
|
||||
'Jellify has been updated!',
|
||||
'Restart to apply the changes',
|
||||
[
|
||||
{ text: 'OK', onPress: () => reloadApp() },
|
||||
{ text: 'Cancel', style: 'cancel' },
|
||||
],
|
||||
)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error downloading update:', error)
|
||||
})
|
||||
downloadUpdate()
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@@ -2,6 +2,10 @@ import { RadioGroup, YStack } from 'tamagui'
|
||||
import { SwitchWithLabel } from '../../Global/helpers/switch-with-label'
|
||||
import SettingsListGroup from './settings-list-group'
|
||||
import { RadioGroupItemWithLabel } from '../../Global/helpers/radio-group-item-with-label'
|
||||
import Button from '../../Global/helpers/button'
|
||||
import Icon from '../../Global/components/icon'
|
||||
import { Text } from '../../Global/helpers/text'
|
||||
import { downloadUpdate } from '../../OtaUpdates'
|
||||
import {
|
||||
ThemeSetting,
|
||||
useReducedHapticsSetting,
|
||||
@@ -68,6 +72,26 @@ export default function PreferencesTab(): React.JSX.Element {
|
||||
/>
|
||||
),
|
||||
},
|
||||
|
||||
{
|
||||
title: 'Forcefully download the latest OTA',
|
||||
iconName: 'web',
|
||||
iconColor: '$success',
|
||||
subTitle: 'Download the latest ota forcefully',
|
||||
children: (
|
||||
<Button
|
||||
variant='outlined'
|
||||
color={'$success'}
|
||||
borderColor={'$success'}
|
||||
icon={() => <Icon name='download' small color={'$success'} />}
|
||||
onPress={() => downloadUpdate(true)}
|
||||
>
|
||||
<Text bold color={'$success'}>
|
||||
Download Update
|
||||
</Text>
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -8432,10 +8432,10 @@ react-native-nitro-modules@^0.31.3:
|
||||
resolved "https://registry.yarnpkg.com/react-native-nitro-modules/-/react-native-nitro-modules-0.31.3.tgz#19d26c3c677921687a42ed9c9943050034b3aebe"
|
||||
integrity sha512-jGHBfSTzSo6eXcb0X4/N1sfYdHm2E+koE2fifLZ3gtArD+3ZeThyFvERhB2fzd4JOqtcIJL/5VLIjxlbjISQ/g==
|
||||
|
||||
react-native-nitro-ota@^0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/react-native-nitro-ota/-/react-native-nitro-ota-0.3.0.tgz#f3a45db30c120b1ad6230229e8725f8e0e827b96"
|
||||
integrity sha512-dOus16bKJ4wLsPWFLToXoEOiCl5loxh8l3fPqF4WiMxiLkUyXuH3mh+e0S5HIdd8kbnZHqtLGofCX0CdUxksnQ==
|
||||
react-native-nitro-ota@^0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/react-native-nitro-ota/-/react-native-nitro-ota-0.4.0.tgz#996b2ccaf6accc92b1d352df448250ca35a6d2e6"
|
||||
integrity sha512-/JAoM2m3WsvnO7dC51bf5jCghxO78yrP3vHyq3/itK+MqiwU8HPk8bGbXLhE+/GYRPS8DbUHGrzptzO2KOoutQ==
|
||||
|
||||
react-native-nitro-web-image@0.8.1:
|
||||
version "0.8.1"
|
||||
|
||||
Reference in New Issue
Block a user