load theme on /doDaemonReady
This commit is contained in:
parent
a77a6495b0
commit
191b95cc2e
4 changed files with 24 additions and 30 deletions
|
@ -12,7 +12,7 @@ import {
|
|||
selectHistoryForward,
|
||||
} from "selectors/app";
|
||||
import { doSearch } from "actions/search";
|
||||
import { doFetchDaemonSettings, doSetClientSetting } from "actions/settings";
|
||||
import { doFetchDaemonSettings, doSetTheme } from "actions/settings";
|
||||
import { doAuthenticate } from "actions/user";
|
||||
import { doFileList } from "actions/file_info";
|
||||
import { toQueryString } from "util/query_params";
|
||||
|
@ -320,6 +320,7 @@ export function doDaemonReady() {
|
|||
type: types.DAEMON_READY,
|
||||
data: { page },
|
||||
});
|
||||
dispatch(doSetTheme());
|
||||
dispatch(doFetchDaemonSettings());
|
||||
dispatch(doFileList());
|
||||
};
|
||||
|
@ -351,22 +352,3 @@ export function doQuit() {
|
|||
remote.app.quit();
|
||||
};
|
||||
}
|
||||
|
||||
export function doGetThemes() {
|
||||
const dir = `${remote.app.getAppPath()}/dist/themes`;
|
||||
|
||||
// Get all .css files
|
||||
const files = fs
|
||||
.readdirSync(dir)
|
||||
.filter(file => path.extname(file) === ".css");
|
||||
|
||||
return function(dispatch, getState) {
|
||||
// Find themes
|
||||
const themes = files.map(file => ({
|
||||
name: file.replace(".css", ""),
|
||||
path: `./themes/${file}`,
|
||||
}));
|
||||
|
||||
dispatch(doSetClientSetting("themes", themes));
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@ import * as types from "constants/action_types";
|
|||
import * as settings from "constants/settings";
|
||||
import lbry from "lbry";
|
||||
|
||||
const { remote } = require("electron");
|
||||
const { extname } = require("path");
|
||||
const { download } = remote.require("electron-dl");
|
||||
const { readdirSync } = remote.require("fs");
|
||||
|
||||
export function doFetchDaemonSettings() {
|
||||
return function(dispatch, getState) {
|
||||
lbry.settings_get().then(settings => {
|
||||
|
@ -43,6 +48,23 @@ export function doSetClientSetting(key, value) {
|
|||
};
|
||||
}
|
||||
|
||||
export function doGetThemes() {
|
||||
const dir = `${remote.app.getAppPath()}/dist/themes`;
|
||||
|
||||
// Get all .css files
|
||||
const files = readdirSync(dir).filter(file => extname(file) === ".css");
|
||||
|
||||
return function(dispatch, getState) {
|
||||
// Find themes
|
||||
const themes = files.map(file => ({
|
||||
name: file.replace(".css", ""),
|
||||
path: `./themes/${file}`,
|
||||
}));
|
||||
|
||||
dispatch(doSetClientSetting("themes", themes));
|
||||
};
|
||||
}
|
||||
|
||||
export function doSetTheme(name) {
|
||||
return function(dispatch, getState) {
|
||||
const last = lbry.getClientSetting(settings.THEME);
|
||||
|
|
|
@ -6,12 +6,10 @@ import {
|
|||
doOpenModal,
|
||||
doAlertError,
|
||||
doRecordScroll,
|
||||
doGetThemes,
|
||||
} from "actions/app";
|
||||
|
||||
import { doFetchRewardedContent } from "actions/content";
|
||||
import { doUpdateBalance } from "actions/wallet";
|
||||
import { doSetTheme } from "actions/settings";
|
||||
import { selectWelcomeModalAcknowledged } from "selectors/app";
|
||||
import { selectUser } from "selectors/user";
|
||||
import App from "./view";
|
||||
|
@ -30,8 +28,6 @@ const perform = dispatch => ({
|
|||
updateBalance: balance => dispatch(doUpdateBalance(balance)),
|
||||
fetchRewardedContent: () => dispatch(doFetchRewardedContent()),
|
||||
recordScroll: scrollPosition => dispatch(doRecordScroll(scrollPosition)),
|
||||
getThemes: () => dispatch(doGetThemes()),
|
||||
setTheme: name => dispatch(doSetTheme(name)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(App);
|
||||
|
|
|
@ -11,18 +11,12 @@ class App extends React.PureComponent {
|
|||
checkUpgradeAvailable,
|
||||
updateBalance,
|
||||
fetchRewardedContent,
|
||||
getThemes,
|
||||
setTheme,
|
||||
} = this.props;
|
||||
|
||||
document.addEventListener("unhandledError", event => {
|
||||
alertError(event.detail);
|
||||
});
|
||||
|
||||
getThemes();
|
||||
|
||||
setTheme();
|
||||
|
||||
if (!this.props.upgradeSkipped) {
|
||||
checkUpgradeAvailable();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue