commit
1ca745d607
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import useDateUtils from 'libs/date/useDateUtils';
|
import useDateUtils from 'libs/date/useDateUtils';
|
||||||
import useServer from 'features/ServerPage/libs/ServerContext/useServer';
|
import useServer from 'features/ServerPage/libs/ServerContext/useServer';
|
||||||
import useStyles from './useStyles';
|
import useStyles from './useStyles';
|
||||||
|
@ -20,9 +20,27 @@ const ServerInfo = ({ t }: Props) => {
|
||||||
numberOfVillages,
|
numberOfVillages,
|
||||||
} = useServer();
|
} = useServer();
|
||||||
const dateUtils = useDateUtils();
|
const dateUtils = useDateUtils();
|
||||||
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
|
const getDataUpdatedAtText = () => {
|
||||||
|
return t('pageLayout.sidebar.serverInfo.dataUpdatedAt', {
|
||||||
|
date: dateUtils.formatDistanceToNow(new Date(dataUpdatedAt), {
|
||||||
|
addSuffix: true,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const [dataUpdatedAtText, setDataUpdatedAtText] = useState<string>(
|
||||||
|
getDataUpdatedAtText()
|
||||||
|
);
|
||||||
|
useEffect(() => {
|
||||||
|
const intervalID = setInterval(() => {
|
||||||
|
setDataUpdatedAtText(getDataUpdatedAtText());
|
||||||
|
}, 30000);
|
||||||
|
return () => {
|
||||||
|
clearInterval(intervalID);
|
||||||
|
}; // eslint-disable-next-line
|
||||||
|
}, [dataUpdatedAt, t, dateUtils]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<Typography>
|
<Typography>
|
||||||
|
@ -43,13 +61,7 @@ const ServerInfo = ({ t }: Props) => {
|
||||||
count: numberOfVillages,
|
count: numberOfVillages,
|
||||||
})}
|
})}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography>
|
<Typography>{dataUpdatedAtText}</Typography>
|
||||||
{t('pageLayout.sidebar.serverInfo.dataUpdatedAt', {
|
|
||||||
date: dateUtils.formatDistanceToNow(new Date(dataUpdatedAt), {
|
|
||||||
addSuffix: true,
|
|
||||||
}),
|
|
||||||
})}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -82,13 +82,18 @@ function IndexPage() {
|
||||||
})`,
|
})`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'deletedAt',
|
field: player.deletedAt ? 'deletedAt' : 'lastActivityAt',
|
||||||
value: player.deletedAt
|
value: player.deletedAt
|
||||||
? dateUtils.format(
|
? dateUtils.format(
|
||||||
dateUtils.date(player.deletedAt),
|
dateUtils.date(player.deletedAt),
|
||||||
DATE_FORMAT.DAY_MONTH_AND_YEAR
|
DATE_FORMAT.DAY_MONTH_AND_YEAR
|
||||||
)
|
)
|
||||||
: '-',
|
: dateUtils.formatDistanceToNow(
|
||||||
|
new Date(player.lastActivityAt ?? 0),
|
||||||
|
{
|
||||||
|
addSuffix: true,
|
||||||
|
}
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'bestRank',
|
field: 'bestRank',
|
||||||
|
|
|
@ -21,6 +21,7 @@ const ctx = createContext<Player>({
|
||||||
mostPointsAt: new Date(0),
|
mostPointsAt: new Date(0),
|
||||||
mostVillages: 0,
|
mostVillages: 0,
|
||||||
mostVillagesAt: new Date(0),
|
mostVillagesAt: new Date(0),
|
||||||
|
lastActivityAt: new Date(0),
|
||||||
bestRank: 0,
|
bestRank: 0,
|
||||||
bestRankAt: new Date(0),
|
bestRankAt: new Date(0),
|
||||||
joinedAt: new Date(0),
|
joinedAt: new Date(0),
|
||||||
|
|
|
@ -27,6 +27,7 @@ export const PLAYER = gql`
|
||||||
joinedAt
|
joinedAt
|
||||||
servers
|
servers
|
||||||
deletedAt
|
deletedAt
|
||||||
|
lastActivityAt
|
||||||
nameChanges {
|
nameChanges {
|
||||||
oldName
|
oldName
|
||||||
newName
|
newName
|
||||||
|
|
|
@ -28,6 +28,7 @@ export type Player = {
|
||||||
bestRankAt: Date | string;
|
bestRankAt: Date | string;
|
||||||
joinedAt: Date | string;
|
joinedAt: Date | string;
|
||||||
deletedAt?: Date | string;
|
deletedAt?: Date | string;
|
||||||
|
lastActivityAt: Date | string;
|
||||||
servers: string[];
|
servers: string[];
|
||||||
nameChanges: NameChange[];
|
nameChanges: NameChange[];
|
||||||
tribe?: {
|
tribe?: {
|
||||||
|
|
|
@ -25,7 +25,7 @@ function Provider({ children }: Props) {
|
||||||
ServerList,
|
ServerList,
|
||||||
ServersQueryVariables
|
ServersQueryVariables
|
||||||
>(SERVERS, {
|
>(SERVERS, {
|
||||||
fetchPolicy: 'cache-first',
|
fetchPolicy: 'cache-and-network',
|
||||||
variables: {
|
variables: {
|
||||||
limit: 1,
|
limit: 1,
|
||||||
filter: {
|
filter: {
|
||||||
|
|
|
@ -24,6 +24,7 @@ const translations = {
|
||||||
mostPoints: 'Most points',
|
mostPoints: 'Most points',
|
||||||
mostVillages: 'Most villages',
|
mostVillages: 'Most villages',
|
||||||
servers: 'Servers',
|
servers: 'Servers',
|
||||||
|
lastActivityAt: 'Last activity',
|
||||||
},
|
},
|
||||||
nameChanges: {
|
nameChanges: {
|
||||||
title: 'Name changes',
|
title: 'Name changes',
|
||||||
|
|
|
@ -24,6 +24,7 @@ const translations = {
|
||||||
mostPoints: 'Najwięcej punktów',
|
mostPoints: 'Najwięcej punktów',
|
||||||
mostVillages: 'Najwięcej wiosek',
|
mostVillages: 'Najwięcej wiosek',
|
||||||
servers: 'Serwery',
|
servers: 'Serwery',
|
||||||
|
lastActivityAt: 'Ostatnia aktywność',
|
||||||
},
|
},
|
||||||
nameChanges: {
|
nameChanges: {
|
||||||
title: 'Zmiany nicków',
|
title: 'Zmiany nicków',
|
||||||
|
|
|
@ -24,6 +24,7 @@ const translations = {
|
||||||
mostPoints: 'Maior pontuação',
|
mostPoints: 'Maior pontuação',
|
||||||
mostVillages: 'Maior quantidade de aldeias',
|
mostVillages: 'Maior quantidade de aldeias',
|
||||||
servers: 'Servidores',
|
servers: 'Servidores',
|
||||||
|
lastActivityAt: 'Last activity',
|
||||||
},
|
},
|
||||||
nameChanges: {
|
nameChanges: {
|
||||||
title: 'Mudanças de nome',
|
title: 'Mudanças de nome',
|
||||||
|
|
|
@ -24,6 +24,7 @@ const translations = {
|
||||||
mostPoints: 'Maior pontuação',
|
mostPoints: 'Maior pontuação',
|
||||||
mostVillages: 'Maior quantidade de aldeias',
|
mostVillages: 'Maior quantidade de aldeias',
|
||||||
servers: 'Servidores',
|
servers: 'Servidores',
|
||||||
|
lastActivityAt: 'Last activity',
|
||||||
},
|
},
|
||||||
nameChanges: {
|
nameChanges: {
|
||||||
title: 'Mudanças de nome',
|
title: 'Mudanças de nome',
|
||||||
|
|
Reference in New Issue
Block a user