From be1d066984ad423611b9c79a3818bd34dbb6b1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Quiroz?= Date: Mon, 12 Dec 2022 13:11:15 -0300 Subject: [PATCH] chore: wip --- src/components/UI/DataTable.tsx | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/components/UI/DataTable.tsx b/src/components/UI/DataTable.tsx index 55df07c493..60c702055b 100644 --- a/src/components/UI/DataTable.tsx +++ b/src/components/UI/DataTable.tsx @@ -71,11 +71,72 @@ export const DataTable: FC = ({ columnHeaders, data }) => { {dataType === 'Releases' && data.map((r: ReleaseData, idx: number) => { + const url = r?.release?.url; + const os = url?.includes('darwin') + ? 'darwin' + : url?.includes('linux') + ? 'linux' + : url?.includes('windows') + ? 'windows' + : url?.includes('android') + ? 'android' + : 'ios'; + + // const isLatestStableLinuxRelease = + // os === 'linux' && + // data + // .filter( + // (e: ReleaseData) => e.arch === '64-bit' && !e.release.url.includes('unstable') + // ) + // .every((elem: ReleaseData) => { + // console.log('release:', r); + // console.log('elem:', elem); + + // return new Date(r.published) >= new Date(elem.published); + // }); + + const x = data.filter((e: ReleaseData, _: any, array: any) => { + const maxDate = array + .map((e: ReleaseData) => new Date(e.published)) + .filter((f: Date, _: any, array: any) => + array.every((f: Date) => f <= new Date(e.published)) + ); + + return ( + e.arch === '64-bit' && + !e.release.url.includes('unstable') && + new Date(e.published) === new Date(maxDate) + ); + }); + + console.log(x); + + const latestDarwinRelease = os === 'darwin' && r.arch === '64-bit'; + const latestWindowsRelease = os === 'darwin' && r.kind === 'Installer'; + const latestAndroidRelease = os === 'android' && r.arch === 'all'; + const latestiOSRelease = os === 'ios' && r.arch === 'all'; + + // const latest = data.filter( + // (rel: ReleaseData) => + // os === 'linux' && rel.arch === '64-bit' && !rel.release.url.includes('unstable') + // ); + // .every((otherRelease: ReleaseData) => r.published > otherRelease.published); + + // console.log({ latest }); + + const isPrimaryRelease = + 'isLatestStableLinuxRelease' || + latestDarwinRelease || + latestWindowsRelease || + latestAndroidRelease || + latestiOSRelease; + return ( {Object.entries(r).map((item, idx) => { const objectItems = ['release', 'commit', 'signature'];