aboutsummaryrefslogtreecommitdiff
path: root/src/console/colorscheme/hooks.ts
blob: c9de75410de8494201d3a0fd4ab661b25484424b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import React from "react";
import { ColorSchemeUpdateContext } from "./contexts";
import SettingClient from "../clients/SettingClient";

export const useColorSchemeRefresh = () => {
  const update = React.useContext(ColorSchemeUpdateContext);
  const settingClient = new SettingClient();
  const refresh = React.useCallback(() => {
    settingClient.getColorScheme().then((newScheme) => {
      update(newScheme);
    });
  }, []);

  return refresh;
};