Test code climate #1058
12 changed files with 1443 additions and 873 deletions
|
@ -4,7 +4,7 @@
|
|||
"airbnb",
|
||||
"plugin:import/electron",
|
||||
"plugin:flowtype/recommended",
|
||||
"plugin:prettier/recommended"
|
||||
"prettier"
|
||||
],
|
||||
"settings": {
|
||||
"import/resolver": {
|
||||
|
@ -28,6 +28,7 @@
|
|||
"rules": {
|
||||
"import/no-commonjs": "warn",
|
||||
"import/no-amd": "warn",
|
||||
"func-names": ["warn", "as-needed"]
|
||||
"func-names": ["warn", "as-needed"],
|
||||
"prettier/prettier": "error"
|
||||
}
|
||||
}
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,6 +1,7 @@
|
|||
/node_modules
|
||||
/dist
|
||||
/build/daemon.ver
|
||||
/build/daemon.zip
|
||||
/build/venv
|
||||
*.pyc
|
||||
/static/daemon/lbrynet*
|
||||
|
|
67
.travis.yml
67
.travis.yml
|
@ -1,28 +1,43 @@
|
|||
matrix:
|
||||
include:
|
||||
- os: osx
|
||||
osx_image: xcode9.2
|
||||
language: node_js
|
||||
node_js: "9"
|
||||
env:
|
||||
global:
|
||||
- TRANSIFEX_USER: api
|
||||
- secure: u6gwnZlPGJLnvpoPPCpUZ+jBPajQuIW1+aq6UGW57z54AUjTAECxaYpqcGTGtDBjYark/yeiso887wP/EmJva7hMHeNMf6uLqwzP3YFsIv/Iv+9c1f4MXbJNgOrEKN834o/BdkD4ifi9CCiH9uPPVYGPx1bvfaxGpcHmQXdW4F4S0uj+jePB257mt+afGiNlz9wET6kWJKNNZf/4BNmefldVNq7h6oTSLsyO1TBhDcvSjatpKIwmXUNQfSUTFWvrtpWUB/m/IzitGuUtrt82vU2fPl7tuH6BHNrNp58MINjFzXXJLC+mMybb2UBDIAuc3+k7vj4J0U2rkcTloxDNCKNmYa1jBogOKBRgGp98Ct7E0V2vuLGAPniUbvBcCGK1wwed7uwDjsz3YNCGxUEcyyWc3OVDgN/up4+gXHxkh9FTpZy8Q3rSZx4Lwj700impBUQIVh/5p7Vgv+bSUdOeVRAMlcP9yT83jX50w9LkJMfICFPNv1tOZ3/SOnnB+JdW/ahpplFI4Z68/fBLttZTeaNcU4f28oJvPer8Wll+Elx5kxwLqLbwVUFNlxTxY1LYnPB7SPjGxrFNy3mVTRq5Pxp1hMiTZF4TlapkfHgR+gEzk2wpcJGmub70tW2baZaJF0jDBWIh7GXV+EGve53BKDhpX2Z6jTK0gkhrSUW1MT8=
|
||||
- secure: h1r9Qzv2xHRQl7nDHcscB4qDv7KlF/ncgHko1YuoY4oLZipBV8mzQXDmn3nlMKwaKOe1/Tty/bjoZexkWict4cwKBzU7/1HtJeMa6nxRICuS6DiVhLUNGZEddK6jQLxeEZFxkFPSCZyjybPWtasF8f8jd0lqqLIL4/FcIVV56aRCKAsUwCbedxi8Vnc19l74xjaQIK82xBFYOQPK078OBovk9DDOnicTjMulUo3/pKEZD1njSdcEhfSRv+MFE+31B/a6lpoLo7twPlyzLMfpo30NlEzIN0TeMAk44e4PV6DYg0wntC2GJ21p4BqMnDGocwnZwm7gpjflzUZdW6hF0esGLcqOdbyJLUb3rNX9AzQmn0p9KwDC3S80peZFxSiuLJGL8eivceVDUK/jwWinu3OHDJ/eO5iMDm9odm2ALemPtrDTSlRNT8HzNCY9PQTU9Dhdm4Q/dGDsRPWibFJSJ/qGKhVgadk2CUEAPua0hB1zZ556PkTGx4R1JDscgFDAkgemzgKl4Z/4qK3xGDoEtz1HmBlvQtn+B/PuhA2essADj0iTDiItxb7AYTA7EzsHEcRMmrbYarZ3Eh2onWy2GOpAGRN5Xl9cBIDbibcSC6BLI1m2PcLABpP7DhUX4bJbsVNSiGesHEU7o9Dgn8Ig09eHW/8F9i0VVoGUZXxKMJ8=
|
||||
|
||||
os: linux
|
||||
dist: xenial
|
||||
|
||||
branches:
|
||||
only:
|
||||
- "/^v\\d+\\.\\d+\\.\\d+$/"
|
||||
|
||||
install:
|
||||
- rvm install 2.3.1
|
||||
|
||||
- ELECTRON_CACHE=$HOME/.cache/electron
|
||||
- ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder
|
||||
- os: linux
|
||||
services: docker
|
||||
language: generic
|
||||
before_cache:
|
||||
- rm -rf $HOME/.cache/electron-builder/wine
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
- $HOME/.cache/electron
|
||||
- $HOME/.cache/electron-builder
|
||||
before_install:
|
||||
- |
|
||||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||
mkdir -p /tmp/git-lfs && curl -L https://github.com/github/git-lfs/releases/download/v2.3.1/git-lfs-$([ "$TRAVIS_OS_NAME" == "linux" ] && echo "linux" || echo "darwin")-amd64-2.3.1.tar.gz | tar -xz -C /tmp/git-lfs --strip-components 1
|
||||
export PATH="/tmp/git-lfs:$PATH"
|
||||
fi
|
||||
before_script:
|
||||
- git lfs pull
|
||||
script:
|
||||
- rvm use 2.3.1 && gem install danger --version '~> 4.0' && danger
|
||||
- FULL_BUILD=true ./build.sh
|
||||
|
||||
sudo: required
|
||||
after_success:
|
||||
- pip install virtualenv
|
||||
- virtualenv ~/env
|
||||
- source ~/env/bin/activate
|
||||
- pip install transifex-client
|
||||
- sudo echo $'[https://www.transifex.com]\nhostname = https://www.transifex.com\nusername= '"$TRANSIFEX_USER"$'\npassword = '"$TRANSIFEX_PASSWORD"$'\ntoken = '"$TRANSIFEX_API_TOKEN"$'\n' > ~/.transifexrc
|
||||
- tx push -s
|
||||
- |
|
||||
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
||||
docker run --rm \
|
||||
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
|
||||
-v ${PWD}:/project \
|
||||
-v ~/.cache/electron:/root/.cache/electron \
|
||||
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
|
||||
electronuserland/builder:wine \
|
||||
/bin/bash -c "yarn --link-duplicates --pure-lockfile && yarn build --linux --win"
|
||||
else
|
||||
yarn build
|
||||
fi
|
||||
branches:
|
||||
except:
|
||||
- "/^v\\d+\\.\\d+\\.\\d+$/"
|
||||
|
|
0
build/build.sh
Executable file → Normal file
0
build/build.sh
Executable file → Normal file
42
build/downloadDaemon.js
Normal file
42
build/downloadDaemon.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* eslint-disable */
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const packageJSON = require('../package.json');
|
||||
const axios = require('axios');
|
||||
const decompress = require('decompress');
|
||||
|
||||
module.exports = function(context) {
|
||||
const daemonURLTemplate = packageJSON.lbrySettings.lbrynetDaemonUrlTemplate;
|
||||
const daemonVersion = packageJSON.lbrySettings.lbrynetDaemonVersion;
|
||||
let currentPlatform = context.platform.toString();
|
||||
if (currentPlatform === 'mac') currentPlatform = 'macos';
|
||||
|
||||
const daemonURL = daemonURLTemplate
|
||||
.replace(/DAEMONVER/g, daemonVersion)
|
||||
.replace(/OSNAME/g, currentPlatform);
|
||||
const tmpZipPath = 'build/daemon.zip';
|
||||
|
||||
return new Promise(resolve => {
|
||||
axios
|
||||
.request({
|
||||
responseType: 'arraybuffer',
|
||||
url: daemonURL,
|
||||
method: 'get',
|
||||
headers: {
|
||||
'Content-Type': 'application/zip',
|
||||
},
|
||||
})
|
||||
.then(result => {
|
||||
fs.writeFileSync(tmpZipPath, result.data);
|
||||
return true;
|
||||
})
|
||||
.then(() => {
|
||||
return decompress(tmpZipPath, 'static/daemon', {
|
||||
filter: file => path.basename(file.path).replace(path.extname(file.path), '') === 'lbrynet-daemon',
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
return resolve(true);
|
||||
});
|
||||
});
|
||||
};
|
|
@ -1,11 +1,8 @@
|
|||
{
|
||||
"appId": "io.lbry.LBRY",
|
||||
"publish": {
|
||||
"provider": "s3",
|
||||
"bucket": "releases.lbry.io",
|
||||
"path": "app/latest"
|
||||
},
|
||||
"productName": "LBRY",
|
||||
"mac": {
|
||||
"target": "dmg",
|
||||
"category": "public.app-category.entertainment"
|
||||
},
|
||||
"dmg": {
|
||||
|
@ -32,32 +29,20 @@
|
|||
},
|
||||
"protocols": [
|
||||
{
|
||||
"name": "lbry",
|
||||
"name": "LBRY URI",
|
||||
"schemes": ["lbry"],
|
||||
"role": "Viewer"
|
||||
}
|
||||
],
|
||||
"linux": {
|
||||
"target": "deb",
|
||||
"category": "Video",
|
||||
"category": "AudioVideo;Video",
|
||||
"desktop": {
|
||||
"MimeType": "x-scheme-handler/lbry",
|
||||
"Exec": "/opt/LBRY/lbry %U"
|
||||
"MimeType": "x-scheme-handler/lbry;"
|
||||
}
|
||||
},
|
||||
"deb": {
|
||||
"depends": [
|
||||
"gconf2",
|
||||
"gconf-service",
|
||||
"libnotify4",
|
||||
"libappindicator1",
|
||||
"libxtst6",
|
||||
"libnss3",
|
||||
"libsecret-1-0"
|
||||
]
|
||||
},
|
||||
"nsis": {
|
||||
"perMachine": true
|
||||
},
|
||||
"artifactName": "${productName}_${version}_${arch}.${ext}"
|
||||
"beforeBuild": "build/downloadDaemon.js",
|
||||
"artifactName": "${productName}_${version}.${ext}"
|
||||
}
|
||||
|
|
35
package.json
35
package.json
|
@ -1,14 +1,14 @@
|
|||
{
|
||||
"name": "LBRY",
|
||||
"version": "0.20.0",
|
||||
"name": "lbry-app",
|
||||
"version": "0.29.0",
|
||||
"description": "A browser for the LBRY network, a digital marketplace controlled by its users.",
|
||||
"homepage": "https://lbry.io/",
|
||||
"bugs": {
|
||||
"url": "https://github.com/lbryio/lbry-app/issues"
|
||||
"url": "https://github.com/IGassmann/lbry-app/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/lbryio/lbry-app"
|
||||
"url": "https://github.com/IGassmann/lbry-app"
|
||||
},
|
||||
"author": {
|
||||
"name": "LBRY Inc.",
|
||||
|
@ -21,6 +21,7 @@
|
|||
"compile": "electron-webpack && yarn extract-langs",
|
||||
"build": "yarn compile && electron-builder build",
|
||||
"build:dir": "yarn build -- --dir -c.compression=store -c.mac.identity=null",
|
||||
"release": "yarn compile && electron-builder build",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"lint": "eslint 'src/**/*.{js,jsx}' --fix",
|
||||
"format": "prettier 'src/**/*.{js,jsx,scss,json}' --write"
|
||||
|
@ -36,13 +37,13 @@
|
|||
"electron-dl": "^1.6.0",
|
||||
"electron-log": "^2.2.12",
|
||||
"electron-publisher-s3": "^19.47.0",
|
||||
"electron-updater": "^2.16.1",
|
||||
"electron-updater": "^2.18.2",
|
||||
"formik": "^0.10.4",
|
||||
"from2": "^2.3.0",
|
||||
"install": "^0.10.2",
|
||||
"jayson": "^2.0.2",
|
||||
"jshashes": "^1.0.7",
|
||||
"keytar-prebuild": "^4.0.4",
|
||||
"keytar-prebuild": "^4.1.1",
|
||||
"localforage": "^1.5.0",
|
||||
"moment": "^2.20.1",
|
||||
"npm": "^5.5.1",
|
||||
|
@ -71,27 +72,29 @@
|
|||
"y18n": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-eslint": "^8.0.3",
|
||||
"babel-plugin-module-resolver": "^3.0.0",
|
||||
"axios": "^0.17.1",
|
||||
"babel-eslint": "^8.2.2",
|
||||
"babel-plugin-module-resolver": "^3.1.0",
|
||||
"babel-plugin-react-require": "^3.0.0",
|
||||
"babel-polyfill": "^6.20.0",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-preset-react": "^6.24.1",
|
||||
"babel-preset-stage-2": "^6.18.0",
|
||||
"decompress": "^4.2.0",
|
||||
"devtron": "^1.4.0",
|
||||
"electron": "^1.7.11",
|
||||
"electron-builder": "^19.49.0",
|
||||
"electron-builder": "^19.56.0",
|
||||
"electron-devtools-installer": "^2.2.1",
|
||||
"electron-webpack": "^1.11.0",
|
||||
"eslint": "^4.13.1",
|
||||
"electron-webpack": "^1.13.0",
|
||||
"eslint": "^4.18.1",
|
||||
"eslint-config-airbnb": "^16.1.0",
|
||||
"eslint-config-prettier": "^2.9.0",
|
||||
"eslint-import-resolver-webpack": "^0.8.3",
|
||||
"eslint-plugin-flowtype": "^2.40.1",
|
||||
"eslint-plugin-import": "^2.8.0",
|
||||
"eslint-import-resolver-webpack": "^0.8.4",
|
||||
"eslint-plugin-flowtype": "^2.46.1",
|
||||
"eslint-plugin-import": "^2.9.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.0.3",
|
||||
"eslint-plugin-prettier": "^2.4.0",
|
||||
"eslint-plugin-react": "^7.5.1",
|
||||
"eslint-plugin-prettier": "^2.6.0",
|
||||
"eslint-plugin-react": "^7.7.0",
|
||||
"flow-babel-webpack-plugin": "^1.1.0",
|
||||
"flow-bin": "^0.61.0",
|
||||
"flow-typed": "^2.2.3",
|
||||
|
|
|
@ -31,7 +31,7 @@ let rendererWindow;
|
|||
let tray;
|
||||
let daemon;
|
||||
|
||||
let isQuitting;
|
||||
let isQuitting
|
||||
|
||||
const updateRendererWindow = window => {
|
||||
rendererWindow = window;
|
||||
|
@ -41,7 +41,7 @@ const installExtensions = async () => {
|
|||
// eslint-disable-next-line import/no-extraneous-dependencies,global-require
|
||||
const installer = require('electron-devtools-installer');
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies,global-require
|
||||
const devtronExtension = require('devtron');
|
||||
const devtronExtension = require("devtron");
|
||||
const forceDownload = !!process.env.UPGRADE_EXTENSIONS;
|
||||
const extensions = ['REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS'];
|
||||
|
||||
|
@ -83,21 +83,30 @@ app.on('activate', () => {
|
|||
if (!rendererWindow) rendererWindow = createWindow();
|
||||
});
|
||||
|
||||
app.on('will-quit', (event) => {
|
||||
if (process.platform === 'win32' && autoUpdateDownloaded && !autoUpdateAccepted && !showingAutoUpdateCloseAlert) {
|
||||
app.on('will-quit', event => {
|
||||
if (
|
||||
process.platform === 'win32' &&
|
||||
autoUpdateDownloaded &&
|
||||
!autoUpdateAccepted &&
|
||||
!showingAutoUpdateCloseAlert
|
||||
) {
|
||||
// We're on Win and have an update downloaded, but the user declined it (or closed
|
||||
// the app without accepting it). Now the user is closing the app, so the new update
|
||||
// will install. On Mac this is silent, but on Windows they get a confusing permission
|
||||
// escalation dialog, so we show Windows users a warning dialog first.
|
||||
|
||||
showingAutoUpdateCloseAlert = true;
|
||||
dialog.showMessageBox({
|
||||
dialog.showMessageBox(
|
||||
{
|
||||
type: 'info',
|
||||
title: 'LBRY Will Upgrade',
|
||||
message: 'LBRY has a pending upgrade. Please select "Yes" to install it on the prompt shown after this one.',
|
||||
}, () => {
|
||||
message:
|
||||
'LBRY has a pending upgrade. Please select "Yes" to install it on the prompt shown after this one.',
|
||||
},
|
||||
() => {
|
||||
app.quit();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
event.preventDefault();
|
||||
return;
|
||||
|
@ -144,7 +153,7 @@ ipcMain.on('upgrade', (event, installerPath) => {
|
|||
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
autoUpdateDownloaded = true;
|
||||
})
|
||||
});
|
||||
|
||||
ipcMain.on('autoUpdateAccepted', () => {
|
||||
autoUpdateAccepted = true;
|
||||
|
|
|
@ -9,10 +9,14 @@ import lbry from 'lbry';
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { Provider } from 'react-redux';
|
||||
import { doConditionalAuthNavigate, doDaemonReady, doShowSnackBar, doAutoUpdate } from 'redux/actions/app';
|
||||
import { doUpdateIsNightAsync } from 'redux/actions/settings';
|
||||
import {
|
||||
doConditionalAuthNavigate,
|
||||
doDaemonReady,
|
||||
doShowSnackBar,
|
||||
doAutoUpdate,
|
||||
} from 'redux/actions/app';
|
||||
import { doNavigate } from 'redux/actions/navigation';
|
||||
import { doDownloadLanguages } from 'redux/actions/settings';
|
||||
import { doDownloadLanguages, doUpdateIsNightAsync } from 'redux/actions/settings';
|
||||
import { doUserEmailVerify } from 'redux/actions/user';
|
||||
import 'scss/all.scss';
|
||||
import store from 'store';
|
||||
|
@ -20,12 +24,7 @@ import app from './app';
|
|||
|
||||
const { autoUpdater } = remote.require('electron-updater');
|
||||
|
||||
autoUpdater.logger = remote.require("electron-log");
|
||||
|
||||
window.addEventListener('contextmenu', event => {
|
||||
contextMenu(remote.getCurrentWindow(), event.x, event.y, app.env === 'development');
|
||||
event.preventDefault();
|
||||
});
|
||||
autoUpdater.logger = remote.require('electron-log');
|
||||
|
||||
ipcRenderer.on('open-uri-requested', (event, uri, newSession) => {
|
||||
if (uri && uri.startsWith('lbry://')) {
|
||||
|
@ -100,22 +99,21 @@ document.addEventListener('click', event => {
|
|||
});
|
||||
|
||||
const init = () => {
|
||||
autoUpdater.on("update-downloaded", () => {
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
app.store.dispatch(doAutoUpdate());
|
||||
});
|
||||
|
||||
if (["win32", "darwin"].includes(process.platform)) {
|
||||
autoUpdater.on("update-available", () => {
|
||||
console.log("Update available");
|
||||
autoUpdater.on('update-available', () => {
|
||||
console.log('Update available');
|
||||
});
|
||||
autoUpdater.on("update-not-available", () => {
|
||||
console.log("Update not available");
|
||||
autoUpdater.on('update-not-available', () => {
|
||||
console.log('Update not available');
|
||||
});
|
||||
autoUpdater.on("update-downloaded", () => {
|
||||
console.log("Update downloaded");
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
console.log('Update downloaded');
|
||||
app.store.dispatch(doAutoUpdate());
|
||||
});
|
||||
}
|
||||
|
||||
app.store.dispatch(doUpdateIsNightAsync());
|
||||
app.store.dispatch(doDownloadLanguages());
|
||||
|
||||
|
|
|
@ -10,12 +10,11 @@ import { doAuthNavigate } from 'redux/actions/navigation';
|
|||
import { doFetchDaemonSettings } from 'redux/actions/settings';
|
||||
import { doAuthenticate } from 'redux/actions/user';
|
||||
import { doBalanceSubscribe } from 'redux/actions/wallet';
|
||||
import { doPause } from "redux/actions/media";
|
||||
import { doPause } from 'redux/actions/media';
|
||||
|
||||
import {
|
||||
selectCurrentModal,
|
||||
selectIsUpgradeSkipped,
|
||||
selectRemoteVersion,
|
||||
selectUpdateUrl,
|
||||
selectUpgradeDownloadItem,
|
||||
selectUpgradeDownloadPath,
|
||||
|
@ -84,7 +83,6 @@ export function doDownloadUpgradeRequested() {
|
|||
|
||||
const autoUpdateDeclined = selectAutoUpdateDeclined(state);
|
||||
|
||||
if (['win32', 'darwin'].includes(process.platform)) { // electron-updater behavior
|
||||
if (autoUpdateDeclined) {
|
||||
// The user declined an update before, so show the "confirm" dialog
|
||||
dispatch({
|
||||
|
@ -99,9 +97,6 @@ export function doDownloadUpgradeRequested() {
|
|||
data: { modal: MODALS.AUTO_UPDATE_DOWNLOADED },
|
||||
});
|
||||
}
|
||||
} else { // Old behavior for Linux
|
||||
dispatch(doDownloadUpgrade());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -145,8 +140,7 @@ export function doDownloadUpgrade() {
|
|||
}
|
||||
|
||||
export function doAutoUpdate() {
|
||||
return function(dispatch, getState) {
|
||||
const state = getState();
|
||||
return function(dispatch) {
|
||||
dispatch({
|
||||
type: ACTIONS.AUTO_UPDATE_DOWNLOADED,
|
||||
});
|
||||
|
@ -159,12 +153,11 @@ export function doAutoUpdate() {
|
|||
}
|
||||
|
||||
export function doAutoUpdateDeclined() {
|
||||
return function(dispatch, getState) {
|
||||
const state = getState();
|
||||
return function(dispatch) {
|
||||
dispatch({
|
||||
type: ACTIONS.AUTO_UPDATE_DECLINED,
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function doCancelUpgrade() {
|
||||
|
@ -197,7 +190,6 @@ export function doCheckUpgradeAvailable() {
|
|||
type: ACTIONS.CHECK_UPGRADE_START,
|
||||
});
|
||||
|
||||
if (["win32", "darwin"].includes(process.platform)) {
|
||||
// On Windows and Mac, updates happen silently through
|
||||
// electron-updater.
|
||||
const autoUpdateDeclined = selectAutoUpdateDeclined(state);
|
||||
|
@ -205,39 +197,6 @@ export function doCheckUpgradeAvailable() {
|
|||
if (!autoUpdateDeclined) {
|
||||
autoUpdater.checkForUpdates();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const success = ({ remoteVersion, upgradeAvailable }) => {
|
||||
dispatch({
|
||||
type: ACTIONS.CHECK_UPGRADE_SUCCESS,
|
||||
data: {
|
||||
upgradeAvailable,
|
||||
remoteVersion,
|
||||
},
|
||||
});
|
||||
|
||||
if (
|
||||
upgradeAvailable &&
|
||||
!selectCurrentModal(state) &&
|
||||
(!selectIsUpgradeSkipped(state) || remoteVersion !== selectRemoteVersion(state))
|
||||
) {
|
||||
dispatch({
|
||||
type: ACTIONS.OPEN_MODAL,
|
||||
data: {
|
||||
modal: MODALS.UPGRADE,
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const fail = () => {
|
||||
dispatch({
|
||||
type: ACTIONS.CHECK_UPGRADE_FAIL,
|
||||
});
|
||||
};
|
||||
|
||||
Lbry.getAppVersionInfo().then(success, fail);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ import * as ACTIONS from 'constants/action_types';
|
|||
import * as SETTINGS from 'constants/settings';
|
||||
import Fs from 'fs';
|
||||
import Http from 'http';
|
||||
|
||||
import Lbry from 'lbry';
|
||||
import moment from 'moment';
|
||||
|
||||
|
@ -54,6 +53,20 @@ export function doGetThemes() {
|
|||
};
|
||||
}
|
||||
|
||||
export function doUpdateIsNight() {
|
||||
const momentNow = moment();
|
||||
return {
|
||||
type: ACTIONS.UPDATE_IS_NIGHT,
|
||||
data: {
|
||||
isNight: (() => {
|
||||
const startNightMoment = moment('19:00', 'HH:mm');
|
||||
const endNightMoment = moment('8:00', 'HH:mm');
|
||||
return !(momentNow.isAfter(endNightMoment) && momentNow.isBefore(startNightMoment));
|
||||
})(),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function doUpdateIsNightAsync() {
|
||||
return dispatch => {
|
||||
dispatch(doUpdateIsNight());
|
||||
|
@ -64,19 +77,6 @@ export function doUpdateIsNightAsync() {
|
|||
};
|
||||
}
|
||||
|
||||
export function doUpdateIsNight() {
|
||||
const momentNow = moment();
|
||||
return {
|
||||
type: ACTIONS.UPDATE_IS_NIGHT,
|
||||
data: { isNight: (() => {
|
||||
const startNightMoment = moment('19:00', 'HH:mm');
|
||||
const endNightMoment = moment('8:00', 'HH:mm');
|
||||
return !(momentNow.isAfter(endNightMoment) && momentNow.isBefore(startNightMoment));
|
||||
})()
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function doDownloadLanguage(langFile) {
|
||||
return dispatch => {
|
||||
const destinationPath = `${app.i18n.directory}/${langFile}`;
|
||||
|
|
Loading…
Reference in a new issue