Skip to content

Commit bdb9163

Browse files
committed
Remove serverTime prop and fetch from context instead
1 parent 0155889 commit bdb9163

67 files changed

Lines changed: 20 additions & 493 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dotcom-rendering/src/components/ArticleBody.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ type Props = {
5454
lang?: string;
5555
isRightToLeftLang?: boolean;
5656
shouldHideAds: boolean;
57-
serverTime?: number;
5857
idApiUrl?: string;
5958
};
6059

@@ -139,7 +138,6 @@ export const ArticleBody = ({
139138
isRightToLeftLang = false,
140139
editionId,
141140
shouldHideAds,
142-
serverTime,
143141
idApiUrl,
144142
}: Props) => {
145143
const isInteractiveContent =
@@ -209,7 +207,6 @@ export const ArticleBody = ({
209207
keywordIds={keywordIds}
210208
editionId={editionId}
211209
shouldHideAds={shouldHideAds}
212-
serverTime={serverTime}
213210
idApiUrl={idApiUrl}
214211
/>
215212
</div>

dotcom-rendering/src/components/Card/Card.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ export type Props = {
8282
format: ArticleFormat;
8383
/** The format of the article holding the card */
8484
contextFormat?: ArticleFormat;
85-
serverTime?: number;
8685
headlineText: string;
8786
headlineSizes?: ResponsiveFontSize;
8887
showQuotedHeadline?: boolean;
@@ -410,7 +409,6 @@ export const Card = ({
410409
liveUpdatesPosition = 'inner',
411410
onwardsSource,
412411
showVideo = true,
413-
serverTime,
414412
isTagPage = false,
415413
aspectRatio,
416414
index = 0,
@@ -468,7 +466,6 @@ export const Card = ({
468466
isWithinTwelveHours: withinTwelveHours,
469467
}}
470468
showClock={showClock}
471-
serverTime={serverTime}
472469
isTagPage={isTagPage}
473470
/>
474471
);
@@ -1313,7 +1310,6 @@ export const Card = ({
13131310
: supportingContentAlignment
13141311
}
13151312
containerPalette={containerPalette}
1316-
serverTime={serverTime}
13171313
displayHeader={isFlexibleContainer}
13181314
directionOnMobile={
13191315
isFlexibleContainer
@@ -1371,7 +1367,6 @@ export const Card = ({
13711367
: supportingContentAlignment
13721368
}
13731369
containerPalette={containerPalette}
1374-
serverTime={serverTime}
13751370
displayHeader={isFlexibleContainer}
13761371
directionOnMobile={'horizontal'}
13771372
></LatestLinks>

dotcom-rendering/src/components/Card/components/CardAge.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const ageStyles = (colour: string) => {
2222
};
2323

2424
type Props = {
25-
serverTime?: number;
2625
webPublication: {
2726
date: string;
2827
isWithinTwelveHours: boolean;
@@ -33,7 +32,6 @@ type Props = {
3332
};
3433

3534
export const CardAge = ({
36-
serverTime,
3735
webPublication,
3836
isTagPage,
3937
showClock,
@@ -58,7 +56,6 @@ export const CardAge = ({
5856
<DateTime
5957
date={new Date(webPublication.date)}
6058
display={'relative'}
61-
serverTime={serverTime}
6259
showWeekday={false}
6360
showDate={true}
6461
showTime={false}

dotcom-rendering/src/components/Carousel.importable.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ type Props = {
4343
onwardsSource: OnwardsSource;
4444
leftColSize: LeftColSize;
4545
discussionApiUrl: string;
46-
serverTime?: number;
4746
renderingTarget: RenderingTarget;
4847
isInStarRatingVariant?: boolean;
4948
};
@@ -450,7 +449,6 @@ type CarouselCardProps = {
450449
linkTo: string;
451450
headlineText: string;
452451
webPublicationDate: string;
453-
serverTime?: number;
454452
imageLoading: Loading;
455453
kickerText?: string;
456454
image?: DCRFrontImage;
@@ -485,7 +483,6 @@ const CarouselCard = ({
485483
imageLoading,
486484
discussionApiUrl,
487485
isOnwardContent,
488-
serverTime,
489486
starRating,
490487
index,
491488
isInStarRatingVariant,
@@ -530,7 +527,6 @@ const CarouselCard = ({
530527
isOnwardContent={isOnwardContent}
531528
mediaPositionOnDesktop={cardImagePosition}
532529
mediaPositionOnMobile={cardImagePosition}
533-
serverTime={serverTime}
534530
starRating={starRating}
535531
index={index}
536532
showTopBarDesktop={!isOnwardContent}
@@ -755,7 +751,6 @@ export const Carousel = ({
755751
leftColSize,
756752
discussionApiUrl,
757753
isOnwardContent = true,
758-
serverTime,
759754
renderingTarget,
760755
isInStarRatingVariant,
761756
...props
@@ -978,7 +973,6 @@ export const Carousel = ({
978973
linkTo={linkTo}
979974
headlineText={headlineText}
980975
webPublicationDate={webPublicationDate}
981-
serverTime={serverTime}
982976
image={image}
983977
kickerText={kickerText}
984978
dataLinkName={`carousel-small-card-position-${i}`}

dotcom-rendering/src/components/DateTime.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { isString, isUndefined } from '@guardian/libs';
1+
import { isString } from '@guardian/libs';
22
import { getEditionFromId } from '../lib/edition';
33
import { useConfig } from './ConfigContext';
4+
import { useDateTime } from './DateTimeContext';
45
import { Island } from './Island';
56
import { RelativeTime } from './RelativeTime.importable';
67

@@ -14,11 +15,9 @@ type Props = {
1415
type DisplayProps =
1516
| {
1617
display?: 'absolute';
17-
serverTime?: never;
1818
}
1919
| {
2020
display: 'relative';
21-
serverTime?: number;
2221
};
2322

2423
const formatWeekday = (date: Date, locale: string, timeZone: string) =>
@@ -57,10 +56,10 @@ export const DateTime = ({
5756
showDate,
5857
showTime,
5958
display = 'absolute',
60-
serverTime,
6159
}: Props & DisplayProps) => {
6260
const { editionId } = useConfig();
6361
const { dateLocale, timeZone } = getEditionFromId(editionId);
62+
const serverTime = useDateTime();
6463

6564
/**
6665
* Server time (if set) is rounded down to the previous minute to ensure
@@ -70,9 +69,9 @@ export const DateTime = ({
7069
*
7170
* [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#the_epoch_timestamps_and_invalid_date
7271
*/
73-
const now = isUndefined(serverTime)
74-
? MAX_DATE
75-
: Math.floor(serverTime / ONE_MINUTE) * ONE_MINUTE;
72+
const now = serverTime
73+
? Math.floor(serverTime / ONE_MINUTE) * ONE_MINUTE
74+
: MAX_DATE;
7675
const then = date.getTime();
7776

7877
return display === 'relative' ? (

dotcom-rendering/src/components/DecideContainer.tsx

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ type Props = {
4141
containerType: DCRContainerType;
4242
containerPalette?: DCRContainerPalette;
4343
showAge?: boolean;
44-
serverTime?: number;
4544
aspectRatio: AspectRatio;
4645
sectionId: string;
4746
frontId?: string;
@@ -57,7 +56,6 @@ export const DecideContainer = ({
5756
containerType,
5857
containerPalette,
5958
showAge,
60-
serverTime,
6159
imageLoading,
6260
aspectRatio,
6361
sectionId,
@@ -74,7 +72,6 @@ export const DecideContainer = ({
7472
groupedTrails={groupedTrails}
7573
containerPalette={containerPalette}
7674
showAge={showAge}
77-
serverTime={serverTime}
7875
imageLoading={imageLoading}
7976
/>
8077
);
@@ -84,7 +81,6 @@ export const DecideContainer = ({
8481
groupedTrails={groupedTrails}
8582
containerPalette={containerPalette}
8683
showAge={showAge}
87-
serverTime={serverTime}
8884
imageLoading={imageLoading}
8985
/>
9086
);
@@ -94,7 +90,6 @@ export const DecideContainer = ({
9490
groupedTrails={groupedTrails}
9591
containerPalette={containerPalette}
9692
showAge={showAge}
97-
serverTime={serverTime}
9893
imageLoading={imageLoading}
9994
/>
10095
);
@@ -104,7 +99,6 @@ export const DecideContainer = ({
10499
trails={trails}
105100
containerPalette={containerPalette}
106101
showAge={showAge}
107-
serverTime={serverTime}
108102
imageLoading={imageLoading}
109103
/>
110104
);
@@ -114,7 +108,6 @@ export const DecideContainer = ({
114108
trails={trails}
115109
containerPalette={containerPalette}
116110
showAge={showAge}
117-
serverTime={serverTime}
118111
imageLoading={imageLoading}
119112
/>
120113
);
@@ -124,7 +117,6 @@ export const DecideContainer = ({
124117
trails={trails}
125118
containerPalette={containerPalette}
126119
showAge={showAge}
127-
serverTime={serverTime}
128120
imageLoading={imageLoading}
129121
/>
130122
);
@@ -134,7 +126,6 @@ export const DecideContainer = ({
134126
trails={trails}
135127
containerPalette={containerPalette}
136128
showAge={showAge}
137-
serverTime={serverTime}
138129
imageLoading={imageLoading}
139130
/>
140131
);
@@ -144,7 +135,6 @@ export const DecideContainer = ({
144135
trails={trails}
145136
containerPalette={containerPalette}
146137
showAge={showAge}
147-
serverTime={serverTime}
148138
imageLoading={imageLoading}
149139
/>
150140
);
@@ -154,7 +144,6 @@ export const DecideContainer = ({
154144
trails={trails}
155145
containerPalette={containerPalette}
156146
showAge={showAge}
157-
serverTime={serverTime}
158147
imageLoading={imageLoading}
159148
/>
160149
);
@@ -164,7 +153,6 @@ export const DecideContainer = ({
164153
trails={trails}
165154
containerPalette={containerPalette}
166155
showAge={showAge}
167-
serverTime={serverTime}
168156
imageLoading={imageLoading}
169157
/>
170158
);
@@ -174,7 +162,6 @@ export const DecideContainer = ({
174162
trails={trails}
175163
containerPalette={containerPalette}
176164
showAge={showAge}
177-
serverTime={serverTime}
178165
imageLoading={imageLoading}
179166
/>
180167
);
@@ -184,7 +171,6 @@ export const DecideContainer = ({
184171
trails={trails}
185172
containerPalette={containerPalette}
186173
showAge={showAge}
187-
serverTime={serverTime}
188174
imageLoading={imageLoading}
189175
/>
190176
);
@@ -194,7 +180,6 @@ export const DecideContainer = ({
194180
trails={trails}
195181
containerPalette={containerPalette}
196182
showAge={showAge}
197-
serverTime={serverTime}
198183
imageLoading={imageLoading}
199184
/>
200185
);
@@ -204,7 +189,6 @@ export const DecideContainer = ({
204189
trails={trails}
205190
containerPalette={containerPalette}
206191
showAge={showAge}
207-
serverTime={serverTime}
208192
imageLoading={imageLoading}
209193
/>
210194
);
@@ -214,7 +198,6 @@ export const DecideContainer = ({
214198
trails={trails}
215199
containerPalette={containerPalette}
216200
showAge={showAge}
217-
serverTime={serverTime}
218201
imageLoading={imageLoading}
219202
/>
220203
);
@@ -224,7 +207,6 @@ export const DecideContainer = ({
224207
trails={trails}
225208
containerPalette={containerPalette}
226209
showAge={showAge}
227-
serverTime={serverTime}
228210
imageLoading={imageLoading}
229211
/>
230212
);
@@ -248,7 +230,6 @@ export const DecideContainer = ({
248230
groupedTrails={groupedTrails}
249231
containerPalette={containerPalette}
250232
showAge={showAge}
251-
serverTime={serverTime}
252233
imageLoading={imageLoading}
253234
aspectRatio={aspectRatio}
254235
collectionId={collectionId}
@@ -262,7 +243,6 @@ export const DecideContainer = ({
262243
groupedTrails={groupedTrails}
263244
containerPalette={containerPalette}
264245
showAge={showAge}
265-
serverTime={serverTime}
266246
imageLoading={imageLoading}
267247
aspectRatio={aspectRatio}
268248
containerLevel={containerLevel}
@@ -279,7 +259,6 @@ export const DecideContainer = ({
279259
imageLoading={imageLoading}
280260
containerPalette={containerPalette}
281261
showAge={showAge}
282-
serverTime={serverTime}
283262
aspectRatio={aspectRatio}
284263
sectionId={sectionId}
285264
isInStarRatingVariant={isInStarRatingVariant}
@@ -294,7 +273,6 @@ export const DecideContainer = ({
294273
imageLoading={imageLoading}
295274
containerPalette={containerPalette}
296275
showAge={showAge}
297-
serverTime={serverTime}
298276
aspectRatio={aspectRatio}
299277
sectionId={sectionId}
300278
isInStarRatingVariant={isInStarRatingVariant}
@@ -307,7 +285,6 @@ export const DecideContainer = ({
307285
trails={trails}
308286
containerPalette={containerPalette}
309287
showAge={showAge}
310-
serverTime={serverTime}
311288
imageLoading={imageLoading}
312289
aspectRatio={aspectRatio}
313290
isInStarRatingVariant={isInStarRatingVariant}
@@ -320,7 +297,6 @@ export const DecideContainer = ({
320297
trails={trails}
321298
imageLoading={imageLoading}
322299
containerPalette={containerPalette}
323-
serverTime={serverTime}
324300
aspectRatio={aspectRatio}
325301
collectionId={collectionId}
326302
isInStarRatingVariant={isInStarRatingVariant}
@@ -332,7 +308,6 @@ export const DecideContainer = ({
332308
<StaticFeatureTwo
333309
trails={trails}
334310
containerPalette={containerPalette}
335-
serverTime={serverTime}
336311
imageLoading={imageLoading}
337312
aspectRatio={aspectRatio}
338313
collectionId={collectionId}

0 commit comments

Comments
 (0)