From ca3ca9dcebd6b3f02176b701c09f280bdb0cbc17 Mon Sep 17 00:00:00 2001 From: Burhan YILMAZ Date: Mon, 6 May 2024 23:11:26 +0300 Subject: [PATCH] chore: cleaning and beautify code --- src/screens/Blog/PostDetailScreen.tsx | 1 + src/screens/Test/index.tsx | 12 ------------ src/store/PostStore.ts | 10 ++++++++-- 3 files changed, 9 insertions(+), 14 deletions(-) delete mode 100644 src/screens/Test/index.tsx diff --git a/src/screens/Blog/PostDetailScreen.tsx b/src/screens/Blog/PostDetailScreen.tsx index 49e9086..1c2cc03 100644 --- a/src/screens/Blog/PostDetailScreen.tsx +++ b/src/screens/Blog/PostDetailScreen.tsx @@ -46,6 +46,7 @@ const PostDetailScreen = () => { }); const onPressSave = () => post && savedStore.addPost(post); + const onPressShare = async () => { post && Share.share({ diff --git a/src/screens/Test/index.tsx b/src/screens/Test/index.tsx deleted file mode 100644 index 52cee60..0000000 --- a/src/screens/Test/index.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { text } from '@theme/text'; -import { SafeAreaView, Text, View } from 'react-native'; - -const TestScreen = () => ( - - - Test Screen - - -); - -export default TestScreen; diff --git a/src/store/PostStore.ts b/src/store/PostStore.ts index fcc93f1..035dc25 100644 --- a/src/store/PostStore.ts +++ b/src/store/PostStore.ts @@ -23,9 +23,11 @@ export const Post = t } const media = yield api.getMediaByUrl(self.mediaUrl); + const mediaSizes = media?.media_details; + const renderedMedia = media?.guid?.rendered; - self.image = media?.media_details?.sizes?.medium?.source_url || media?.guid?.rendered; - self.headerImage = media?.media_details?.sizes?.large?.source_url || media?.guid?.rendered; + self.image = mediaSizes?.medium?.source_url || renderedMedia; + self.headerImage = mediaSizes?.large?.source_url || renderedMedia; self.imageLoaded = true; }), @@ -56,9 +58,11 @@ const PostStore = t get listingPosts() { return Array.from(self.posts.values()).slice(4, self.posts.size); }, + getSelectedPost(id: string) { return self.posts.get(id); }, + get sliderPosts() { return Array.from(self.posts.values()).slice(0, 4); }, @@ -94,7 +98,9 @@ const PostStore = t if (!self.url) { return; } + this.setLoading(true); + try { const posts = await api.getPost(self.page);