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 Main from "../Main/Main"
|
||||
import NotFoundError from "../NotFoundError";
|
||||
import {fetchCurrentUser} from "../../api/users";
|
||||
import {fetchCurrentUser, fetchUserSettings} from "../../api/users";
|
||||
import {connect} from "react-redux";
|
||||
import {setUser} from "../../store/actions";
|
||||
import Character from "../Character/Character";
|
||||
@@ -42,14 +42,15 @@ class App extends React.Component<Props, State> {
|
||||
super(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);
|
||||
});
|
||||
|
||||
const theme = localStorage.getItem('theme');
|
||||
if(theme)
|
||||
document.body.setAttribute('theme', theme);
|
||||
|
||||
parser.registerTag('spoiler', SpoilerTag);
|
||||
parser.registerTag('color', ColorTag);
|
||||
|
||||
|
||||
Vendored
+9
-1
@@ -1,3 +1,5 @@
|
||||
type Theme = 'dark' | 'blue' | 'red' | 'green' | 'light'
|
||||
|
||||
type ApiError = {
|
||||
code: number
|
||||
text: string
|
||||
@@ -41,6 +43,12 @@ type UserType = {
|
||||
is_activated: boolean
|
||||
}
|
||||
|
||||
type UserSettingsType = {
|
||||
avatar: string
|
||||
theme: Theme
|
||||
use_gravatar: boolean
|
||||
}
|
||||
|
||||
type UserNovelType = {
|
||||
mark?: number
|
||||
status: string
|
||||
@@ -83,4 +91,4 @@ type StoreState = {
|
||||
modal: React.ReactNode
|
||||
}
|
||||
|
||||
type SetModalType = (modal: React.ReactNode | null) => void
|
||||
type SetModalType = (modal: React.ReactNode | null) => void
|
||||
|
||||
Reference in New Issue
Block a user