mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-26 22:31:13 +00:00
load theme list in site-form.tsx
This commit is contained in:
parent
886a444e16
commit
7cd884ad92
1 changed files with 9 additions and 2 deletions
|
@ -6,7 +6,7 @@ import { WebSocketService } from "../../services";
|
||||||
import {
|
import {
|
||||||
authField,
|
authField,
|
||||||
capitalizeFirstLetter,
|
capitalizeFirstLetter,
|
||||||
themes,
|
fetchThemeList,
|
||||||
wsClient,
|
wsClient,
|
||||||
} from "../../utils";
|
} from "../../utils";
|
||||||
import { Spinner } from "../common/icon";
|
import { Spinner } from "../common/icon";
|
||||||
|
@ -21,6 +21,7 @@ interface SiteFormProps {
|
||||||
interface SiteFormState {
|
interface SiteFormState {
|
||||||
siteForm: EditSite;
|
siteForm: EditSite;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
|
themeList: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
|
@ -40,6 +41,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
auth: authField(),
|
auth: authField(),
|
||||||
},
|
},
|
||||||
loading: false,
|
loading: false,
|
||||||
|
themeList: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props: any, context: any) {
|
constructor(props: any, context: any) {
|
||||||
|
@ -78,6 +80,11 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async componentDidMount() {
|
||||||
|
this.state.themeList = await fetchThemeList();
|
||||||
|
this.setState(this.state);
|
||||||
|
}
|
||||||
|
|
||||||
// Necessary to stop the loading
|
// Necessary to stop the loading
|
||||||
componentWillReceiveProps() {
|
componentWillReceiveProps() {
|
||||||
this.state.loading = false;
|
this.state.loading = false;
|
||||||
|
@ -336,7 +343,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
class="custom-select w-auto"
|
class="custom-select w-auto"
|
||||||
>
|
>
|
||||||
<option value="browser">{i18n.t("browser_default")}</option>
|
<option value="browser">{i18n.t("browser_default")}</option>
|
||||||
{themes.map(theme => (
|
{this.state.themeList.map(theme => (
|
||||||
<option value={theme}>{theme}</option>
|
<option value={theme}>{theme}</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
|
|
Loading…
Reference in a new issue