From 62307fd76528736215551c59ab41cfa4c72c372d Mon Sep 17 00:00:00 2001 From: Aditya Pawar <34043950+adityapawar1@users.noreply.github.com> Date: Thu, 11 Apr 2024 22:15:21 -0700 Subject: [PATCH 01/11] [bug] Add other ethnicities (#83) * Add other ethnicities * Remove old settings --- src/app/(tabs)/settings/index.tsx | 3 +++ src/app/auth/onboarding/index.tsx | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/app/(tabs)/settings/index.tsx b/src/app/(tabs)/settings/index.tsx index 10bf4af..0434bc6 100644 --- a/src/app/(tabs)/settings/index.tsx +++ b/src/app/(tabs)/settings/index.tsx @@ -259,9 +259,12 @@ function SettingsScreen() { options={[ 'American Indian/Alaska Native', 'Asian', + 'Hispanic/Latinx', + 'Middle Eastern', 'Black or African American', 'Native Hawaiian or other Pacific Islander', 'White', + 'Not Listed Here', 'Prefer Not to Disclose', ]} label="Race/Ethnicity" diff --git a/src/app/auth/onboarding/index.tsx b/src/app/auth/onboarding/index.tsx index 936624f..ea0af6e 100644 --- a/src/app/auth/onboarding/index.tsx +++ b/src/app/auth/onboarding/index.tsx @@ -219,9 +219,12 @@ function OnboardingScreen() { options={[ 'American Indian/Alaska Native', 'Asian', + 'Hispanic/Latinx', + 'Middle Eastern', 'Black or African American', 'Native Hawaiian or other Pacific Islander', 'White', + 'Not Listed Here', 'Prefer Not to Disclose', ]} label="Race/Ethnicity" From 860d346d2a8fd29c88f365ea86fda2209ae0fd22 Mon Sep 17 00:00:00 2001 From: Marcoss28 <69034384+Marcoss28@users.noreply.github.com> Date: Thu, 11 Apr 2024 22:19:51 -0700 Subject: [PATCH 02/11] [update] Update preview card (#82) * accidently forgot to branch * [updated preview card]\n[updated preview and content card emojis/reactions] * chanegs made * Increase margin by 2 --------- Co-authored-by: Marcos Hernandez Co-authored-by: Aditya Pawar --- package-lock.json | 39 ++++++++++++++++ package.json | 3 ++ src/components/ContentCard/ContentCard.tsx | 42 ++++++++---------- src/components/ContentCard/styles.ts | 22 ++++++--- src/components/PreviewCard/PreviewCard.tsx | 37 ++++++++++++--- .../PreviewCard/savedStoriesIcon.png | Bin 0 -> 1052 bytes src/components/PreviewCard/styles.ts | 30 +++++++++++-- 7 files changed, 133 insertions(+), 40 deletions(-) create mode 100644 src/components/PreviewCard/savedStoriesIcon.png diff --git a/package-lock.json b/package-lock.json index ca07deb..f83fb7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,10 +38,13 @@ "expo-status-bar": "~1.6.0", "html-entities": "^2.4.0", "react": "18.2.0", + "react-apple-emojis": "^2.2.1", "react-native": "0.72.10", "react-native-dom-parser": "^1.5.3", "react-native-element-dropdown": "^2.10.0", "react-native-elements": "^3.4.3", + "react-native-emoji": "^1.8.0", + "react-native-emojicon": "^1.0.0", "react-native-gesture-handler": "~2.12.0", "react-native-htmlview": "^0.16.0", "react-native-ionicons": "^4.6.5", @@ -14217,6 +14220,11 @@ "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz", "integrity": "sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==" }, + "node_modules/lodash.toarray": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.toarray/-/lodash.toarray-4.4.0.tgz", + "integrity": "sha512-QyffEA3i5dma5q2490+SgCvDN0pXLmRGSyAANuVi0HQ01Pkfr9fuoKQW8wm1wGBnJITs/mS7wQvS6VshUEBFCw==" + }, "node_modules/log-symbols": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", @@ -15502,6 +15510,14 @@ "node": ">=10.5.0" } }, + "node_modules/node-emoji": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.10.0.tgz", + "integrity": "sha512-Yt3384If5H6BYGVHiHwTL+99OzJKHhgp82S8/dktEK73T26BazdgZ4JZh92xSVtGNJvz9UbXdNAc5hcrXV42vw==", + "dependencies": { + "lodash.toarray": "^4.4.0" + } + }, "node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", @@ -16664,6 +16680,16 @@ "node": ">=0.10.0" } }, + "node_modules/react-apple-emojis": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/react-apple-emojis/-/react-apple-emojis-2.2.1.tgz", + "integrity": "sha512-tgq/+GUR6WsBkkkl0EYgVbaU803IF8GoELcG83cfircrEiyiiIbHqpBXIHyD8YIOecAGgN2ucEG6U/REDR7jvQ==", + "peerDependencies": { + "prop-types": "*", + "react": ">=16.x", + "react-dom": ">=16.x" + } + }, "node_modules/react-devtools-core": { "version": "4.28.0", "resolved": "https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-4.28.0.tgz", @@ -16853,6 +16879,19 @@ "react-native-vector-icons": ">7.0.0" } }, + "node_modules/react-native-emoji": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/react-native-emoji/-/react-native-emoji-1.8.0.tgz", + "integrity": "sha512-VunKOtYes6eymyWwE7QS3mhmNXksTt2AN92PcGRtmDKLDPjuKrwd5tcJckFUekAK3H+6AMpwYy30CsiCJrDdFQ==", + "dependencies": { + "node-emoji": "1.10.0" + } + }, + "node_modules/react-native-emojicon": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/react-native-emojicon/-/react-native-emojicon-1.0.0.tgz", + "integrity": "sha512-rK6/7EIf/yNgkB24ujpV8zmmZylbQV+oq4F7YopZ9aSfNKmVKKFmqGOPahPo6OW8b1Dg5dm8caybgfpM2GP4Nw==" + }, "node_modules/react-native-gesture-handler": { "version": "2.12.1", "resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.12.1.tgz", diff --git a/package.json b/package.json index 7ba5f15..ed0b39d 100644 --- a/package.json +++ b/package.json @@ -42,10 +42,13 @@ "expo-status-bar": "~1.6.0", "html-entities": "^2.4.0", "react": "18.2.0", + "react-apple-emojis": "^2.2.1", "react-native": "0.72.10", "react-native-dom-parser": "^1.5.3", "react-native-element-dropdown": "^2.10.0", "react-native-elements": "^3.4.3", + "react-native-emoji": "^1.8.0", + "react-native-emojicon": "^1.0.0", "react-native-gesture-handler": "~2.12.0", "react-native-htmlview": "^0.16.0", "react-native-ionicons": "^4.6.5", diff --git a/src/components/ContentCard/ContentCard.tsx b/src/components/ContentCard/ContentCard.tsx index 4301cb9..dd62a58 100644 --- a/src/components/ContentCard/ContentCard.tsx +++ b/src/components/ContentCard/ContentCard.tsx @@ -9,6 +9,7 @@ import { import styles from './styles'; import globalStyles from '../../styles/globalStyles'; +import Emoji from 'react-native-emoji'; type ContentCardProps = { title: string; @@ -58,33 +59,26 @@ function ContentCard({ - - null} - style={{ flexDirection: 'row' }} - > - - - - - - 14{/*change number to work*/} - - - + + + + + + + + + + + {/* heart, clap, muscle, cry, ??? */} + + + 14{/*change number to work*/} + + saveStory()}> diff --git a/src/components/ContentCard/styles.ts b/src/components/ContentCard/styles.ts index d445870..f18d483 100644 --- a/src/components/ContentCard/styles.ts +++ b/src/components/ContentCard/styles.ts @@ -50,18 +50,26 @@ const styles = StyleSheet.create({ color: colors.grey, }, reactionNumber: { - marginLeft: 15, - marginTop: 10, + marginLeft: 14, + marginTop: 16, }, reactions: { - width: 20, - height: 20, - borderRadius: 20 / 2, + width: 30, + height: 30, + borderRadius: 30 / 2, borderWidth: 1, - backgroundColor: '#89CFF0', //different per emoji reaction + backgroundColor: 'transparent', //different per emoji reaction borderColor: 'white', marginTop: 10, - marginRight: -10, + marginRight: -5, // -10 + overflow: 'hidden', + justifyContent: 'center', + paddingLeft: 3, + }, + saveStoryImage: { + width: 30, + height: 30, + marginTop: 10, }, buttons: { flexDirection: 'row', diff --git a/src/components/PreviewCard/PreviewCard.tsx b/src/components/PreviewCard/PreviewCard.tsx index 8272b57..dfe7322 100644 --- a/src/components/PreviewCard/PreviewCard.tsx +++ b/src/components/PreviewCard/PreviewCard.tsx @@ -4,8 +4,10 @@ import { Image, Pressable, Text, + TouchableOpacity, View, } from 'react-native'; +import Emoji from 'react-native-emoji'; import styles from './styles'; import globalStyles from '../../styles/globalStyles'; @@ -32,6 +34,10 @@ function PreviewCard({ tags, pressFunction, }: PreviewCardProps) { + const saveStory = () => { + console.log("testing '+' icon does something for story " + title); + }; + return ( @@ -39,11 +45,17 @@ function PreviewCard({ {title} + saveStory()}> + + @@ -64,6 +76,23 @@ function PreviewCard({ + + + + + + + + + + + {/* heart, clap, muscle, cry, ??? */} + + + 14{/*change number to work*/} + + + {(tags?.length ?? 0) > 0 && ( @@ -72,12 +101,10 @@ function PreviewCard({ )} - - - + {' '} - + {(tags?.length ?? 1) - 1} more tags + + {(tags?.length ?? 1) - 1} diff --git a/src/components/PreviewCard/savedStoriesIcon.png b/src/components/PreviewCard/savedStoriesIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..65b2ea6e4dd47e1c590ef1cbe5d7afc29d8fcca7 GIT binary patch literal 1052 zcmV+%1mpXOP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91JfH&r1ONa40RR91JOBUy0E^%0TmS$AhDk(0RA>e5n@@7uFciimr$e`7 zhCjm&P7v1VhMpkVWYbNP6Eryi^aM>$(8;zeN=^{ENH^V(6Qo@wfn;E^B&pr+b1h;E2p>P%^ zpbQq?-QDePZEbx)!+h{wlCB94d0Rp7Dd53i@ClWUJ+Q82S)K8Cd|s(k*x2~g@AvBv zl1CH3Rpd;qVzKz~->L8O;o+ePUuKrbW`fVi zqM-RzouJ&`-(P#ciMQ+o$~yrUE$teUld(|NMSdNuoR(_(yQfn;M+^dj^sVI7We(n$i%k7S&sd<5^duoYdS(=jKw9*6>g(U-yqNOC) z$t;{?>qU`$<1GA2r@nU*mXIMN=))V14f=4r*LT@(7=xLG;_HeuMsDMM!AIJIj+ z-`aK91W&7fuzLz$U`I&ND}KE^SwwMKU=uto54IuPy_rRDh0p@0&C}8Xm)bw*$iH1o zujaJQW@&S55sxI9h2znyIlX2UHpdq6NTS^USeB<1wpTUrpfqe!iaLA_ZvBkld~lhZ zpF%t`^;e5_9bT5F6}DG3@u235?{~1Uza|=*>cZb3SXT?YEKe(JugVe5m2@KfhX)Ho z@W>Wszd=xStsT;;;yUxe!J7-$vX1B$+n4|4^{FA9&C=_%S$Gv%UgtA13$IiA zt9W*1;ZQ8bmrI=+zT z9%pIy_a(shlL!-0X8zg|h$sEc;L`8BK;WetRm=0VB}580$ppr4fxLNn~&jVDeU zEM9H+KsFT*Zf$RGk1(8%JPkB`<2~{0FeYC?Y7t~69vrU$oKh3CHY3NAPD{&z$sM_P z-@%0@)71V7V0ptG@80a)V&HhGRB|UaHZVDHrOD-TdyttEaD%eK!k;1k#DG)4tbieX zh|K@q4~vtSMgTu5m&+Z$@H4>bCc$B4&fHZTbyaS1&QS@A_V9h}K0ZF4)oQg-P~N|w WSfpXwp?D_%0000 Date: Wed, 17 Apr 2024 18:07:03 -0700 Subject: [PATCH 03/11] [saved] Implement saved story button (#79) * Implemented save story button * Move story image to assets * Add save story to preview card, one home screen viewing bug * Add pubsub to sync preview and content cards * Bug fixes * Refactor * Create SavedStoryButton componenet * Remove unused imports * Fix type errors --------- Co-authored-by: Aditya Pawar <34043950+adityapawar1@users.noreply.github.com> Co-authored-by: Aditya Pawar --- .../save_story.png | Bin assets/saved_story.png | Bin 0 -> 12911 bytes package-lock.json | 9 +++ package.json | 3 +- src/app/(tabs)/author/index.tsx | 1 + src/app/(tabs)/genre/index.tsx | 1 + src/app/(tabs)/home/index.tsx | 3 + src/app/(tabs)/search/index.tsx | 4 +- src/app/_layout.tsx | 13 ++-- src/components/AuthorCard/AuthorCard.tsx | 4 +- src/components/ContentCard/ContentCard.tsx | 16 ++--- src/components/PreviewCard/PreviewCard.tsx | 16 ++--- .../PreviewCard/savedStoriesIcon.png | Bin 1052 -> 0 bytes src/components/PreviewCard/styles.ts | 2 + .../SaveStoryButton/SaveStoryButton.tsx | 64 ++++++++++++++++++ src/queries/reactions.tsx | 2 +- src/queries/savedStories.tsx | 54 ++++++++++++--- src/utils/PubSubContext.tsx | 57 ++++++++++++++++ 18 files changed, 209 insertions(+), 40 deletions(-) rename src/components/ContentCard/savedStoriesIcon.png => assets/save_story.png (100%) create mode 100644 assets/saved_story.png delete mode 100644 src/components/PreviewCard/savedStoriesIcon.png create mode 100644 src/components/SaveStoryButton/SaveStoryButton.tsx create mode 100644 src/utils/PubSubContext.tsx diff --git a/src/components/ContentCard/savedStoriesIcon.png b/assets/save_story.png similarity index 100% rename from src/components/ContentCard/savedStoriesIcon.png rename to assets/save_story.png diff --git a/assets/saved_story.png b/assets/saved_story.png new file mode 100644 index 0000000000000000000000000000000000000000..46c3e7b053fe8b9c8b2a5a15994de304b40a3767 GIT binary patch literal 12911 zcmeHuc{tSV+c(opjZqPU$vQ<6$#f@MmWhl~mML3=k(P-pWsQm%)ZG}{-EL5M}G(m zG(mT@JH+>VIR4Znc`1SMqsgbeN)=4c|xLCJoX0j?MOq< z)JT2Gp1OqU;9TAF!w+H>lbWL_C-Lt2t~k};T91+Ud36exmo(-_)CIg|`VbnM@!|O0 zusHpt!R3;BSF#>c_o|ZfXAulKYqV{R{nx2dCxy$Luw}4*xB#UFF6s7V)K5cB=V2S^ zpK`@lj@2a1<2a8(WJ$wH@M@KSq&=|^-*!T0Q!YHwogSI@u3Y{;*X6*%2Ea<%r0A>H z6ADmSE9Sb~VT;J^skV9xFXkJz2P}X8Ha~ruj$jBQRDh-BH+?>PI<*dTNf+on~ zsf(TwO;3WV^YyApN*MJXnIvy|ZN+PSO@o((#eNWbOl#QuswP?-vfatOIgBGY;;ZIW z`_d!oXvyBG%fC{C;@8b~jqAgaqF7umUgjUW9uIN)v7MbiX~fWg(XU38A17Qm$6MA- z3_(Niq_vcjrJZm^R*oM|?C)1UXZUy65PWbY zjC1>F-6D;+8;4JYPj*8qfiq5ijFVmNI9Qjk z%PL?0WC@Er-)p7tW}89lS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@ARX&0WA8rnd##d%06 z%Leppj)hV|g0LT=4pKD7s4*&dn#R?6-Q-zsG~Qe#R|``jyyv?Drx!w-=)1qW#ZZXD zCcsk2p`oFrag(`I(gzGqhi?1eRbr#gZ!6S8#5xD(K@G=4wd)d$Zb@{}MCqNcA{j%K z{dg`r);IAVty^|ffp$b$+mhGnyo8dH&{+`Ei_;?+_Y8)xyn#{7`x#_AaO&LSg-&p; zBkS0tTd5>EgG2w);zQ{FU5ReOi)xL5hny%vYWU?`%l3OrJ{cp~vAN)x2!Z`}`@S_;3+4Fq3{$@rwIi=%Q zORk-}BSzO?%za=|3dmZ*b!TT9=2FSu z98Cx^nceX6)tgyl0*n0EM(~U`=jbCBu)zl_QZrr&Q-{N--|D{1aa{Ub3}VjuDeYG@ zNO9?UlsPs1*p-Q_;Wu})?F`+omy;VX`SH0Dr>4#$?zOmz^LoJdQ7S29wrk6j>cLqV zwJ@6n=Q9s-CeJx*U+FsQ>@UadhungYzc5!j3_9%9y)wqD!&8KHsV~bMNt{<6J|!ha1xm9WwmiTc2OZisON_R<{#@Y%E^i#S zv++}x?Fztkp1<={h{i>M2ELF8fvtxY!3}De_w6%ekjxB@qv_ShjA(TU#l6* zHQt3P%LApH^PITq<)P)4%6_hwP%X83cjzwj=$s7+Od&C)B{uTUb zBbcDbouE%~w@UVkH3*!;QddK0cQhU#QMT0-0fj=Y>IAChI JufUi@{VzM@4g>%I literal 0 HcmV?d00001 diff --git a/package-lock.json b/package-lock.json index f83fb7d..6829847 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,7 @@ "expo": "~49.0.11", "expo-constants": "~14.4.2", "expo-font": "~11.4.0", + "expo-image": "~1.3.5", "expo-linking": "~5.0.2", "expo-router": "^2.0.0", "expo-status-bar": "~1.6.0", @@ -11174,6 +11175,14 @@ "react-native": "*" } }, + "node_modules/expo-image": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/expo-image/-/expo-image-1.3.5.tgz", + "integrity": "sha512-yrIR2mnfIKbKcguoqWK3U5m3zvLPnonvSCabB2ErVGhws8zQs7ILYf+7T08j8U6eFcohjw0CoAFJ6RWNsX2EhA==", + "peerDependencies": { + "expo": "*" + } + }, "node_modules/expo-keep-awake": { "version": "12.3.0", "resolved": "https://registry.npmjs.org/expo-keep-awake/-/expo-keep-awake-12.3.0.tgz", diff --git a/package.json b/package.json index ed0b39d..d15d3b5 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,8 @@ "react-native-vector-icons": "^10.0.2", "react-scroll-to-top": "^3.0.0", "use-debounce": "^10.0.0", - "validator": "^13.11.0" + "validator": "^13.11.0", + "expo-image": "~1.3.5" }, "devDependencies": { "@babel/core": "^7.20.0", diff --git a/src/app/(tabs)/author/index.tsx b/src/app/(tabs)/author/index.tsx index 38b8b88..7767637 100644 --- a/src/app/(tabs)/author/index.tsx +++ b/src/app/(tabs)/author/index.tsx @@ -122,6 +122,7 @@ function AuthorScreen() { {authorStoryPreview?.map(story => ( ( ( router.push({ pathname: '/story', @@ -161,6 +163,7 @@ function HomeScreen() { title={story.title} author={story.author_name} authorImage={story.author_image} + storyId={story.id} pressFunction={() => router.push({ pathname: '/story', diff --git a/src/app/(tabs)/search/index.tsx b/src/app/(tabs)/search/index.tsx index a511472..fdc5612 100644 --- a/src/app/(tabs)/search/index.tsx +++ b/src/app/(tabs)/search/index.tsx @@ -306,6 +306,7 @@ function SearchScreen() { {recentlyViewed.map(item => ( ( - - - - - + + + + + + + diff --git a/src/components/AuthorCard/AuthorCard.tsx b/src/components/AuthorCard/AuthorCard.tsx index afdd2b5..99694ab 100644 --- a/src/components/AuthorCard/AuthorCard.tsx +++ b/src/components/AuthorCard/AuthorCard.tsx @@ -1,7 +1,5 @@ -import { Image, Pressable, Text, View } from 'react-native'; - +import { Image, Text, View } from 'react-native'; import styles from './styles'; -import globalStyles from '../../styles/globalStyles'; type AuthorCardProps = { name: string; diff --git a/src/components/ContentCard/ContentCard.tsx b/src/components/ContentCard/ContentCard.tsx index dd62a58..c766751 100644 --- a/src/components/ContentCard/ContentCard.tsx +++ b/src/components/ContentCard/ContentCard.tsx @@ -1,21 +1,23 @@ import { GestureResponderEvent, - Image, Pressable, Text, View, TouchableOpacity, } from 'react-native'; +import { Image } from 'expo-image'; import styles from './styles'; import globalStyles from '../../styles/globalStyles'; import Emoji from 'react-native-emoji'; +import SaveStoryButton from '../SaveStoryButton/SaveStoryButton'; type ContentCardProps = { title: string; author: string; image: string; authorImage: string; + storyId: number; pressFunction: (event: GestureResponderEvent) => void; }; @@ -24,12 +26,9 @@ function ContentCard({ author, image, authorImage, + storyId, pressFunction, }: ContentCardProps) { - const saveStory = () => { - console.log("testing '+' icon does something for story " + title); - }; - return ( @@ -76,11 +75,8 @@ function ContentCard({ - saveStory()}> - + + diff --git a/src/components/PreviewCard/PreviewCard.tsx b/src/components/PreviewCard/PreviewCard.tsx index dfe7322..71d6d05 100644 --- a/src/components/PreviewCard/PreviewCard.tsx +++ b/src/components/PreviewCard/PreviewCard.tsx @@ -1,16 +1,17 @@ import * as cheerio from 'cheerio'; import { GestureResponderEvent, - Image, Pressable, Text, TouchableOpacity, View, } from 'react-native'; import Emoji from 'react-native-emoji'; +import { Image } from 'expo-image'; import styles from './styles'; import globalStyles from '../../styles/globalStyles'; +import SaveStoryButton from '../SaveStoryButton/SaveStoryButton'; const placeholderImage = 'https://gwn-uploads.s3.amazonaws.com/wp-content/uploads/2021/10/10120952/Girls-Write-Now-logo-avatar.png'; @@ -18,6 +19,7 @@ const placeholderImage = type PreviewCardProps = { title: string; image: string; + storyId: number; author: string; authorImage: string; excerpt: { html: string }; @@ -28,16 +30,13 @@ type PreviewCardProps = { function PreviewCard({ title, image, + storyId, author, authorImage, excerpt, tags, pressFunction, }: PreviewCardProps) { - const saveStory = () => { - console.log("testing '+' icon does something for story " + title); - }; - return ( @@ -45,11 +44,8 @@ function PreviewCard({ {title} - saveStory()}> - + + diff --git a/src/components/PreviewCard/savedStoriesIcon.png b/src/components/PreviewCard/savedStoriesIcon.png deleted file mode 100644 index 65b2ea6e4dd47e1c590ef1cbe5d7afc29d8fcca7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1052 zcmV+%1mpXOP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91JfH&r1ONa40RR91JOBUy0E^%0TmS$AhDk(0RA>e5n@@7uFciimr$e`7 zhCjm&P7v1VhMpkVWYbNP6Eryi^aM>$(8;zeN=^{ENH^V(6Qo@wfn;E^B&pr+b1h;E2p>P%^ zpbQq?-QDePZEbx)!+h{wlCB94d0Rp7Dd53i@ClWUJ+Q82S)K8Cd|s(k*x2~g@AvBv zl1CH3Rpd;qVzKz~->L8O;o+ePUuKrbW`fVi zqM-RzouJ&`-(P#ciMQ+o$~yrUE$teUld(|NMSdNuoR(_(yQfn;M+^dj^sVI7We(n$i%k7S&sd<5^duoYdS(=jKw9*6>g(U-yqNOC) z$t;{?>qU`$<1GA2r@nU*mXIMN=))V14f=4r*LT@(7=xLG;_HeuMsDMM!AIJIj+ z-`aK91W&7fuzLz$U`I&ND}KE^SwwMKU=uto54IuPy_rRDh0p@0&C}8Xm)bw*$iH1o zujaJQW@&S55sxI9h2znyIlX2UHpdq6NTS^USeB<1wpTUrpfqe!iaLA_ZvBkld~lhZ zpF%t`^;e5_9bT5F6}DG3@u235?{~1Uza|=*>cZb3SXT?YEKe(JugVe5m2@KfhX)Ho z@W>Wszd=xStsT;;;yUxe!J7-$vX1B$+n4|4^{FA9&C=_%S$Gv%UgtA13$IiA zt9W*1;ZQ8bmrI=+zT z9%pIy_a(shlL!-0X8zg|h$sEc;L`8BK;WetRm=0VB}580$ppr4fxLNn~&jVDeU zEM9H+KsFT*Zf$RGk1(8%JPkB`<2~{0FeYC?Y7t~69vrU$oKh3CHY3NAPD{&z$sM_P z-@%0@)71V7V0ptG@80a)V&HhGRB|UaHZVDHrOD-TdyttEaD%eK!k;1k#DG)4tbieX zh|K@q4~vtSMgTu5m&+Z$@H4>bCc$B4&fHZTbyaS1&QS@A_V9h}K0ZF4)oQg-P~N|w WSfpXwp?D_%0000 { + isStoryInReadingList(storyId, user?.id).then(storyInReadingList => { + setStoryIsSaved(storyInReadingList); + initializeChannel(storyId); + }); + }, [storyId]); + + useEffect(() => { + // if another card updates this story, update it here also + if (typeof channels[storyId] !== 'undefined') { + setStoryIsSaved(channels[storyId] ?? false); + } + }, [channels[storyId]]); + + useEffect(() => { + isStoryInReadingList(storyId, user?.id).then(storyInReadingList => + setStoryIsSaved(storyInReadingList), + ); + }, [storyId]); + + const saveStory = async (saved: boolean) => { + setStoryIsSaved(saved); + publish(storyId, saved); // update other cards with this story + + if (saved) { + await addUserStoryToReadingList(user?.id, storyId); + } else { + await deleteUserStoryToReadingList(user?.id, storyId); + } + }; + + return ( + saveStory(!storyIsSaved)}> + {storyIsSaved ? ( + + ) : ( + + )} + + ); +} diff --git a/src/queries/reactions.tsx b/src/queries/reactions.tsx index 8a9da88..ffe68c4 100644 --- a/src/queries/reactions.tsx +++ b/src/queries/reactions.tsx @@ -53,7 +53,7 @@ export async function fetchAllReactionsToStory( `An error occured when trying to fetch reactions to a story', ${error}`, ); } else { - return data; + return data as Reactions[]; } } diff --git a/src/queries/savedStories.tsx b/src/queries/savedStories.tsx index 59f6eca..0416ecb 100644 --- a/src/queries/savedStories.tsx +++ b/src/queries/savedStories.tsx @@ -1,7 +1,9 @@ import supabase from '../utils/supabase'; -const favorites = 'favorites'; -const readingList = 'reading list'; +enum SavedList { + FAVORITES = 'favorites', + READING_LIST = 'reading list', +} async function fetchUserStories( user_id: string | undefined, @@ -48,11 +50,11 @@ async function fetchUserStories( } export async function fetchUserStoriesFavorites(user_id: string | undefined) { - return await fetchUserStories(user_id, favorites); + return await fetchUserStories(user_id, SavedList.FAVORITES); } export async function fetchUserStoriesReadingList(user_id: string | undefined) { - return await fetchUserStories(user_id, readingList); + return await fetchUserStories(user_id, SavedList.READING_LIST); } async function addUserStory( @@ -62,13 +64,15 @@ async function addUserStory( ) { const { error } = await supabase .from('saved_stories') - .insert([{ user_id: user_id, story_id: story_id, name: name }]) + .upsert([{ user_id: user_id, story_id: story_id, name: name }]) .select(); if (error) { if (process.env.NODE_ENV !== 'production') { throw new Error( - `An error occured when trying to set user saved stories: ${error.details}`, + `An error occured when trying to set user saved stories: ${JSON.stringify( + error, + )}`, ); } } @@ -78,17 +82,31 @@ export async function addUserStoryToFavorites( user_id: string | undefined, story_id: number, ) { - addUserStory(user_id, story_id, favorites); + addUserStory(user_id, story_id, SavedList.FAVORITES); } export async function addUserStoryToReadingList( user_id: string | undefined, story_id: number, ) { - addUserStory(user_id, story_id, readingList); + addUserStory(user_id, story_id, SavedList.READING_LIST); +} + +export async function deleteUserStoryToFavorites( + user_id: string | undefined, + story_id: number, +) { + deleteUserStory(user_id, story_id, SavedList.FAVORITES); } -export async function deleteUserStories( +export async function deleteUserStoryToReadingList( + user_id: string | undefined, + story_id: number, +) { + deleteUserStory(user_id, story_id, SavedList.READING_LIST); +} + +export async function deleteUserStory( user_id: string | undefined, story_id: number, name: string, @@ -108,3 +126,21 @@ export async function deleteUserStories( } } } + +export async function isStoryInReadingList( + storyId: number, + userId: string | undefined, +): Promise { + let { data, error } = await supabase.rpc('is_story_saved_for_user', { + list_name: 'reading list', + story_db_id: storyId, + user_uuid: userId, + }); + + if (error) { + console.error(error); + return false; + } + + return data; +} diff --git a/src/utils/PubSubContext.tsx b/src/utils/PubSubContext.tsx new file mode 100644 index 0000000..fbb9ada --- /dev/null +++ b/src/utils/PubSubContext.tsx @@ -0,0 +1,57 @@ +import React, { createContext, useContext, useMemo, useState } from 'react'; + +export interface PubSubState { + channels: Record; + initializeChannel: (id: number) => void; + publish: (id: number, message: boolean) => void; +} + +const BooleanPubSubContext = createContext({} as PubSubState); + +export function usePubSub() { + const value = useContext(BooleanPubSubContext); + if (process.env.NODE_ENV !== 'production') { + if (!value) { + throw new Error( + 'usePubSub must be wrapped in a ', + ); + } + } + + return value; +} + +export function BooleanPubSubProvider({ + children, +}: { + children: React.ReactNode; +}) { + const [channels, setChannels] = useState>( + {}, + ); + + const initializeChannel = (id: number) => { + if (!(id in channels)) { + setChannels({ ...channels, [id]: undefined }); + } + }; + + const publish = (id: number, message: boolean) => { + setChannels({ ...channels, [id]: message }); + }; + + const authContextValue = useMemo( + () => ({ + channels, + initializeChannel, + publish, + }), + [channels], + ); + + return ( + + {children} + + ); +} From 9cc1b1a05e002f992873c7949ffd2519f651baa0 Mon Sep 17 00:00:00 2001 From: Aditya Pawar <34043950+adityapawar1@users.noreply.github.com> Date: Thu, 18 Apr 2024 21:34:15 -0700 Subject: [PATCH 04/11] [bug] Bug bash changes (#86) * Bug bash changes * Change link back to login --- src/app/(tabs)/story/index.tsx | 39 ++++++++++++++++++++++-------- src/app/auth/onboarding/index.tsx | 13 ++++++++++ src/app/auth/onboarding/styles.tsx | 4 +++ src/app/auth/signup/index.tsx | 4 +-- 4 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/app/(tabs)/story/index.tsx b/src/app/(tabs)/story/index.tsx index 2387f2f..2995426 100644 --- a/src/app/(tabs)/story/index.tsx +++ b/src/app/(tabs)/story/index.tsx @@ -89,7 +89,12 @@ function StoryScreen() { style={styles.authorImage} source={{ uri: story.author_image ? story.author_image : '' }} /> - + By {story.author_name} @@ -161,15 +166,29 @@ function StoryScreen() { systemFonts={fonts} /> - - - - By {story.author_name} - - + { + router.push({ + pathname: '/author', + params: { author: story.author_id.toString() }, + }); + }} + > + + + + By {story.author_name} + + +