fix: sync post translation state and clear feed cache on language change

This commit is contained in:
Adolfo Reyna
2026-02-25 18:49:50 -05:00
parent c281878875
commit c508ea8fea
3 changed files with 14 additions and 2 deletions

View File

@@ -10,7 +10,7 @@ import { useSnapshot } from 'valtio';
import GlobalState from '../contexts/GlobalState.js';
import ProfileCardHorizontal from "../components/ProfileCardHorizontal.js";
import * as Updates from 'expo-updates';
import AsyncStorage from '@react-native-async-storage/async-storage';
let MenuView = ({ navigation }) => {
const [value, setValue] = React.useState(i18n.locale);
@@ -32,10 +32,11 @@ let MenuView = ({ navigation }) => {
}
}, []);
let changeLang = (locale) => {
let changeLang = async (locale) => {
i18n.locale = locale;
Moment.locale(locale);
setValue(locale);
await AsyncStorage.removeItem('feed');
//Change local on profile then reload
}
const languageOptions = [

View File

@@ -11,6 +11,7 @@ import GlobalState from '../contexts/GlobalState.js';
import API from "../API.js";
import * as ImagePicker from 'expo-image-picker';
import { useNavigation } from '@react-navigation/native';
import AsyncStorage from '@react-native-async-storage/async-storage';
@@ -158,6 +159,11 @@ let ProfileSettings = () => {
...currentProfile,
};
}
await AsyncStorage.removeItem('feed');
if (language && language !== i18n.locale) {
i18n.locale = language;
Moment.locale(language);
}
console.log(r);
setUpdateKey((k) => k + 1);
if (goBackAfter) {