Port and re-write icon code.

This commit is contained in:
Paul
2021-06-19 12:34:53 +01:00
parent ec97dbebd0
commit 5aa8f30e14
17 changed files with 412 additions and 41 deletions

32
src/context/Settings.tsx Normal file
View File

@@ -0,0 +1,32 @@
// This code is more or less redundant, but settings has so little state
// updates that I can't be asked to pass everything through props each
// time when I can just use the Context API.
//
// Replace references to SettingsContext with connectState in the future
// if it does cause problems though.
import { Settings } from "../redux/reducers/settings";
import { connectState } from "../redux/connector";
import { Children } from "../types/Preact";
import { createContext } from "preact";
export const SettingsContext = createContext<Settings>({} as any);
interface Props {
children?: Children,
settings: Settings
}
function Settings(props: Props) {
return (
<SettingsContext.Provider value={props.settings}>
{ props.children }
</SettingsContext.Provider>
)
}
export default connectState(Settings, state => {
return {
settings: state.settings
}
});

View File

@@ -201,11 +201,12 @@ function Context({ auth, sync, children, dispatcher }: Props) {
}
}
} else {
await client
.fetchConfiguration()
.catch(() =>
console.error("Failed to connect to API server.")
);
try {
await client.fetchConfiguration()
} catch (err) {
console.error("Failed to connect to API server.");
}
setStatus(ClientStatus.READY);
}
})();