From 6ea451d10d23846be2a92768a01c5c42d9e7dfa0 Mon Sep 17 00:00:00 2001 From: Quang Lam Date: Mon, 30 Aug 2021 18:03:54 -0500 Subject: [PATCH] Fix cannot read property 'ratingCardDidRate2' of undefined on macOS (#346) --- .github/workflows/linux-arm64.yml | 3 ++- .github/workflows/linux-x64.yml | 3 ++- .github/workflows/macos-mas.yml | 3 ++- .github/workflows/windows.yml | 3 ++- main-src/libs/preferences.js | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linux-arm64.yml b/.github/workflows/linux-arm64.yml index 93549e70..bcebe188 100644 --- a/.github/workflows/linux-arm64.yml +++ b/.github/workflows/linux-arm64.yml @@ -57,4 +57,5 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REACT_APP_AMPLITUDE_API_KEY: ${{ secrets.REACT_APP_AMPLITUDE_API_KEY }} REACT_APP_OCR_SPACE_API_KEY: ${{ secrets.REACT_APP_OCR_SPACE_API_KEY }} - ELECTRON_APP_SENTRY_DSN: ${{ secrets.ELECTRON_APP_SENTRY_DSN }} \ No newline at end of file + ELECTRON_APP_SENTRY_DSN: ${{ secrets.ELECTRON_APP_SENTRY_DSN }} + if: startsWith(github.ref, 'refs/tags/') \ No newline at end of file diff --git a/.github/workflows/linux-x64.yml b/.github/workflows/linux-x64.yml index 13d5d098..eb246e3e 100644 --- a/.github/workflows/linux-x64.yml +++ b/.github/workflows/linux-x64.yml @@ -55,4 +55,5 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REACT_APP_AMPLITUDE_API_KEY: ${{ secrets.REACT_APP_AMPLITUDE_API_KEY }} REACT_APP_OCR_SPACE_API_KEY: ${{ secrets.REACT_APP_OCR_SPACE_API_KEY }} - ELECTRON_APP_SENTRY_DSN: ${{ secrets.ELECTRON_APP_SENTRY_DSN }} \ No newline at end of file + ELECTRON_APP_SENTRY_DSN: ${{ secrets.ELECTRON_APP_SENTRY_DSN }} + if: startsWith(github.ref, 'refs/tags/') \ No newline at end of file diff --git a/.github/workflows/macos-mas.yml b/.github/workflows/macos-mas.yml index fe2bf514..51f0e6f6 100644 --- a/.github/workflows/macos-mas.yml +++ b/.github/workflows/macos-mas.yml @@ -62,4 +62,5 @@ jobs: REACT_APP_AMPLITUDE_API_KEY: ${{ secrets.REACT_APP_AMPLITUDE_API_KEY }} REACT_APP_OCR_SPACE_API_KEY: ${{ secrets.REACT_APP_OCR_SPACE_API_KEY }} ELECTRON_APP_SENTRY_DSN: ${{ secrets.ELECTRON_APP_SENTRY_DSN }} - SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk \ No newline at end of file + SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk + if: startsWith(github.ref, 'refs/tags/') \ No newline at end of file diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index f2e6ef98..38afdb3b 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -51,4 +51,5 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REACT_APP_AMPLITUDE_API_KEY: ${{ secrets.REACT_APP_AMPLITUDE_API_KEY }} REACT_APP_OCR_SPACE_API_KEY: ${{ secrets.REACT_APP_OCR_SPACE_API_KEY }} - ELECTRON_APP_SENTRY_DSN: ${{ secrets.ELECTRON_APP_SENTRY_DSN }} \ No newline at end of file + ELECTRON_APP_SENTRY_DSN: ${{ secrets.ELECTRON_APP_SENTRY_DSN }} + if: startsWith(github.ref, 'refs/tags/') \ No newline at end of file diff --git a/main-src/libs/preferences.js b/main-src/libs/preferences.js index 20ff776d..cee083e9 100644 --- a/main-src/libs/preferences.js +++ b/main-src/libs/preferences.js @@ -68,7 +68,7 @@ const initCachedPreferences = () => { // ratingCardDidRate2 is only reset on Windows & Linux // so transfer old value (ratingCardDidRate) to new value on macOS const savedPreferences = settings.getSync(`preferences.${v}`); - if (process.platform === 'darwin' && !savedPreferences.ratingCardDidRate2 && savedPreferences.ratingCardDidRate) { + if (process.platform === 'darwin' && savedPreferences && !savedPreferences.ratingCardDidRate2 && savedPreferences.ratingCardDidRate) { savedPreferences.ratingCardDidRate2 = true; }