fix: sync post translation state and clear feed cache on language change
This commit is contained in:
@@ -10,7 +10,7 @@ import { useSnapshot } from 'valtio';
|
|||||||
import GlobalState from '../contexts/GlobalState.js';
|
import GlobalState from '../contexts/GlobalState.js';
|
||||||
import ProfileCardHorizontal from "../components/ProfileCardHorizontal.js";
|
import ProfileCardHorizontal from "../components/ProfileCardHorizontal.js";
|
||||||
import * as Updates from 'expo-updates';
|
import * as Updates from 'expo-updates';
|
||||||
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||||
|
|
||||||
let MenuView = ({ navigation }) => {
|
let MenuView = ({ navigation }) => {
|
||||||
const [value, setValue] = React.useState(i18n.locale);
|
const [value, setValue] = React.useState(i18n.locale);
|
||||||
@@ -32,10 +32,11 @@ let MenuView = ({ navigation }) => {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
let changeLang = (locale) => {
|
let changeLang = async (locale) => {
|
||||||
i18n.locale = locale;
|
i18n.locale = locale;
|
||||||
Moment.locale(locale);
|
Moment.locale(locale);
|
||||||
setValue(locale);
|
setValue(locale);
|
||||||
|
await AsyncStorage.removeItem('feed');
|
||||||
//Change local on profile then reload
|
//Change local on profile then reload
|
||||||
}
|
}
|
||||||
const languageOptions = [
|
const languageOptions = [
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import GlobalState from '../contexts/GlobalState.js';
|
|||||||
import API from "../API.js";
|
import API from "../API.js";
|
||||||
import * as ImagePicker from 'expo-image-picker';
|
import * as ImagePicker from 'expo-image-picker';
|
||||||
import { useNavigation } from '@react-navigation/native';
|
import { useNavigation } from '@react-navigation/native';
|
||||||
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -158,6 +159,11 @@ let ProfileSettings = () => {
|
|||||||
...currentProfile,
|
...currentProfile,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
await AsyncStorage.removeItem('feed');
|
||||||
|
if (language && language !== i18n.locale) {
|
||||||
|
i18n.locale = language;
|
||||||
|
Moment.locale(language);
|
||||||
|
}
|
||||||
console.log(r);
|
console.log(r);
|
||||||
setUpdateKey((k) => k + 1);
|
setUpdateKey((k) => k + 1);
|
||||||
if (goBackAfter) {
|
if (goBackAfter) {
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ let Post = (props) => {
|
|||||||
const viewer = gState.me;
|
const viewer = gState.me;
|
||||||
let [showCommentsB, changeshowCommentsB] = useState(props.showComments || false);
|
let [showCommentsB, changeshowCommentsB] = useState(props.showComments || false);
|
||||||
let [post, changePost] = useState(props.post);
|
let [post, changePost] = useState(props.post);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
changePost(props.post);
|
||||||
|
}, [props.post]);
|
||||||
|
|
||||||
const [deleted, setDeleted] = useState(false);
|
const [deleted, setDeleted] = useState(false);
|
||||||
let [likes, changeLikes] = useState(Object.keys(post.reactions).length);
|
let [likes, changeLikes] = useState(Object.keys(post.reactions).length);
|
||||||
let [bookmarked, changeBookmarked] = useState(post.bookmarks && post.bookmarks.includes(viewer._id));
|
let [bookmarked, changeBookmarked] = useState(post.bookmarks && post.bookmarks.includes(viewer._id));
|
||||||
|
|||||||
Reference in New Issue
Block a user