From f8b1b1d2ea15025c01e20d21a9be6053585bd00c Mon Sep 17 00:00:00 2001 From: Oliver Sauter Date: Wed, 28 Feb 2024 13:02:19 +0100 Subject: [PATCH] automatically get the right download helper link --- src/options/imports/components/Import.tsx | 36 +++++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/options/imports/components/Import.tsx b/src/options/imports/components/Import.tsx index 131d66d9ee..425e2f041a 100644 --- a/src/options/imports/components/Import.tsx +++ b/src/options/imports/components/Import.tsx @@ -18,6 +18,7 @@ import { MemexLocalBackend } from 'src/pkm-integrations/background/backend' import { TooltipBox } from '@worldbrain/memex-common/lib/common-ui/components/tooltip-box' import Checkbox from 'src/common-ui/components/Checkbox' import { LOCAL_SERVER_ROOT } from 'src/backup-restore/ui/backup-pane/constants' +import { downloadMemexDesktop } from 'src/util/subscriptions/storage' const localStyles = require('./Import.css') @@ -290,6 +291,27 @@ class Import extends React.PureComponent { }) } + getSystemArchAndOS = async () => { + let os + let arch + await browser.runtime.getPlatformInfo().then(function (info) { + os = info.os + arch = info.arch + }) + + if (arch === 'aarch64' || arch === 'arm' || arch === 'arm64') { + arch = 'arm' + } + if (arch === 'x86-64') { + arch = 'x64' + } + + return { + arch, + os, + } + } + private async getPathsFromLocalStorage() { const data = await browser.storage.local.get('PKMSYNCpkmFolders') @@ -658,10 +680,11 @@ class Import extends React.PureComponent { { - window.open( - 'https://github.com/WorldBrain/memex-local-sync/releases/latest', - '_blank', + const url = await downloadMemexDesktop( + await this.getSystemArchAndOS(), ) + + window.open(url, '_blank') }} icon={'inbox'} size={'medium'} @@ -1004,10 +1027,11 @@ class Import extends React.PureComponent { { - window.open( - 'https://github.com/WorldBrain/memex-local-sync/releases/latest', - '_blank', + const url = await downloadMemexDesktop( + await this.getSystemArchAndOS(), ) + + window.open(url, '_blank') }} icon={'inbox'} size={'medium'}