mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-10 20:03:03 +00:00
Change fetchThemeBundle to not require this passed in.
`this` doesn't work with functional components
This commit is contained in:
@@ -116,27 +116,21 @@ const printCurrentBrew = ()=>{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchThemeBundle = async (obj, renderer, theme)=>{
|
const fetchThemeBundle = async (setError, setThemeBundle, renderer, theme)=>{
|
||||||
if(!renderer || !theme) return;
|
if(!renderer || !theme) return;
|
||||||
const res = await request
|
const res = await request
|
||||||
.get(`/api/theme/${renderer}/${theme}`)
|
.get(`/api/theme/${renderer}/${theme}`)
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
obj.setState({ error: err });
|
setError(err)
|
||||||
});
|
});
|
||||||
if(!res) {
|
if(!res) {
|
||||||
obj.setState((prevState)=>({
|
setThemeBundle({});
|
||||||
...prevState,
|
|
||||||
themeBundle : {}
|
|
||||||
}));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const themeBundle = res.body;
|
const themeBundle = res.body;
|
||||||
themeBundle.joinedStyles = themeBundle.styles.map((style)=>`<style>${style}</style>`).join('\n\n');
|
themeBundle.joinedStyles = themeBundle.styles.map((style)=>`<style>${style}</style>`).join('\n\n');
|
||||||
obj.setState((prevState)=>({
|
setThemeBundle(themeBundle);
|
||||||
...prevState,
|
setError(null);
|
||||||
themeBundle : themeBundle,
|
|
||||||
error : null
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const debugTextMismatch = (clientTextRaw, serverTextRaw, label) => {
|
const debugTextMismatch = (clientTextRaw, serverTextRaw, label) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user