mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-06 17:11:55 +00:00
Port and re-write icon code.
This commit is contained in:
32
src/context/Settings.tsx
Normal file
32
src/context/Settings.tsx
Normal 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
|
||||
}
|
||||
});
|
||||
@@ -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);
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user