2019-02-22 06:01:59 +01:00
|
|
|
// @if TARGET='app'
|
2018-03-16 00:04:15 +01:00
|
|
|
import { execSync } from 'child_process';
|
2018-03-08 00:03:45 +01:00
|
|
|
import isDev from 'electron-is-dev';
|
2017-12-28 00:48:11 +01:00
|
|
|
import { ipcRenderer, remote } from 'electron';
|
2019-02-22 06:01:59 +01:00
|
|
|
// @endif
|
2019-03-05 05:46:57 +01:00
|
|
|
import path from 'path';
|
2022-07-12 12:17:50 +02:00
|
|
|
import { MINIMUM_VERSION, IGNORE_MINIMUM_VERSION, URL } from 'config';
|
2018-11-07 23:44:38 +01:00
|
|
|
import * as ACTIONS from 'constants/action_types';
|
2018-10-29 18:23:53 +01:00
|
|
|
import * as MODALS from 'constants/modal_types';
|
2021-10-17 10:36:14 +02:00
|
|
|
import * as SETTINGS from 'constants/settings';
|
|
|
|
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
|
|
|
|
import * as SHARED_PREFERENCES from 'constants/shared_preferences';
|
|
|
|
import Lbry from 'lbry';
|
|
|
|
import { doFetchChannelListMine, doFetchCollectionListMine, doCheckPendingClaims } from 'redux/actions/claims';
|
2022-05-04 15:07:51 +02:00
|
|
|
import { selectClaimForUri, selectClaimIsMineForUri } from 'redux/selectors/claims';
|
2021-10-17 10:36:14 +02:00
|
|
|
import { doFetchFileInfos } from 'redux/actions/file_info';
|
|
|
|
import { doClearSupport, doBalanceSubscribe } from 'redux/actions/wallet';
|
|
|
|
import { doClearPublish } from 'redux/actions/publish';
|
2021-01-11 20:19:54 +01:00
|
|
|
import { Lbryio } from 'lbryinc';
|
2020-07-23 16:22:57 +02:00
|
|
|
import { doToast, doError, doNotificationList } from 'redux/actions/notifications';
|
2021-11-01 19:51:23 +01:00
|
|
|
import pushNotifications from '$web/src/push-notifications';
|
2020-10-05 20:31:51 +02:00
|
|
|
|
2018-04-18 06:03:01 +02:00
|
|
|
import Native from 'native';
|
2020-02-26 03:04:43 +01:00
|
|
|
import {
|
|
|
|
doFetchDaemonSettings,
|
|
|
|
doSetAutoLaunch,
|
2020-07-10 23:04:36 +02:00
|
|
|
doSetDaemonSetting,
|
2020-03-24 18:57:17 +01:00
|
|
|
doFindFFmpeg,
|
|
|
|
doGetDaemonStatus,
|
2020-02-26 03:04:43 +01:00
|
|
|
} from 'redux/actions/settings';
|
2017-04-07 07:15:22 +02:00
|
|
|
import {
|
2017-12-28 00:48:11 +01:00
|
|
|
selectIsUpgradeSkipped,
|
2017-04-07 07:15:22 +02:00
|
|
|
selectUpdateUrl,
|
|
|
|
selectUpgradeDownloadItem,
|
2017-12-28 00:48:11 +01:00
|
|
|
selectUpgradeDownloadPath,
|
2017-07-29 01:31:10 +02:00
|
|
|
selectUpgradeFilename,
|
2018-01-17 11:50:02 +01:00
|
|
|
selectAutoUpdateDeclined,
|
2018-03-15 01:22:54 +01:00
|
|
|
selectRemoteVersion,
|
2018-08-06 19:25:30 +02:00
|
|
|
selectUpgradeTimer,
|
2018-11-28 17:58:47 +01:00
|
|
|
selectModal,
|
2020-02-19 07:31:40 +01:00
|
|
|
selectAllowAnalytics,
|
2022-04-04 14:13:15 +02:00
|
|
|
selectAppDrawerOpen,
|
2017-12-21 18:32:51 +01:00
|
|
|
} from 'redux/selectors/app';
|
2021-11-23 05:29:04 +01:00
|
|
|
import { selectDaemonSettings, selectClientSetting } from 'redux/selectors/settings';
|
2020-11-10 06:21:04 +01:00
|
|
|
import { selectUser, selectUserVerifiedEmail } from 'redux/selectors/user';
|
2021-12-23 09:27:03 +01:00
|
|
|
import { doSetPrefsReady, doPreferenceGet, doPopulateSharedUserState, syncInvalidated } from 'redux/actions/sync';
|
2020-06-15 22:33:03 +02:00
|
|
|
import { doAuthenticate } from 'redux/actions/user';
|
2018-09-24 05:44:42 +02:00
|
|
|
import { lbrySettings as config, version as appVersion } from 'package.json';
|
2022-05-26 04:44:26 +02:00
|
|
|
import analytics from 'analytics';
|
2020-11-13 20:42:32 +01:00
|
|
|
import { doSignOutCleanup } from 'util/saved-passwords';
|
2022-05-26 04:44:26 +02:00
|
|
|
import { LocalStorage, LS } from 'util/storage';
|
2021-03-10 19:34:21 +01:00
|
|
|
import { doNotificationSocketConnect } from 'redux/actions/websocket';
|
2020-07-10 23:04:36 +02:00
|
|
|
import { stringifyServerParam, shouldSetSetting } from 'util/sync-settings';
|
2017-12-21 18:32:51 +01:00
|
|
|
|
2019-02-22 06:01:59 +01:00
|
|
|
// @if TARGET='app'
|
2017-12-08 13:14:37 +01:00
|
|
|
const { autoUpdater } = remote.require('electron-updater');
|
2017-12-21 18:32:51 +01:00
|
|
|
const { download } = remote.require('electron-dl');
|
|
|
|
const Fs = remote.require('fs');
|
2019-02-22 06:01:59 +01:00
|
|
|
// @endif
|
2017-12-13 22:36:30 +01:00
|
|
|
|
2017-11-16 22:39:10 +01:00
|
|
|
const CHECK_UPGRADE_INTERVAL = 10 * 60 * 1000;
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2018-11-28 17:58:47 +01:00
|
|
|
export function doOpenModal(id, modalProps = {}) {
|
|
|
|
return {
|
|
|
|
type: ACTIONS.SHOW_MODAL,
|
|
|
|
data: {
|
|
|
|
id,
|
|
|
|
modalProps,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function doHideModal() {
|
|
|
|
return {
|
|
|
|
type: ACTIONS.HIDE_MODAL,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-04-07 07:15:22 +02:00
|
|
|
export function doUpdateDownloadProgress(percent) {
|
|
|
|
return {
|
2017-12-21 18:32:51 +01:00
|
|
|
type: ACTIONS.UPGRADE_DOWNLOAD_PROGRESSED,
|
2017-04-07 07:15:22 +02:00
|
|
|
data: {
|
2017-12-13 22:36:30 +01:00
|
|
|
percent,
|
2017-06-06 23:19:12 +02:00
|
|
|
},
|
|
|
|
};
|
2017-04-07 07:15:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function doSkipUpgrade() {
|
|
|
|
return {
|
2017-12-21 18:32:51 +01:00
|
|
|
type: ACTIONS.SKIP_UPGRADE,
|
2017-06-06 23:19:12 +02:00
|
|
|
};
|
2017-04-07 07:15:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function doStartUpgrade() {
|
2017-12-28 00:48:11 +01:00
|
|
|
return (dispatch, getState) => {
|
2017-06-06 23:19:12 +02:00
|
|
|
const state = getState();
|
|
|
|
const upgradeDownloadPath = selectUpgradeDownloadPath(state);
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
ipcRenderer.send('upgrade', upgradeDownloadPath);
|
2017-06-06 23:19:12 +02:00
|
|
|
};
|
2017-04-07 07:15:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function doDownloadUpgrade() {
|
2017-12-28 00:48:11 +01:00
|
|
|
return (dispatch, getState) => {
|
2019-02-22 06:01:59 +01:00
|
|
|
// @if TARGET='app'
|
2017-06-06 23:19:12 +02:00
|
|
|
const state = getState();
|
2017-04-07 07:15:22 +02:00
|
|
|
// Make a new directory within temp directory so the filename is guaranteed to be available
|
2018-03-08 00:03:45 +01:00
|
|
|
const dir = Fs.mkdtempSync(remote.app.getPath('temp') + path.sep);
|
2017-12-21 18:32:51 +01:00
|
|
|
const upgradeFilename = selectUpgradeFilename(state);
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2017-12-13 22:36:30 +01:00
|
|
|
const options = {
|
2021-03-10 19:34:21 +01:00
|
|
|
onProgress: (p) => dispatch(doUpdateDownloadProgress(Math.round(p * 100))),
|
2017-04-07 07:15:22 +02:00
|
|
|
directory: dir,
|
|
|
|
};
|
2021-03-10 19:34:21 +01:00
|
|
|
download(remote.getCurrentWindow(), selectUpdateUrl(state), options).then((downloadItem) => {
|
2017-12-21 18:32:51 +01:00
|
|
|
/**
|
|
|
|
* TODO: get the download path directly from the download object. It should just be
|
|
|
|
* downloadItem.getSavePath(), but the copy on the main process is being garbage collected
|
|
|
|
* too soon.
|
|
|
|
*/
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
dispatch({
|
|
|
|
type: ACTIONS.UPGRADE_DOWNLOAD_COMPLETED,
|
|
|
|
data: {
|
|
|
|
downloadItem,
|
2018-03-08 00:03:45 +01:00
|
|
|
path: path.join(dir, upgradeFilename),
|
2017-12-21 18:32:51 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
2017-04-07 07:15:22 +02:00
|
|
|
|
|
|
|
dispatch({
|
2017-12-21 18:32:51 +01:00
|
|
|
type: ACTIONS.UPGRADE_DOWNLOAD_STARTED,
|
2017-06-06 23:19:12 +02:00
|
|
|
});
|
2018-10-29 18:23:53 +01:00
|
|
|
dispatch(doHideModal());
|
2018-11-28 17:58:47 +01:00
|
|
|
dispatch(doOpenModal(MODALS.DOWNLOADING));
|
2019-02-22 06:01:59 +01:00
|
|
|
// @endif
|
2017-06-06 23:19:12 +02:00
|
|
|
};
|
2017-04-07 07:15:22 +02:00
|
|
|
}
|
|
|
|
|
2018-03-15 01:22:54 +01:00
|
|
|
export function doDownloadUpgradeRequested() {
|
|
|
|
// This means the user requested an upgrade by clicking the "upgrade" button in the navbar.
|
|
|
|
// If on Mac and Windows, we do some new behavior for the auto-update system.
|
|
|
|
// This will probably be reorganized once we get auto-update going on Linux and remove
|
|
|
|
// the old logic.
|
|
|
|
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2020-01-15 05:34:28 +01:00
|
|
|
if (['win32', 'darwin'].includes(process.platform) || !!process.env.APPIMAGE) {
|
2018-03-15 01:22:54 +01:00
|
|
|
// electron-updater behavior
|
2019-10-03 00:57:11 +02:00
|
|
|
dispatch(doOpenModal(MODALS.AUTO_UPDATE_DOWNLOADED));
|
2018-03-15 01:22:54 +01:00
|
|
|
} else {
|
|
|
|
// Old behavior for Linux
|
|
|
|
dispatch(doDownloadUpgrade());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-08-07 16:02:11 +02:00
|
|
|
export function doClearUpgradeTimer() {
|
2018-08-07 15:33:06 +02:00
|
|
|
return (dispatch, getState) => {
|
|
|
|
const state = getState();
|
2018-08-07 16:02:11 +02:00
|
|
|
|
|
|
|
if (selectUpgradeTimer(state)) {
|
|
|
|
clearInterval(selectUpgradeTimer(state));
|
|
|
|
dispatch({
|
|
|
|
type: ACTIONS.CLEAR_UPGRADE_TIMER,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function doAutoUpdate() {
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2018-01-16 06:38:23 +01:00
|
|
|
dispatch({
|
|
|
|
type: ACTIONS.AUTO_UPDATE_DOWNLOADED,
|
|
|
|
});
|
|
|
|
|
2018-11-28 17:58:47 +01:00
|
|
|
dispatch(doOpenModal(MODALS.AUTO_UPDATE_DOWNLOADED));
|
2018-08-07 15:33:06 +02:00
|
|
|
|
2018-08-07 16:02:11 +02:00
|
|
|
dispatch(doClearUpgradeTimer());
|
2017-12-08 13:14:37 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-01-17 11:50:02 +01:00
|
|
|
export function doAutoUpdateDeclined() {
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2018-08-07 16:02:11 +02:00
|
|
|
dispatch(doClearUpgradeTimer());
|
2018-08-06 19:25:30 +02:00
|
|
|
|
2018-01-17 11:50:02 +01:00
|
|
|
dispatch({
|
|
|
|
type: ACTIONS.AUTO_UPDATE_DECLINED,
|
|
|
|
});
|
2018-02-24 01:24:00 +01:00
|
|
|
};
|
2018-01-17 11:50:02 +01:00
|
|
|
}
|
|
|
|
|
2017-04-07 07:15:22 +02:00
|
|
|
export function doCancelUpgrade() {
|
2017-12-28 00:48:11 +01:00
|
|
|
return (dispatch, getState) => {
|
2017-06-06 23:19:12 +02:00
|
|
|
const state = getState();
|
|
|
|
const upgradeDownloadItem = selectUpgradeDownloadItem(state);
|
2017-04-07 07:15:22 +02:00
|
|
|
|
|
|
|
if (upgradeDownloadItem) {
|
|
|
|
/*
|
|
|
|
* Right now the remote reference to the download item gets garbage collected as soon as the
|
|
|
|
* the download is over (maybe even earlier), so trying to cancel a finished download may
|
|
|
|
* throw an error.
|
|
|
|
*/
|
|
|
|
try {
|
|
|
|
upgradeDownloadItem.cancel();
|
|
|
|
} catch (err) {
|
2019-07-23 10:05:51 +02:00
|
|
|
console.error(err); // eslint-disable-line no-console
|
2017-04-07 07:15:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-21 18:32:51 +01:00
|
|
|
dispatch({ type: ACTIONS.UPGRADE_CANCELLED });
|
2017-06-06 23:19:12 +02:00
|
|
|
};
|
2017-04-07 07:15:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function doCheckUpgradeAvailable() {
|
2017-12-28 00:48:11 +01:00
|
|
|
return (dispatch, getState) => {
|
2017-06-06 23:19:12 +02:00
|
|
|
const state = getState();
|
2017-11-15 02:50:21 +01:00
|
|
|
dispatch({
|
2017-12-21 18:32:51 +01:00
|
|
|
type: ACTIONS.CHECK_UPGRADE_START,
|
2017-11-15 02:50:21 +01:00
|
|
|
});
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2020-01-15 05:34:28 +01:00
|
|
|
if (['win32', 'darwin'].includes(process.platform) || !!process.env.APPIMAGE) {
|
|
|
|
// On Windows, Mac, and AppImage, updates happen silently through
|
2018-03-15 01:22:54 +01:00
|
|
|
// electron-updater.
|
|
|
|
const autoUpdateDeclined = selectAutoUpdateDeclined(state);
|
2018-01-24 21:42:49 +01:00
|
|
|
|
2018-03-15 01:22:54 +01:00
|
|
|
if (!autoUpdateDeclined && !isDev) {
|
|
|
|
autoUpdater.checkForUpdates();
|
|
|
|
}
|
|
|
|
return;
|
2017-12-08 13:14:37 +01:00
|
|
|
}
|
2018-03-15 01:22:54 +01:00
|
|
|
|
|
|
|
const success = ({ remoteVersion, upgradeAvailable }) => {
|
|
|
|
dispatch({
|
|
|
|
type: ACTIONS.CHECK_UPGRADE_SUCCESS,
|
|
|
|
data: {
|
|
|
|
upgradeAvailable,
|
|
|
|
remoteVersion,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
if (
|
|
|
|
upgradeAvailable &&
|
2018-11-28 17:58:47 +01:00
|
|
|
!selectModal(state) &&
|
2018-03-15 01:22:54 +01:00
|
|
|
(!selectIsUpgradeSkipped(state) || remoteVersion !== selectRemoteVersion(state))
|
|
|
|
) {
|
2018-11-28 17:58:47 +01:00
|
|
|
dispatch(doOpenModal(MODALS.UPGRADE));
|
2018-03-15 01:22:54 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const fail = () => {
|
|
|
|
dispatch({
|
|
|
|
type: ACTIONS.CHECK_UPGRADE_FAIL,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2018-04-18 06:03:01 +02:00
|
|
|
Native.getAppVersionInfo().then(success, fail);
|
2017-11-15 02:50:21 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Initiate a timer that will check for an app upgrade every 10 minutes.
|
|
|
|
*/
|
2017-11-16 22:39:10 +01:00
|
|
|
export function doCheckUpgradeSubscribe() {
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2019-05-07 23:38:29 +02:00
|
|
|
const checkUpgradeTimer = setInterval(() => dispatch(doCheckUpgradeAvailable()), CHECK_UPGRADE_INTERVAL);
|
2017-11-15 02:50:21 +01:00
|
|
|
dispatch({
|
2017-12-21 18:32:51 +01:00
|
|
|
type: ACTIONS.CHECK_UPGRADE_SUBSCRIBE,
|
2017-11-15 02:50:21 +01:00
|
|
|
data: { checkUpgradeTimer },
|
2017-04-07 07:15:22 +02:00
|
|
|
});
|
2017-06-06 23:19:12 +02:00
|
|
|
};
|
2017-04-07 07:15:22 +02:00
|
|
|
}
|
|
|
|
|
2022-07-05 15:14:32 +02:00
|
|
|
export function doMinVersionCheck() {
|
|
|
|
return (dispatch) => {
|
|
|
|
fetch(`${URL}/$/minVersion/v1/get`)
|
|
|
|
.then((response) => response.json())
|
|
|
|
.then((json) => {
|
|
|
|
if (json?.status === 'success' && json?.data && MINIMUM_VERSION) {
|
|
|
|
const liveMinimumVersion = Number(json.data);
|
|
|
|
if (liveMinimumVersion > MINIMUM_VERSION) {
|
|
|
|
dispatch({ type: ACTIONS.RELOAD_REQUIRED });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
console.error(err);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function doMinVersionSubscribe() {
|
|
|
|
return (dispatch) => {
|
2022-07-12 12:17:50 +02:00
|
|
|
if (IGNORE_MINIMUM_VERSION === 'true') {
|
|
|
|
return;
|
|
|
|
}
|
2022-07-05 15:14:32 +02:00
|
|
|
|
2022-07-12 12:17:50 +02:00
|
|
|
dispatch(doMinVersionCheck());
|
2022-07-05 15:14:32 +02:00
|
|
|
const CHECK_UPGRADE_INTERVAL_MS = 60 * 60 * 1000;
|
|
|
|
setInterval(() => dispatch(doMinVersionCheck()), CHECK_UPGRADE_INTERVAL_MS);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-07-19 23:05:08 +02:00
|
|
|
export function doCheckDaemonVersion() {
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2019-02-22 06:01:59 +01:00
|
|
|
// @if TARGET='app'
|
2017-12-21 18:32:51 +01:00
|
|
|
Lbry.version().then(({ lbrynet_version: lbrynetVersion }) => {
|
2018-07-11 06:14:50 +02:00
|
|
|
// Avoid the incompatible daemon modal if running in dev mode
|
2019-04-15 05:45:13 +02:00
|
|
|
// Lets you run a different daemon than the one specified in package.json
|
2020-02-05 19:01:07 +01:00
|
|
|
if (config.lbrynetDaemonVersion === lbrynetVersion || process.env.NODE_ENV !== 'production') {
|
2018-07-11 06:14:50 +02:00
|
|
|
return dispatch({
|
2018-05-11 01:06:41 +02:00
|
|
|
type: ACTIONS.DAEMON_VERSION_MATCH,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-07-19 23:05:08 +02:00
|
|
|
dispatch({
|
2018-05-11 01:06:41 +02:00
|
|
|
type: ACTIONS.DAEMON_VERSION_MISMATCH,
|
2017-07-19 23:05:08 +02:00
|
|
|
});
|
2020-02-05 19:01:07 +01:00
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
|
|
return dispatch(doOpenModal(MODALS.INCOMPATIBLE_DAEMON));
|
|
|
|
}
|
2017-07-19 23:05:08 +02:00
|
|
|
});
|
2019-02-22 06:01:59 +01:00
|
|
|
// @endif
|
|
|
|
// @if TARGET='web'
|
|
|
|
dispatch({
|
|
|
|
type: ACTIONS.DAEMON_VERSION_MATCH,
|
|
|
|
});
|
|
|
|
// @endif
|
2017-07-19 23:05:08 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-07-18 21:48:30 +02:00
|
|
|
export function doNotifyEncryptWallet() {
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2018-11-28 17:58:47 +01:00
|
|
|
dispatch(doOpenModal(MODALS.WALLET_ENCRYPT));
|
2018-07-18 21:48:30 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function doNotifyDecryptWallet() {
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2018-11-28 17:58:47 +01:00
|
|
|
dispatch(doOpenModal(MODALS.WALLET_DECRYPT));
|
2018-07-18 21:48:30 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function doNotifyUnlockWallet() {
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2018-11-28 17:58:47 +01:00
|
|
|
dispatch(doOpenModal(MODALS.WALLET_UNLOCK));
|
2018-07-18 21:48:30 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-09-26 18:28:08 +02:00
|
|
|
export function doNotifyForgetPassword(props) {
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2019-09-26 18:28:08 +02:00
|
|
|
dispatch(doOpenModal(MODALS.WALLET_PASSWORD_UNSAVE, props));
|
2019-08-20 14:29:59 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-04-07 07:15:22 +02:00
|
|
|
export function doAlertError(errorList) {
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2018-11-28 17:58:47 +01:00
|
|
|
dispatch(doError(errorList));
|
2017-06-06 23:19:12 +02:00
|
|
|
};
|
2017-04-07 07:15:22 +02:00
|
|
|
}
|
|
|
|
|
2020-10-05 20:31:51 +02:00
|
|
|
export function doAlertWaitingForSync() {
|
2020-11-10 06:21:04 +01:00
|
|
|
return (dispatch, getState) => {
|
|
|
|
const state = getState();
|
|
|
|
const authenticated = selectUserVerifiedEmail(state);
|
|
|
|
|
2020-10-05 20:31:51 +02:00
|
|
|
dispatch(
|
|
|
|
doToast({
|
2020-11-10 06:21:04 +01:00
|
|
|
message:
|
|
|
|
!authenticated && IS_WEB
|
|
|
|
? __('Sign in or create an account to change this setting.')
|
|
|
|
: __('Please wait a bit, we are still getting your account ready.'),
|
2020-10-05 20:31:51 +02:00
|
|
|
isError: false,
|
|
|
|
})
|
|
|
|
);
|
2020-11-10 06:21:04 +01:00
|
|
|
};
|
2020-10-05 20:31:51 +02:00
|
|
|
}
|
|
|
|
|
2017-04-22 15:17:01 +02:00
|
|
|
export function doDaemonReady() {
|
2017-12-28 00:48:11 +01:00
|
|
|
return (dispatch, getState) => {
|
2017-11-16 22:39:10 +01:00
|
|
|
const state = getState();
|
2020-02-24 23:02:03 +01:00
|
|
|
|
|
|
|
// TODO: call doFetchDaemonSettings, then get usage data, and call doAuthenticate once they are loaded into the store
|
2022-05-26 04:44:26 +02:00
|
|
|
const shareUsageData = IS_WEB || LocalStorage.getItem(LS.SHARE_INTERNAL) === 'true';
|
2020-02-24 18:07:49 +01:00
|
|
|
|
2020-03-12 17:36:45 +01:00
|
|
|
dispatch(
|
2020-06-04 19:43:36 +02:00
|
|
|
doAuthenticate(
|
|
|
|
appVersion,
|
|
|
|
shareUsageData,
|
2021-03-10 19:34:21 +01:00
|
|
|
(status) => {
|
2020-06-04 19:43:36 +02:00
|
|
|
const trendingAlgorithm =
|
|
|
|
status &&
|
|
|
|
status.wallet &&
|
|
|
|
status.wallet.connected_features &&
|
|
|
|
status.wallet.connected_features.trending_algorithm;
|
|
|
|
|
|
|
|
if (trendingAlgorithm) {
|
|
|
|
analytics.trendingAlgorithmEvent(trendingAlgorithm);
|
|
|
|
}
|
|
|
|
},
|
2021-12-20 06:35:32 +01:00
|
|
|
undefined
|
2020-06-04 19:43:36 +02:00
|
|
|
)
|
2020-03-12 17:36:45 +01:00
|
|
|
);
|
2017-12-21 18:32:51 +01:00
|
|
|
dispatch({ type: ACTIONS.DAEMON_READY });
|
2019-03-29 15:23:32 +01:00
|
|
|
|
2019-02-22 06:01:59 +01:00
|
|
|
// @if TARGET='app'
|
2019-04-15 05:45:13 +02:00
|
|
|
dispatch(doBalanceSubscribe());
|
2019-11-18 19:30:15 +01:00
|
|
|
dispatch(doSetAutoLaunch());
|
2020-03-24 18:57:17 +01:00
|
|
|
dispatch(doFindFFmpeg());
|
|
|
|
dispatch(doGetDaemonStatus());
|
2019-09-26 18:07:11 +02:00
|
|
|
dispatch(doFetchDaemonSettings());
|
2020-04-24 15:51:00 +02:00
|
|
|
dispatch(doFetchFileInfos());
|
2017-11-16 22:39:10 +01:00
|
|
|
if (!selectIsUpgradeSkipped(state)) {
|
|
|
|
dispatch(doCheckUpgradeAvailable());
|
|
|
|
}
|
|
|
|
dispatch(doCheckUpgradeSubscribe());
|
2019-02-22 06:01:59 +01:00
|
|
|
// @endif
|
2017-06-08 02:56:52 +02:00
|
|
|
};
|
2017-04-22 15:17:01 +02:00
|
|
|
}
|
2017-05-23 09:21:21 +02:00
|
|
|
|
2017-06-16 07:43:43 +02:00
|
|
|
export function doClearCache() {
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2019-07-23 10:05:51 +02:00
|
|
|
// Need to update this to work with new version of redux-persist
|
|
|
|
// Leaving for now
|
|
|
|
// const reducersToClear = whiteListedReducers.filter(reducerKey => reducerKey !== 'tags');
|
|
|
|
// window.cacheStore.purge(reducersToClear);
|
2020-03-27 17:49:41 +01:00
|
|
|
window.sessionStorage.clear();
|
2019-10-30 08:51:41 +01:00
|
|
|
dispatch(doClearSupport());
|
2020-03-27 17:49:41 +01:00
|
|
|
window.location.reload();
|
2019-10-04 19:29:57 +02:00
|
|
|
return dispatch(doClearPublish());
|
2017-06-16 07:43:43 +02:00
|
|
|
};
|
|
|
|
}
|
2017-07-19 23:05:08 +02:00
|
|
|
|
2017-07-29 21:22:17 +02:00
|
|
|
export function doQuit() {
|
2017-12-28 00:48:11 +01:00
|
|
|
return () => {
|
2019-02-22 06:01:59 +01:00
|
|
|
// @if TARGET='app'
|
2017-07-19 23:05:08 +02:00
|
|
|
remote.app.quit();
|
2019-02-22 06:01:59 +01:00
|
|
|
// @endif
|
2017-07-19 23:05:08 +02:00
|
|
|
};
|
|
|
|
}
|
2017-08-25 21:05:00 +02:00
|
|
|
|
2018-03-16 00:04:15 +01:00
|
|
|
export function doQuitAnyDaemon() {
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2019-02-22 06:01:59 +01:00
|
|
|
// @if TARGET='app'
|
2019-02-18 18:33:02 +01:00
|
|
|
Lbry.stop()
|
|
|
|
.catch(() => {
|
|
|
|
try {
|
|
|
|
if (process.platform === 'win32') {
|
|
|
|
execSync('taskkill /im lbrynet.exe /t /f');
|
|
|
|
} else {
|
|
|
|
execSync('pkill lbrynet');
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
dispatch(doAlertError(`Quitting daemon failed due to: ${error.message}`));
|
|
|
|
}
|
2019-02-22 06:01:59 +01:00
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
dispatch(doQuit());
|
2019-02-18 18:33:02 +01:00
|
|
|
});
|
2019-02-22 06:01:59 +01:00
|
|
|
// @endif
|
2018-03-16 00:04:15 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-08-25 21:05:00 +02:00
|
|
|
export function doChangeVolume(volume) {
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2017-08-25 21:05:00 +02:00
|
|
|
dispatch({
|
2017-12-21 18:32:51 +01:00
|
|
|
type: ACTIONS.VOLUME_CHANGED,
|
2017-08-25 21:05:00 +02:00
|
|
|
data: {
|
|
|
|
volume,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
2017-12-23 03:09:06 +01:00
|
|
|
|
2019-07-27 23:17:25 +02:00
|
|
|
export function doChangeMute(muted) {
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2019-07-27 23:17:25 +02:00
|
|
|
dispatch({
|
|
|
|
type: ACTIONS.VOLUME_MUTED,
|
|
|
|
data: {
|
|
|
|
muted,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-11-07 23:44:38 +01:00
|
|
|
export function doClickCommentButton() {
|
|
|
|
return {
|
|
|
|
type: ACTIONS.ADD_COMMENT,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-02-21 23:45:17 +01:00
|
|
|
export function doToggleSearchExpanded() {
|
|
|
|
return {
|
|
|
|
type: ACTIONS.TOGGLE_SEARCH_EXPANDED,
|
|
|
|
};
|
|
|
|
}
|
2019-08-14 05:04:08 +02:00
|
|
|
|
|
|
|
export function doAnalyticsView(uri, timeToStart) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const state = getState();
|
2021-11-11 05:48:10 +01:00
|
|
|
const claim = selectClaimForUri(state, uri);
|
|
|
|
const { txid, nout, claim_id: claimId } = claim;
|
2022-02-15 16:35:39 +01:00
|
|
|
const claimIsMine = selectClaimIsMineForUri(state, uri);
|
2019-08-14 05:04:08 +02:00
|
|
|
const outpoint = `${txid}:${nout}`;
|
|
|
|
|
|
|
|
if (claimIsMine) {
|
2019-09-21 18:45:52 +02:00
|
|
|
return Promise.resolve();
|
2019-08-14 05:04:08 +02:00
|
|
|
}
|
|
|
|
|
2019-09-18 20:41:20 +02:00
|
|
|
return analytics.apiLogView(uri, outpoint, claimId, timeToStart);
|
2019-08-14 05:04:08 +02:00
|
|
|
};
|
|
|
|
}
|
2019-09-26 18:07:11 +02:00
|
|
|
|
2020-08-07 22:59:20 +02:00
|
|
|
export function doAnalyticsBuffer(uri, bufferData) {
|
|
|
|
return (dispatch, getState) => {
|
2022-05-17 16:47:44 +02:00
|
|
|
const isLivestream = bufferData.isLivestream;
|
2020-08-07 22:59:20 +02:00
|
|
|
const state = getState();
|
2021-11-11 05:48:10 +01:00
|
|
|
const claim = selectClaimForUri(state, uri);
|
2020-08-07 22:59:20 +02:00
|
|
|
const user = selectUser(state);
|
|
|
|
const {
|
|
|
|
value: { video, audio, source },
|
|
|
|
} = claim;
|
2022-05-17 16:47:44 +02:00
|
|
|
const timeAtBuffer = isLivestream ? 0 : parseInt(bufferData.currentTime * 1000);
|
2020-08-27 20:18:45 +02:00
|
|
|
const bufferDuration = parseInt(bufferData.secondsToLoad * 1000);
|
2022-05-17 16:47:44 +02:00
|
|
|
const fileDurationInSeconds = isLivestream ? 0 : (video && video.duration) || (audio && audio.duration);
|
|
|
|
const fileSize = isLivestream ? 0 : source.size; // size in bytes
|
|
|
|
const fileSizeInBits = isLivestream ? '0' : fileSize * 8;
|
|
|
|
const bitRate = isLivestream ? bufferData.bitrateAsBitsPerSecond : parseInt(fileSizeInBits / fileDurationInSeconds);
|
2021-06-18 00:52:21 +02:00
|
|
|
const userId = user && user.id.toString();
|
2021-10-06 20:59:33 +02:00
|
|
|
// if there's a logged in user, send buffer event data to watchman
|
2021-06-18 00:52:21 +02:00
|
|
|
if (userId) {
|
|
|
|
analytics.videoBufferEvent(claim, {
|
2022-05-17 16:47:44 +02:00
|
|
|
isLivestream,
|
2021-06-18 00:52:21 +02:00
|
|
|
timeAtBuffer,
|
|
|
|
bufferDuration,
|
|
|
|
bitRate,
|
|
|
|
userId,
|
|
|
|
duration: fileDurationInSeconds,
|
|
|
|
playerPoweredBy: bufferData.playerPoweredBy,
|
|
|
|
readyState: bufferData.readyState,
|
|
|
|
});
|
|
|
|
}
|
2020-08-07 22:59:20 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-05-21 17:38:28 +02:00
|
|
|
export function doAnaltyicsPurchaseEvent(fileInfo) {
|
2021-03-10 19:34:21 +01:00
|
|
|
return (dispatch) => {
|
2020-05-21 17:38:28 +02:00
|
|
|
let purchasePrice = fileInfo.purchase_receipt && fileInfo.purchase_receipt.amount;
|
|
|
|
if (purchasePrice) {
|
|
|
|
const purchaseInt = Number(Number(purchasePrice).toFixed(0));
|
|
|
|
analytics.purchaseEvent(purchaseInt);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-09-26 18:07:11 +02:00
|
|
|
export function doSignIn() {
|
|
|
|
return (dispatch, getState) => {
|
2020-07-09 20:22:39 +02:00
|
|
|
const state = getState();
|
|
|
|
const user = selectUser(state);
|
2021-10-27 16:38:10 +02:00
|
|
|
|
2021-12-29 20:03:05 +01:00
|
|
|
if (pushNotifications.supported && user) {
|
2021-11-01 19:51:23 +01:00
|
|
|
pushNotifications.reconnect(user.id);
|
|
|
|
pushNotifications.validate(user.id);
|
|
|
|
}
|
2021-10-27 16:38:10 +02:00
|
|
|
|
2021-11-15 04:20:47 +01:00
|
|
|
dispatch(doNotificationSocketConnect(true));
|
2021-11-19 15:46:31 +01:00
|
|
|
dispatch(doNotificationList(null, false));
|
2021-06-25 00:06:08 +02:00
|
|
|
dispatch(doCheckPendingClaims());
|
2019-09-26 18:07:11 +02:00
|
|
|
dispatch(doBalanceSubscribe());
|
|
|
|
dispatch(doFetchChannelListMine());
|
wip
wip
wip - everything but publish, autoplay, and styling
collection publishing
add channel to collection publish
cleanup
wip
bump
clear mass add after success
move collection item management controls
redirect replace to published collection id
bump
playlist selector on create
bump
use new collection add ui element
bump
wip
gitignore
add content json
wip
bump
context add to playlist
basic collections page style pass wip
wip: edits, buttons, styles...
change fileAuthor to claimAuthor
update, pending bugfixes, delete modal progress, collection header, other bugfixes
bump
cleaning
show page bugfix
builtin collection headers
no playlists, no grid title
wip
style tweaks
use normal looking claim previews for collection tiles
add collection changes
style library previews
collection menulist for delete/view on library
delete modal works for unpublished
rearrange collection publish tabs
clean up collection publishing and items
show on odysee
begin collectoin edit header and css renaming
better thumbnails
bump
fix collection publish redirect
view collection in menu does something
copy and thumbs
list previews, pending, context menus, list page
enter to add collection, lists page empty state
playable lists only, delete feature, bump
put fileListDownloaded back
better collection titles
improve collection claim details
fix horiz more icon
fix up channel page
style, copy, bump
refactor preview overlay properties,
fix reposts showing as floppydisk
add watch later toast,
small overlay properties on wunderbar results,
fix collection actions buttons
bump
cleanup
cleaning, refactoring
bump
preview thumb styling, cleanup
support discover page lists search
sync, bump
bump, fix sync more
enforce builtin order for now
new lists page empty state
try to indicate unpublished edits in lists
bump
fix autoplay and linting
consts, fix autoplay
bugs
fixes
cleanup
fix, bump
lists experimental ui, fixes
refactor listIndex out
hack in collection fallback thumb
bump
2021-02-06 08:03:51 +01:00
|
|
|
dispatch(doFetchCollectionListMine());
|
2019-09-26 18:07:11 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function doSignOut() {
|
2021-10-27 16:38:10 +02:00
|
|
|
return async (dispatch, getState) => {
|
|
|
|
const state = getState();
|
|
|
|
const user = selectUser(state);
|
|
|
|
try {
|
2021-12-29 20:03:05 +01:00
|
|
|
if (pushNotifications.supported && user) {
|
2021-11-01 19:51:23 +01:00
|
|
|
await pushNotifications.disconnect(user.id);
|
|
|
|
}
|
2021-10-27 16:38:10 +02:00
|
|
|
} finally {
|
|
|
|
Lbryio.call('user', 'signout')
|
|
|
|
.then(doSignOutCleanup)
|
|
|
|
.then(() => {
|
|
|
|
// @if TARGET='web'
|
2022-04-11 08:30:42 +02:00
|
|
|
return window.persistor.purge();
|
2021-10-27 16:38:10 +02:00
|
|
|
// @endif
|
|
|
|
})
|
2022-04-11 08:30:42 +02:00
|
|
|
.catch((err) => {
|
|
|
|
analytics.error(`\`doSignOut\`: ${err.message || err}`);
|
2021-10-27 16:38:10 +02:00
|
|
|
})
|
2022-04-11 08:30:42 +02:00
|
|
|
.finally(() => location.reload());
|
2021-10-27 16:38:10 +02:00
|
|
|
}
|
2019-09-26 18:07:11 +02:00
|
|
|
};
|
|
|
|
}
|
2019-10-15 23:23:51 +02:00
|
|
|
|
2020-02-19 07:31:40 +01:00
|
|
|
export function doSetWelcomeVersion(version) {
|
|
|
|
return {
|
|
|
|
type: ACTIONS.SET_WELCOME_VERSION,
|
|
|
|
data: version,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-07-10 23:04:36 +02:00
|
|
|
export function doSetHasNavigated() {
|
|
|
|
return {
|
|
|
|
type: ACTIONS.SET_HAS_NAVIGATED,
|
|
|
|
data: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-02-19 07:31:40 +01:00
|
|
|
export function doToggle3PAnalytics(allowParam, doNotDispatch) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const state = getState();
|
|
|
|
const allowState = selectAllowAnalytics(state);
|
2020-02-24 20:55:34 +01:00
|
|
|
const allow = allowParam !== undefined && allowParam !== null ? allowParam : allowState;
|
2020-02-19 07:31:40 +01:00
|
|
|
analytics.toggleThirdParty(allow);
|
|
|
|
if (!doNotDispatch) {
|
|
|
|
return dispatch({
|
|
|
|
type: ACTIONS.SET_ALLOW_ANALYTICS,
|
|
|
|
data: allow,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-12-23 09:27:03 +01:00
|
|
|
export function doGetAndPopulatePreferences(syncId /* ?: number */) {
|
2020-07-10 23:04:36 +02:00
|
|
|
const { SDK_SYNC_KEYS } = SHARED_PREFERENCES;
|
|
|
|
|
2020-02-19 07:31:40 +01:00
|
|
|
return (dispatch, getState) => {
|
2020-07-10 23:04:36 +02:00
|
|
|
const state = getState();
|
2021-11-23 05:29:04 +01:00
|
|
|
const syncEnabled = selectClientSetting(state, SETTINGS.ENABLE_SYNC);
|
2022-07-13 15:36:51 +02:00
|
|
|
const hasVerifiedEmail = selectUserVerifiedEmail(state);
|
2020-08-07 22:59:20 +02:00
|
|
|
let preferenceKey;
|
2022-07-13 15:36:51 +02:00
|
|
|
// TODO: the logic should match `runPreferences`, but since this function is
|
|
|
|
// only hit as a successful sync callback, it doesn't matter for now.
|
2020-07-10 23:04:36 +02:00
|
|
|
// @if TARGET='app'
|
2020-09-11 20:35:50 +02:00
|
|
|
preferenceKey = syncEnabled && hasVerifiedEmail ? 'shared' : 'local';
|
2020-07-10 23:04:36 +02:00
|
|
|
// @endif
|
|
|
|
// @if TARGET='web'
|
2020-08-07 22:59:20 +02:00
|
|
|
preferenceKey = 'shared';
|
2020-07-10 23:04:36 +02:00
|
|
|
// @endif
|
|
|
|
|
2019-12-11 21:09:27 +01:00
|
|
|
function successCb(savedPreferences) {
|
2020-07-10 23:04:36 +02:00
|
|
|
const successState = getState();
|
|
|
|
const daemonSettings = selectDaemonSettings(successState);
|
2019-12-11 21:09:27 +01:00
|
|
|
if (savedPreferences !== null) {
|
2021-12-23 09:27:03 +01:00
|
|
|
if (!syncInvalidated(getState, syncId)) {
|
|
|
|
dispatch(doPopulateSharedUserState(savedPreferences));
|
|
|
|
}
|
|
|
|
|
2020-02-19 07:31:40 +01:00
|
|
|
// @if TARGET='app'
|
2020-07-10 23:04:36 +02:00
|
|
|
const { settings } = savedPreferences.value;
|
2020-08-28 17:25:47 +02:00
|
|
|
if (settings) {
|
|
|
|
Object.entries(settings).forEach(([key, val]) => {
|
|
|
|
if (SDK_SYNC_KEYS.includes(key)) {
|
|
|
|
if (shouldSetSetting(key, val, daemonSettings[key])) {
|
|
|
|
if (key === DAEMON_SETTINGS.LBRYUM_SERVERS) {
|
|
|
|
const servers = stringifyServerParam(val);
|
|
|
|
dispatch(doSetDaemonSetting(key, servers, true));
|
|
|
|
} else {
|
|
|
|
dispatch(doSetDaemonSetting(key, val, true));
|
|
|
|
}
|
2020-07-10 23:04:36 +02:00
|
|
|
}
|
|
|
|
}
|
2020-08-28 17:25:47 +02:00
|
|
|
});
|
|
|
|
}
|
2020-02-19 07:31:40 +01:00
|
|
|
// @endif
|
2020-10-05 20:31:51 +02:00
|
|
|
} else {
|
|
|
|
dispatch(doSetPrefsReady());
|
2019-10-15 23:23:51 +02:00
|
|
|
}
|
2020-09-04 17:02:30 +02:00
|
|
|
return true;
|
2019-12-11 21:09:27 +01:00
|
|
|
}
|
2019-10-15 23:23:51 +02:00
|
|
|
|
2021-07-15 20:07:06 +02:00
|
|
|
function failCb(er) {
|
2020-11-13 20:42:32 +01:00
|
|
|
dispatch(
|
|
|
|
doToast({
|
|
|
|
isError: true,
|
|
|
|
message: __('Unable to load your saved preferences.'),
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: ACTIONS.SYNC_FATAL_ERROR,
|
2021-07-15 20:07:06 +02:00
|
|
|
error: er,
|
2019-12-11 21:09:27 +01:00
|
|
|
});
|
2020-11-13 20:42:32 +01:00
|
|
|
|
2020-09-04 17:02:30 +02:00
|
|
|
return false;
|
2019-12-11 21:09:27 +01:00
|
|
|
}
|
2020-01-02 17:30:27 +01:00
|
|
|
|
2020-11-12 19:32:18 +01:00
|
|
|
return dispatch(doPreferenceGet(preferenceKey, successCb, failCb));
|
2019-12-11 21:09:27 +01:00
|
|
|
};
|
|
|
|
}
|
2019-10-15 23:23:51 +02:00
|
|
|
|
2021-12-23 09:27:03 +01:00
|
|
|
export function doHandleSyncComplete(error, hasNewData, syncId) {
|
|
|
|
return (dispatch, getState) => {
|
2020-05-29 21:20:01 +02:00
|
|
|
if (!error) {
|
|
|
|
if (hasNewData) {
|
2021-12-23 09:27:03 +01:00
|
|
|
if (syncInvalidated(getState, syncId)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(doGetAndPopulatePreferences(syncId));
|
2020-03-24 22:19:39 +01:00
|
|
|
}
|
2021-07-15 20:07:06 +02:00
|
|
|
} else {
|
2022-04-04 14:13:15 +02:00
|
|
|
// eslint-disable-next-line no-console
|
2021-07-15 22:55:57 +02:00
|
|
|
console.error('Error in doHandleSyncComplete', error);
|
2019-10-15 23:23:51 +02:00
|
|
|
}
|
2020-05-29 21:20:01 +02:00
|
|
|
};
|
|
|
|
}
|
2019-10-15 23:23:51 +02:00
|
|
|
|
2020-09-04 22:11:28 +02:00
|
|
|
export function doToggleInterestedInYoutubeSync() {
|
|
|
|
return {
|
|
|
|
type: ACTIONS.TOGGLE_YOUTUBE_SYNC_INTEREST,
|
|
|
|
};
|
|
|
|
}
|
2020-11-09 18:22:38 +01:00
|
|
|
|
|
|
|
export function doToggleSplashAnimation() {
|
|
|
|
return {
|
|
|
|
type: ACTIONS.TOGGLE_SPLASH_ANIMATION,
|
|
|
|
};
|
|
|
|
}
|
2021-02-09 17:05:56 +01:00
|
|
|
|
2022-05-04 15:07:51 +02:00
|
|
|
export function doSetActiveChannel(claimId, override) {
|
2021-02-09 17:05:56 +01:00
|
|
|
return (dispatch, getState) => {
|
2022-05-04 15:07:51 +02:00
|
|
|
if (claimId || override) {
|
2021-02-09 17:05:56 +01:00
|
|
|
return dispatch({
|
|
|
|
type: ACTIONS.SET_ACTIVE_CHANNEL,
|
|
|
|
data: {
|
|
|
|
claimId,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function doSetIncognito(incognitoEnabled) {
|
|
|
|
return {
|
|
|
|
type: ACTIONS.SET_INCOGNITO,
|
|
|
|
data: {
|
|
|
|
enabled: incognitoEnabled,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2022-02-02 13:44:33 +01:00
|
|
|
|
2022-03-14 18:49:15 +01:00
|
|
|
export function doSetAdBlockerFound(found) {
|
|
|
|
return {
|
|
|
|
type: ACTIONS.SET_AD_BLOCKER_FOUND,
|
|
|
|
data: found,
|
|
|
|
};
|
|
|
|
}
|
2022-04-04 14:13:15 +02:00
|
|
|
|
Playlists v2: Refactors, touch ups + Queue Mode (#1604)
* Playlists v2
* Style pass
* Change playlist items arrange icon
* Playlist card body open by default
* Refactor collectionEdit components
* Paginate & Refactor bid field
* Collection page changes
* Add Thumbnail optional
* Replace extra info for description on collection page
* Playlist card right below video on medium screen
* Allow editing private collections
* Add edit option to menus
* Allow deleting a public playlist but keeping a private version
* Add queue to Save menu, remove edit option from Builtin pages, show queue on playlists page
* Fix scroll to recent persisting on medium screen
* Fix adding to queue from menu
* Fixes for delete
* PublishList: delay mounting Items tab to prevent lock-up (#1783)
For a large list, the playlist publish form is unusable (super-slow typing) due to the entire list being mounted despite the tab is not active.
The full solution is still to paginate it, but for now, don't mount the tab until it is selected. Add a spinner to indicate something is loading. It's not prefect, but it's throwaway code anyway. At least we can fill in the fields properly now.
* Batch-resolve private collections (#1782)
* makeSelectClaimForClaimId --> selectClaimForClaimId
Move away from the problematic `makeSelect*`, especially in large loops.
* Batch-resolve private collections
1758
This alleviates the lock-up that is caused by large number of invidual resolves. There will still be some minor stutter due to the large DOM that React needs to handle -- that is logged in 1758 and will be handled separately.
At least the stutter is short (1-2s) and the app is still usable.
Private list items are being resolve individually, super slow if the list is large (>100). Published lists doesn't have this issue.
doFetchItemsInCollections contains most of the useful logic, but it isn't called for private/built-in lists because it's not an actual claim.
Tweaked doFetchItemsInCollections to handle private (UUID-based) collections.
* Use persisted state for floating player playlist card body
- I find it annoying being open everytime
* Fix removing edits from published playlist
* Fix scroll on mobile
* Allow going editing items from toast
* Fix ClaimShareButton
* Prevent edit/publish of builtin
* Fix async inside forEach
* Fix sync on queue edit
* Fix autoplayCountdown replay
* Fix deleting an item scrolling the playlist
* CreatedAt fixes
* Remove repost for now
* Anon publish fixes
* Fix mature case on floating
Co-authored-by: infinite-persistence <64950861+infinite-persistence@users.noreply.github.com>
2022-07-13 15:59:59 +02:00
|
|
|
export function doToggleAppDrawer(type) {
|
2022-04-04 14:13:15 +02:00
|
|
|
return (dispatch, getState) => {
|
|
|
|
const state = getState();
|
Playlists v2: Refactors, touch ups + Queue Mode (#1604)
* Playlists v2
* Style pass
* Change playlist items arrange icon
* Playlist card body open by default
* Refactor collectionEdit components
* Paginate & Refactor bid field
* Collection page changes
* Add Thumbnail optional
* Replace extra info for description on collection page
* Playlist card right below video on medium screen
* Allow editing private collections
* Add edit option to menus
* Allow deleting a public playlist but keeping a private version
* Add queue to Save menu, remove edit option from Builtin pages, show queue on playlists page
* Fix scroll to recent persisting on medium screen
* Fix adding to queue from menu
* Fixes for delete
* PublishList: delay mounting Items tab to prevent lock-up (#1783)
For a large list, the playlist publish form is unusable (super-slow typing) due to the entire list being mounted despite the tab is not active.
The full solution is still to paginate it, but for now, don't mount the tab until it is selected. Add a spinner to indicate something is loading. It's not prefect, but it's throwaway code anyway. At least we can fill in the fields properly now.
* Batch-resolve private collections (#1782)
* makeSelectClaimForClaimId --> selectClaimForClaimId
Move away from the problematic `makeSelect*`, especially in large loops.
* Batch-resolve private collections
1758
This alleviates the lock-up that is caused by large number of invidual resolves. There will still be some minor stutter due to the large DOM that React needs to handle -- that is logged in 1758 and will be handled separately.
At least the stutter is short (1-2s) and the app is still usable.
Private list items are being resolve individually, super slow if the list is large (>100). Published lists doesn't have this issue.
doFetchItemsInCollections contains most of the useful logic, but it isn't called for private/built-in lists because it's not an actual claim.
Tweaked doFetchItemsInCollections to handle private (UUID-based) collections.
* Use persisted state for floating player playlist card body
- I find it annoying being open everytime
* Fix removing edits from published playlist
* Fix scroll on mobile
* Allow going editing items from toast
* Fix ClaimShareButton
* Prevent edit/publish of builtin
* Fix async inside forEach
* Fix sync on queue edit
* Fix autoplayCountdown replay
* Fix deleting an item scrolling the playlist
* CreatedAt fixes
* Remove repost for now
* Anon publish fixes
* Fix mature case on floating
Co-authored-by: infinite-persistence <64950861+infinite-persistence@users.noreply.github.com>
2022-07-13 15:59:59 +02:00
|
|
|
const openDrawer = selectAppDrawerOpen(state);
|
|
|
|
const isOpen = openDrawer && openDrawer === type;
|
2022-04-04 14:13:15 +02:00
|
|
|
|
Playlists v2: Refactors, touch ups + Queue Mode (#1604)
* Playlists v2
* Style pass
* Change playlist items arrange icon
* Playlist card body open by default
* Refactor collectionEdit components
* Paginate & Refactor bid field
* Collection page changes
* Add Thumbnail optional
* Replace extra info for description on collection page
* Playlist card right below video on medium screen
* Allow editing private collections
* Add edit option to menus
* Allow deleting a public playlist but keeping a private version
* Add queue to Save menu, remove edit option from Builtin pages, show queue on playlists page
* Fix scroll to recent persisting on medium screen
* Fix adding to queue from menu
* Fixes for delete
* PublishList: delay mounting Items tab to prevent lock-up (#1783)
For a large list, the playlist publish form is unusable (super-slow typing) due to the entire list being mounted despite the tab is not active.
The full solution is still to paginate it, but for now, don't mount the tab until it is selected. Add a spinner to indicate something is loading. It's not prefect, but it's throwaway code anyway. At least we can fill in the fields properly now.
* Batch-resolve private collections (#1782)
* makeSelectClaimForClaimId --> selectClaimForClaimId
Move away from the problematic `makeSelect*`, especially in large loops.
* Batch-resolve private collections
1758
This alleviates the lock-up that is caused by large number of invidual resolves. There will still be some minor stutter due to the large DOM that React needs to handle -- that is logged in 1758 and will be handled separately.
At least the stutter is short (1-2s) and the app is still usable.
Private list items are being resolve individually, super slow if the list is large (>100). Published lists doesn't have this issue.
doFetchItemsInCollections contains most of the useful logic, but it isn't called for private/built-in lists because it's not an actual claim.
Tweaked doFetchItemsInCollections to handle private (UUID-based) collections.
* Use persisted state for floating player playlist card body
- I find it annoying being open everytime
* Fix removing edits from published playlist
* Fix scroll on mobile
* Allow going editing items from toast
* Fix ClaimShareButton
* Prevent edit/publish of builtin
* Fix async inside forEach
* Fix sync on queue edit
* Fix autoplayCountdown replay
* Fix deleting an item scrolling the playlist
* CreatedAt fixes
* Remove repost for now
* Anon publish fixes
* Fix mature case on floating
Co-authored-by: infinite-persistence <64950861+infinite-persistence@users.noreply.github.com>
2022-07-13 15:59:59 +02:00
|
|
|
if (isOpen) {
|
|
|
|
dispatch({ type: ACTIONS.DRAWER_CLOSED });
|
|
|
|
} else {
|
|
|
|
dispatch({ type: ACTIONS.DRAWER_OPENED, data: type });
|
|
|
|
}
|
2022-04-04 14:13:15 +02:00
|
|
|
};
|
|
|
|
}
|
Playlists v2: Refactors, touch ups + Queue Mode (#1604)
* Playlists v2
* Style pass
* Change playlist items arrange icon
* Playlist card body open by default
* Refactor collectionEdit components
* Paginate & Refactor bid field
* Collection page changes
* Add Thumbnail optional
* Replace extra info for description on collection page
* Playlist card right below video on medium screen
* Allow editing private collections
* Add edit option to menus
* Allow deleting a public playlist but keeping a private version
* Add queue to Save menu, remove edit option from Builtin pages, show queue on playlists page
* Fix scroll to recent persisting on medium screen
* Fix adding to queue from menu
* Fixes for delete
* PublishList: delay mounting Items tab to prevent lock-up (#1783)
For a large list, the playlist publish form is unusable (super-slow typing) due to the entire list being mounted despite the tab is not active.
The full solution is still to paginate it, but for now, don't mount the tab until it is selected. Add a spinner to indicate something is loading. It's not prefect, but it's throwaway code anyway. At least we can fill in the fields properly now.
* Batch-resolve private collections (#1782)
* makeSelectClaimForClaimId --> selectClaimForClaimId
Move away from the problematic `makeSelect*`, especially in large loops.
* Batch-resolve private collections
1758
This alleviates the lock-up that is caused by large number of invidual resolves. There will still be some minor stutter due to the large DOM that React needs to handle -- that is logged in 1758 and will be handled separately.
At least the stutter is short (1-2s) and the app is still usable.
Private list items are being resolve individually, super slow if the list is large (>100). Published lists doesn't have this issue.
doFetchItemsInCollections contains most of the useful logic, but it isn't called for private/built-in lists because it's not an actual claim.
Tweaked doFetchItemsInCollections to handle private (UUID-based) collections.
* Use persisted state for floating player playlist card body
- I find it annoying being open everytime
* Fix removing edits from published playlist
* Fix scroll on mobile
* Allow going editing items from toast
* Fix ClaimShareButton
* Prevent edit/publish of builtin
* Fix async inside forEach
* Fix sync on queue edit
* Fix autoplayCountdown replay
* Fix deleting an item scrolling the playlist
* CreatedAt fixes
* Remove repost for now
* Anon publish fixes
* Fix mature case on floating
Co-authored-by: infinite-persistence <64950861+infinite-persistence@users.noreply.github.com>
2022-07-13 15:59:59 +02:00
|
|
|
|
|
|
|
export const doSetMainPlayerDimension = (dimensions) => (dispatch) =>
|
|
|
|
dispatch({ type: ACTIONS.SET_MAIN_PLAYER_DIMENSIONS, data: dimensions });
|