Skip to content

Commit 922e526

Browse files
committed
[desktop] appelSilicon special case
will only work on Chrome I am afraid
1 parent 7617756 commit 922e526

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/components/DownloadGephiDesktop.astro

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,20 @@ const DOWNLOAD_LINKS = await getDownloadLinks();
106106
</download-gephi-desktop>
107107
<script >
108108
import { UAParser } from 'ua-parser-js';
109+
import { isAppleSilicon } from 'ua-parser-js/device-detection';
109110
class DownloadGephiDesktop extends HTMLElement {
110-
connectedCallback() {
111+
async connectedCallback() {
111112
// Read the message from the data attribute.
112113
const BROWSERS = JSON.parse(this.dataset.browsers||'{}');
113114
const DOWNLOAD_LINKS = JSON.parse(this.dataset.links||'{}');
114-
const { os, cpu } = UAParser(navigator.userAgent);
115+
const detection = await UAParser(navigator.userAgent).withClientHints();
115116

116117
let currentBrowser = "windows64";
117-
switch(os.name){
118-
case "Windows": currentBrowser = cpu.architecture?.includes("32") ? "windows32": "windows64" ; break;
119-
case "macOS": currentBrowser = cpu.architecture?.includes("arm") ? "macSilicon" : "macIntel"; break;
118+
switch(detection.os.name){
119+
case "Windows": currentBrowser = detection.cpu.architecture?.includes("32") ? "windows32": "windows64" ; break;
120+
case "macOS":
121+
currentBrowser = detection.cpu.architecture?.includes("arm") ||
122+
isAppleSilicon(detection) ? "macSilicon" : "macIntel"; break;
120123
// default to linux for all variety of linux OS + all variety of mobile...
121124
// TODO: for mobile/tablet/console (detected in the device) we could advertize gephi-lite
122125
default: currentBrowser = "linux";

0 commit comments

Comments
 (0)