fix(lib/discord/modules/settings): fix edge case on renavigation in refreshSettingsOverviewScreen

If a route was replaced before renavigation, renavigation would fail. This commit fixes that issue.
This commit is contained in:
PalmDevs 2025-07-14 23:46:17 +07:00
parent 8d4581f9c1
commit ab8e2a5772
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA

View file

@ -4,7 +4,7 @@ import { findInTree } from '@revenge-mod/utils/tree'
import { Constants } from '../../common'
import { RootNavigationRef } from '../main_tabs_v2'
import { sData, sSubscriptions } from './_internal'
import type { NavigationState } from '@react-navigation/core'
import type { NavigationState, PartialState } from '@react-navigation/core'
import type { DiscordModules } from '../../types'
export type SettingsItem = DiscordModules.Modules.Settings.SettingsItem
@ -143,9 +143,12 @@ export async function refreshSettingsOverviewScreen(renavigate?: boolean) {
navigation.navigate(mainState.routes[mainState.index].name)
// Dispatch on next paint
// Wait for navigation to complete and reset to the settings state
requestAnimationFrame(() => {
navigation.dispatch(CommonActions.reset(settingsState))
navigation.reset({
index: settingsState.routes.length - 1,
routes: settingsState.routes,
} as PartialState<typeof settingsState>)
})
} else {
const {