Skip to content

Commit bb7bbd0

Browse files
authored
fix: articles load more button cache issues (#360)
1 parent 69d8939 commit bb7bbd0

11 files changed

Lines changed: 29 additions & 15 deletions

File tree

apps/events-helsinki/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"react-datepicker": "^4.8.0",
7272
"react-dom": "18.2.0",
7373
"react-error-boundary": "3.1.4",
74-
"react-helsinki-headless-cms": "1.0.0-alpha151",
74+
"react-helsinki-headless-cms": "1.0.0-alpha154",
7575
"react-i18next": "12.2.0",
7676
"react-scroll": "^1.8.7",
7777
"react-toastify": "^9.0.3",

apps/events-helsinki/src/pages/articles/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ export default function ArticleArchive({
6565
networkStatus,
6666
} = usePostsQuery({
6767
notifyOnNetworkStatusChange: true,
68+
// does not work without fetchPolicy: 'network-only',
69+
fetchPolicy: 'network-only',
70+
// not sure if nextFetchPolicy is needed
71+
nextFetchPolicy: 'cache-first',
6872
variables: {
6973
first: BLOCK_SIZE,
7074
search: debouncedSearchTerm ?? '',

apps/hobbies-helsinki/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"react-datepicker": "^4.8.0",
7272
"react-dom": "18.2.0",
7373
"react-error-boundary": "3.1.4",
74-
"react-helsinki-headless-cms": "1.0.0-alpha151",
74+
"react-helsinki-headless-cms": "1.0.0-alpha154",
7575
"react-i18next": "12.2.0",
7676
"react-scroll": "^1.8.7",
7777
"react-toastify": "^9.0.3",

apps/hobbies-helsinki/src/pages/articles/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ export default function ArticleArchive({
6565
networkStatus,
6666
} = usePostsQuery({
6767
notifyOnNetworkStatusChange: true,
68+
// does not work without fetchPolicy: 'network-only',
69+
fetchPolicy: 'network-only',
70+
// not sure if nextFetchPolicy is needed
71+
nextFetchPolicy: 'cache-first',
6872
variables: {
6973
first: BLOCK_SIZE,
7074
search: debouncedSearchTerm ?? '',

apps/sports-helsinki/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"react-datepicker": "^4.8.0",
8080
"react-dom": "18.2.0",
8181
"react-error-boundary": "3.1.4",
82-
"react-helsinki-headless-cms": "1.0.0-alpha151",
82+
"react-helsinki-headless-cms": "1.0.0-alpha154",
8383
"react-i18next": "12.2.0",
8484
"react-leaflet": "4.2.0",
8585
"react-scroll": "^1.8.7",

apps/sports-helsinki/src/pages/articles/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ export default function ArticleArchive({
6565
networkStatus,
6666
} = usePostsQuery({
6767
notifyOnNetworkStatusChange: true,
68+
// does not work without fetchPolicy: 'network-only',
69+
fetchPolicy: 'network-only',
70+
// not sure if nextFetchPolicy is needed
71+
nextFetchPolicy: 'cache-first',
6872
variables: {
6973
first: BLOCK_SIZE,
7074
search: debouncedSearchTerm ?? '',

packages/components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"react-datepicker": "^4.8.0",
7272
"react-dom": "18.2.0",
7373
"react-error-boundary": "3.1.4",
74-
"react-helsinki-headless-cms": "1.0.0-alpha151",
74+
"react-helsinki-headless-cms": "1.0.0-alpha154",
7575
"react-i18next": "12.2.0",
7676
"react-leaflet": "4.2.0",
7777
"react-toastify": "^9.0.3",

packages/components/src/apollo/EventsFederationApolloClient.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ class EventsFederationApolloClient {
203203
};
204204
}
205205
),
206+
// works in combination with fetchPolicy: 'network-only'
207+
posts: relayStylePagination(excludeArgs(['after'])),
206208
unifiedSearch: relayStylePagination(excludeArgs(['after'])),
207209
},
208210
},

packages/components/src/components/footer/Footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const FooterSection: FunctionComponent<FooterSectionProps> = ({
4949
>
5050
{footerMenu?.menuItems?.nodes?.map(
5151
// NOTE: HCRC-build sometimes fails - this type should not be needed.
52-
(navigationItem) => (
52+
(navigationItem: Menu['menuItems']['nodes'][number]) => (
5353
<Footer.Item
5454
className={styles.footerLink}
5555
key={navigationItem?.id}

packages/components/src/utils/headless-cms/service.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const getAllArticles = async (
4040
locale: node.language.code.toLowerCase(),
4141
slug: node.slug,
4242
});
43-
node.translations?.forEach((translation) => {
43+
node.translations?.forEach((translation: PageType['translations']) => {
4444
if (
4545
translation?.uri &&
4646
translation.slug &&
@@ -88,7 +88,7 @@ export const getAllPages = async (
8888
locale: node.language.code.toLowerCase(),
8989
slug: node.slug,
9090
});
91-
node.translations?.forEach((translation) => {
91+
node.translations?.forEach((translation: PageType['translations']) => {
9292
if (
9393
translation?.uri &&
9494
translation.slug &&

0 commit comments

Comments
 (0)