getting theme from backend
This commit is contained in:
Generated
+1309
-1236
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@ import Novel from "../Novel/Novel";
|
|||||||
import User from "../User/User";
|
import User from "../User/User";
|
||||||
import Main from "../Main/Main"
|
import Main from "../Main/Main"
|
||||||
import NotFoundError from "../NotFoundError";
|
import NotFoundError from "../NotFoundError";
|
||||||
import {fetchCurrentUser} from "../../api/users";
|
import {fetchCurrentUser, fetchUserSettings} from "../../api/users";
|
||||||
import {connect} from "react-redux";
|
import {connect} from "react-redux";
|
||||||
import {setUser} from "../../store/actions";
|
import {setUser} from "../../store/actions";
|
||||||
import Character from "../Character/Character";
|
import Character from "../Character/Character";
|
||||||
@@ -42,14 +42,15 @@ class App extends React.Component<Props, State> {
|
|||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
const { setUser } = this.props;
|
const { setUser } = this.props;
|
||||||
fetchCurrentUser().then(setUser).catch((err: ApiError) => {
|
fetchCurrentUser().then((user: UserType) => {
|
||||||
|
setUser(user);
|
||||||
|
fetchUserSettings().then((settings: UserSettingsType) => {
|
||||||
|
document.body.setAttribute('theme', settings.theme);
|
||||||
|
});
|
||||||
|
}).catch((err: ApiError) => {
|
||||||
if(err.code !== 3 && err.text) console.error(err.text);
|
if(err.code !== 3 && err.text) console.error(err.text);
|
||||||
});
|
});
|
||||||
|
|
||||||
const theme = localStorage.getItem('theme');
|
|
||||||
if(theme)
|
|
||||||
document.body.setAttribute('theme', theme);
|
|
||||||
|
|
||||||
parser.registerTag('spoiler', SpoilerTag);
|
parser.registerTag('spoiler', SpoilerTag);
|
||||||
parser.registerTag('color', ColorTag);
|
parser.registerTag('color', ColorTag);
|
||||||
|
|
||||||
|
|||||||
Vendored
+8
@@ -1,3 +1,5 @@
|
|||||||
|
type Theme = 'dark' | 'blue' | 'red' | 'green' | 'light'
|
||||||
|
|
||||||
type ApiError = {
|
type ApiError = {
|
||||||
code: number
|
code: number
|
||||||
text: string
|
text: string
|
||||||
@@ -41,6 +43,12 @@ type UserType = {
|
|||||||
is_activated: boolean
|
is_activated: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UserSettingsType = {
|
||||||
|
avatar: string
|
||||||
|
theme: Theme
|
||||||
|
use_gravatar: boolean
|
||||||
|
}
|
||||||
|
|
||||||
type UserNovelType = {
|
type UserNovelType = {
|
||||||
mark?: number
|
mark?: number
|
||||||
status: string
|
status: string
|
||||||
|
|||||||
Reference in New Issue
Block a user