Skip to content

Commit 8fd5c75

Browse files
authored
Merge pull request #103 from medyo/develop
v 1.15.0
2 parents af60013 + b977077 commit 8fd5c75

10 files changed

Lines changed: 65 additions & 77 deletions

File tree

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
"dependencies": {
66
"@amplitude/analytics-browser": "^1.5.5",
77
"@craco/craco": "^6.4.5",
8-
"@sentry/react": "^7.17.4",
9-
"@sentry/tracing": "^7.17.4",
108
"@tanstack/react-query": "^4.13.0",
119
"@testing-library/jest-dom": "^5.11.4",
1210
"@testing-library/react": "^11.1.0",

src/config/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { CardPropsType } from 'src/types'
2727
// Keys
2828
export const ANALYTICS_ENDPOINT = process.env.REACT_APP_AMPLITUDE_URL as string
2929
export const ANALYTICS_SDK_KEY = process.env.REACT_APP_AMPLITUDE_KEY as string
30-
export const SENTRY_DSN = process.env.REACT_APP_SENTRY_DSN as string
3130
export const LS_ANALYTICS_ID_KEY = 'hackerTabAnalyticsId'
3231
// Meta
3332
export const name = 'Hackertab.dev'
@@ -180,6 +179,7 @@ export const GLOBAL_TAG = {
180179
devtoValues: ['programming'],
181180
hashnodeValues: ['programming'],
182181
mediumValues: ['programming'],
182+
redditValues: ['programming'],
183183
freecodecampValues: ['programming'],
184184
}
185185
export const MY_LANGUAGES_TAG = {
@@ -189,6 +189,7 @@ export const MY_LANGUAGES_TAG = {
189189
devtoValues: ['myLangs'],
190190
hashnodeValues: ['myLangs'],
191191
mediumValues: ['myLangs'],
192+
redditValues: ['myLangs'],
192193
freecodecampValues: ['myLangs'],
193194
}
194195
export const MAX_ITEMS_PER_CARD = 50

src/features/cards/api/getMediumArticles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Article } from 'src/types'
44
import { axios } from 'src/lib/axios'
55

66
const getArticles = async (tag: string): Promise<Article[]> => {
7-
return axios.get(`/data/v2/devto/${tag}.json`)
7+
return axios.get(`/data/v2/medium/${tag}.json`)
88
}
99

1010
type QueryFnType = typeof getArticles

src/features/cards/components/devtoCard/DevtoCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function DevtoCard({ withAds, meta }: CardPropsType) {
4444
if (!curr.data) return acc
4545
return [...acc, ...curr.data]
4646
}, [])
47-
.sort((a, b) => b.reactions - a.reactions)
47+
.sort((a, b) => b.published_at - a.published_at)
4848
}
4949

5050
const renderItem = (item: Article, index: number) => (

src/features/cards/components/freecodecampCard/FreecodecampCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function FreecodecampCard({ meta, withAds }: CardPropsType) {
4444
if (!curr.data) return acc
4545
return [...acc, ...curr.data]
4646
}, [])
47-
.sort((a, b) => b.reactions - a.reactions)
47+
.sort((a, b) => b.published_at - a.published_at)
4848
}
4949

5050
const renderItem = (item: Article, index: number) => (

src/features/cards/components/hashnodeCard/HashnodeCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function HashnodeCard({ withAds, meta }: CardPropsType) {
4444
if (!curr.data) return acc
4545
return [...acc, ...curr.data]
4646
}, [])
47-
.sort((a, b) => b.reactions - a.reactions)
47+
.sort((a, b) => b.published_at - a.published_at)
4848
}
4949

5050
const renderItem = (item: Article, index: number) => (

src/features/cards/components/mediumCard/MediumCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function MediumCard({ meta, withAds }: CardPropsType) {
4444
if (!curr.data) return acc
4545
return [...acc, ...curr.data]
4646
}, [])
47-
.sort((a, b) => b.reactions - a.reactions)
47+
.sort((a, b) => b.published_at - a.published_at)
4848
}
4949

5050
const renderItem = (item: Article, index: number) => (

src/features/cards/components/redditCard/RedditCard.tsx

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,37 @@ import { Article, CardPropsType } from 'src/types'
55
import { useUserPreferences } from 'src/stores/preferences'
66
import { getCardTagsValue } from 'src/utils/DataEnhancement'
77
import ArticleItem from './ArticleItem'
8+
import { useState, useEffect } from 'react'
9+
import { Tag } from 'src/features/remoteConfig'
10+
import { GLOBAL_TAG, MY_LANGUAGES_TAG } from 'src/config'
11+
import SelectableCard from 'src/components/SelectableCard'
12+
import { trackCardLanguageSelect } from 'src/lib/analytics'
13+
14+
const REDDIT_MENU_LANGUAGE_ID = 'REDDIT_MENU_LANGUAGE_ID'
815

916
export function RedditCard({ withAds, meta }: CardPropsType) {
10-
const { userSelectedTags } = useUserPreferences()
17+
const { userSelectedTags, cardsSettings, setCardSettings } = useUserPreferences()
18+
const [selectedTag, setSelectedTag] = useState<Tag>()
19+
20+
useEffect(() => {
21+
if (selectedTag) {
22+
setCardSettings(meta.value, { language: selectedTag.label })
23+
}
24+
}, [selectedTag, meta, setCardSettings])
25+
26+
const getQueryTags = () => {
27+
if (!selectedTag) {
28+
return []
29+
}
1130

12-
const tags = getCardTagsValue(userSelectedTags, 'redditValues')
31+
if (selectedTag.value === MY_LANGUAGES_TAG.redditValues[0]) {
32+
return getCardTagsValue(userSelectedTags, 'redditValues') || []
33+
}
34+
return selectedTag.redditValues || []
35+
}
1336

14-
const results = useGetRedditArticles({ tags })
37+
console.log('getQueryTags()', getQueryTags())
38+
const results = useGetRedditArticles({ tags: getQueryTags() })
1539

1640
const getIsLoading = () => results.some((result) => result.isLoading)
1741

@@ -25,11 +49,38 @@ export function RedditCard({ withAds, meta }: CardPropsType) {
2549
}
2650

2751
const renderItem = (item: Article, index: number) => (
28-
<ArticleItem item={item} key={`re-${index}`} index={index} analyticsTag={meta.analyticsTag} />
52+
<ArticleItem
53+
item={item}
54+
key={`md-${index}`}
55+
index={index}
56+
selectedTag={selectedTag}
57+
analyticsTag={meta.analyticsTag}
58+
/>
2959
)
3060

61+
const HeaderTitle = () => {
62+
return (
63+
<div style={{ display: 'inline-block', margin: 0, padding: 0 }}>
64+
<span> {meta.label} </span>
65+
<SelectableCard
66+
isLanguage={true}
67+
tagId={REDDIT_MENU_LANGUAGE_ID}
68+
selectedTag={selectedTag}
69+
setSelectedTag={setSelectedTag}
70+
fallbackTag={GLOBAL_TAG}
71+
cardSettings={cardsSettings?.reddit?.language}
72+
trackEvent={(tag: Tag) => trackCardLanguageSelect(meta.analyticsTag, tag.value)}
73+
data={userSelectedTags.map((tag) => ({
74+
label: tag.label,
75+
value: tag.value,
76+
}))}
77+
/>
78+
</div>
79+
)
80+
}
81+
3182
return (
32-
<Card card={meta}>
83+
<Card card={meta} titleComponent={<HeaderTitle />}>
3384
<ListComponent
3485
items={getData()}
3586
isLoading={getIsLoading()}

src/index.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ import {AppErrorBoundary} from 'src/providers/AppErrorBoundary'
88
import { ConfigurationWrapper } from 'src/features/remoteConfig/'
99
import { QueryClientProvider } from '@tanstack/react-query'
1010
import { queryClient } from 'src/lib/react-query'
11-
import * as Sentry from '@sentry/react'
12-
import { SENTRY_DSN } from './config'
13-
import { BrowserTracing } from '@sentry/tracing'
14-
15-
Sentry.init({
16-
dsn: SENTRY_DSN,
17-
integrations: [new BrowserTracing()],
18-
tracesSampleRate: 1.0,
19-
})
2011

2112
ReactDOM.render(
2213
<React.StrictMode>

yarn.lock

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,59 +1799,6 @@
17991799
resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.2.0.tgz#8be36a1f66f3265389e90b5f9c9962146758f728"
18001800
integrity sha512-sXo/qW2/pAcmT43VoRKOJbDOfV3cYpq3szSVfIThQXNt+E4DfKj361vaAt3c88U5tPUxzEswam7GW48PJqtKAg==
18011801

1802-
"@sentry/browser@7.17.4":
1803-
version "7.17.4"
1804-
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.17.4.tgz#2e4ad09180905929b823d01e2a029f10933c0a03"
1805-
integrity sha512-cNLQ/6ea0KOZyLKXGLTdgfqWYdg43+T/uF9D/hmc6kp/5qXm2dR3FcFRZX6OicaENM3dXvSoBIF6bSWmcszRtQ==
1806-
dependencies:
1807-
"@sentry/core" "7.17.4"
1808-
"@sentry/types" "7.17.4"
1809-
"@sentry/utils" "7.17.4"
1810-
tslib "^1.9.3"
1811-
1812-
"@sentry/core@7.17.4":
1813-
version "7.17.4"
1814-
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.17.4.tgz#62686e1b2baf4e7ba3d9ca57d91d2dfc643b8250"
1815-
integrity sha512-U3ABSJBKGK8dJ01nEG2+qNOb6Wv7U3VqoajiZxfV4lpPWNFGCoEhiTytxBlFTOCmdUH8209zSZiWJZaDLy+TSA==
1816-
dependencies:
1817-
"@sentry/types" "7.17.4"
1818-
"@sentry/utils" "7.17.4"
1819-
tslib "^1.9.3"
1820-
1821-
"@sentry/react@^7.17.4":
1822-
version "7.17.4"
1823-
resolved "https://registry.yarnpkg.com/@sentry/react/-/react-7.17.4.tgz#1d2c752841ace0561043be6a863de9fc7437f64c"
1824-
integrity sha512-Hw8lgeCgUthgVQ5OG24/iZWGNXnxodVfCmfngeIfqUWeFgQUae1V833GNkYZCiE5j2yjNVh3LL2bXA8PnvMCEg==
1825-
dependencies:
1826-
"@sentry/browser" "7.17.4"
1827-
"@sentry/types" "7.17.4"
1828-
"@sentry/utils" "7.17.4"
1829-
hoist-non-react-statics "^3.3.2"
1830-
tslib "^1.9.3"
1831-
1832-
"@sentry/tracing@^7.17.4":
1833-
version "7.17.4"
1834-
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.17.4.tgz#1254f4eb7397e1134248de1dade33d2fec864005"
1835-
integrity sha512-9Fz6DI16ddnd970mlB5MiCNRSmSXp4SVZ1Yv3L22oS3kQeNxjBTE+htYNwJzSPrQp9aL/LqTYwlnrCy24u9XQA==
1836-
dependencies:
1837-
"@sentry/core" "7.17.4"
1838-
"@sentry/types" "7.17.4"
1839-
"@sentry/utils" "7.17.4"
1840-
tslib "^1.9.3"
1841-
1842-
"@sentry/types@7.17.4":
1843-
version "7.17.4"
1844-
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.17.4.tgz#476522bc988989101e7aee9eee3c3f8f16fa59ea"
1845-
integrity sha512-QJj8vO4AtxuzQfJIzDnECSmoxwnS+WJsm1Ta2Cwdy+TUCBJyWpW7aIJJGta76zb9gNPGb3UcAbeEjhMJBJeRMQ==
1846-
1847-
"@sentry/utils@7.17.4":
1848-
version "7.17.4"
1849-
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.17.4.tgz#b8f4fb6a329765b97668b34f6d397e8de2169fef"
1850-
integrity sha512-ioG0ANy8uiWzig82/e7cc+6C9UOxkyBzJDi1luoQVDH6P0/PvM8GzVU+1iUVUipf8+OL1Jh09GrWnd5wLm3XNQ==
1851-
dependencies:
1852-
"@sentry/types" "7.17.4"
1853-
tslib "^1.9.3"
1854-
18551802
"@sinclair/typebox@^0.24.1":
18561803
version "0.24.46"
18571804
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.24.46.tgz#57501b58023776dbbae9e25619146286440be34c"
@@ -6461,7 +6408,7 @@ hoist-non-react-statics@^1.2.0:
64616408
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-1.2.0.tgz#aa448cf0986d55cc40773b17174b7dd066cb7cfb"
64626409
integrity sha512-r8huvKK+m+VraiRipdZYc+U4XW43j6OFG/oIafe7GfDbRpCduRoX9JI/DRxqgtBSCeL+et6N6ibZoedHS2NyOQ==
64636410

6464-
hoist-non-react-statics@^3.3.1, hoist-non-react-statics@^3.3.2:
6411+
hoist-non-react-statics@^3.3.1:
64656412
version "3.3.2"
64666413
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
64676414
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
@@ -12192,7 +12139,7 @@ tsconfig-paths@^3.14.1:
1219212139
minimist "^1.2.6"
1219312140
strip-bom "^3.0.0"
1219412141

12195-
tslib@^1.8.1, tslib@^1.9.3:
12142+
tslib@^1.8.1:
1219612143
version "1.14.1"
1219712144
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
1219812145
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==

0 commit comments

Comments
 (0)