Skip to content

Commit

Permalink
Load gateways before /settings and /about
Browse files Browse the repository at this point in the history
  • Loading branch information
sidoh committed Oct 26, 2024
1 parent 42b3a36 commit a4d0cfe
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 43 deletions.
6 changes: 3 additions & 3 deletions dist/bundle.js.gz.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/index.html.gz.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define index_html_gz_len 1832
static const char index_html_filename[] = "/dist/index.10148807.html";
static const char index_html_gz[] PROGMEM = {31,139,8,0,0,0,0,0,2,10,237,88,91,115,218,56,20,126,239,204,254,7,213,219,157,49,99,98,145,20,18,66,66,102,133,77,154,180,132,152,54,217,221,116,103,103,107,108,249,18,140,205,202,2,67,50,252,247,61,178,13,216,64,218,62,236,219,214,51,88,150,116,116,244,157,79,231,162,225,213,249,107,253,86,187,123,48,186,200,227,227,224,226,213,185,104,80,96,134,110,91,162,161,36,6,168,105,67,51,166,220,68,150,103,178,152,242,182,116,127,119,121,208,148,86,195,161,57,166,109,105,230,211,100,18,49,46,33,43,10,57,13,65,44,241,109,238,181,109,58,243,45,122,144,118,170,200,15,125,238,155,193,65,108,153,1,109,31,170,53,161,134,251,60,160,23,55,126,207,119,61,142,174,166,195,115,156,13,189,58,15,252,112,132,60,70,157,182,100,155,220,108,249,99,211,165,120,126,224,195,46,103,67,51,166,199,245,42,33,164,67,72,151,116,225,45,90,141,116,162,206,128,144,75,23,186,154,120,145,129,120,93,147,213,252,234,233,146,242,83,238,227,183,205,62,233,232,138,150,232,248,113,16,147,211,201,253,45,233,124,156,98,232,95,13,18,162,184,6,35,70,253,102,72,200,231,166,211,36,218,124,120,10,253,119,163,68,251,29,147,136,232,15,143,10,49,26,167,218,64,63,185,36,35,162,97,28,146,247,15,31,240,128,12,112,82,39,150,59,195,196,56,57,212,18,237,147,110,52,137,66,70,15,208,103,96,70,31,43,53,130,231,93,139,24,135,76,75,200,13,142,70,68,119,148,43,114,141,79,192,164,30,110,196,68,55,78,27,132,212,238,1,79,29,187,208,255,131,41,192,196,45,118,245,64,195,160,111,86,235,19,242,22,119,147,78,189,11,248,154,9,59,33,70,237,154,130,254,19,163,78,134,78,179,71,200,244,61,78,180,223,244,25,200,123,214,59,162,93,41,186,219,121,194,73,12,246,157,96,210,185,83,62,15,200,141,54,171,17,211,13,49,121,127,135,245,129,174,116,13,177,255,73,76,110,29,172,19,29,235,115,192,235,30,193,73,212,251,216,237,212,176,155,16,253,243,19,172,239,1,95,128,191,243,64,148,228,159,27,242,227,249,241,252,120,254,231,15,228,185,210,115,31,195,75,233,39,132,188,123,186,94,143,94,63,214,200,7,143,144,43,175,153,143,68,226,213,79,63,59,73,154,162,225,87,88,145,62,99,34,82,190,30,63,22,198,62,245,146,23,160,116,110,194,126,121,132,221,232,201,111,189,143,229,90,160,235,247,246,75,214,188,215,11,178,218,125,93,52,31,244,178,137,151,154,144,177,196,231,113,161,214,252,145,131,16,53,233,247,158,75,76,178,193,217,251,0,85,235,118,32,244,212,203,96,58,35,99,253,109,52,128,3,125,252,25,214,53,71,192,83,111,6,56,53,71,129,181,79,24,210,173,129,5,71,142,2,175,43,236,230,125,168,54,32,31,226,81,46,175,47,238,160,223,24,91,185,62,210,150,16,163,65,91,18,101,86,66,124,49,129,10,95,44,189,18,194,80,156,99,190,16,69,26,161,159,131,200,180,253,208,69,207,208,65,104,18,197,80,229,163,176,133,28,127,78,237,179,116,144,71,147,22,106,212,126,201,122,1,117,120,161,203,153,25,198,78,196,198,173,236,51,48,57,149,15,96,186,138,196,187,146,73,57,112,179,56,136,253,39,218,66,71,245,201,188,48,232,152,99,63,88,180,16,97,112,185,168,162,24,84,28,196,148,249,142,144,89,190,58,199,57,212,243,216,98,254,132,95,200,206,52,180,4,68,36,87,208,243,79,32,4,70,197,28,89,118,216,129,75,5,106,35,201,227,124,18,183,48,134,33,245,49,182,105,224,207,152,26,82,142,93,15,199,190,29,121,152,198,147,230,209,241,241,223,176,181,184,184,252,237,77,135,191,38,116,120,132,211,151,237,199,28,207,40,139,97,151,24,195,77,71,61,198,210,217,102,43,199,15,104,12,27,253,249,83,106,198,115,214,160,148,236,22,146,82,192,177,71,41,151,170,171,41,128,98,152,220,107,173,97,42,72,26,78,67,59,160,170,21,199,27,185,32,130,219,85,38,41,165,48,114,161,183,39,195,134,217,116,204,178,116,70,232,68,220,237,174,67,46,75,205,250,225,169,84,69,135,181,74,46,178,172,190,0,49,229,242,187,224,61,126,15,186,134,109,55,143,106,102,73,120,27,220,209,81,173,241,182,177,7,222,95,64,173,104,215,7,107,49,10,78,244,105,77,99,15,110,146,178,184,73,86,86,134,100,231,144,222,48,219,200,142,172,233,24,174,173,106,182,174,27,80,209,147,37,49,45,85,206,178,21,162,163,66,96,8,255,40,28,80,113,86,236,0,211,162,201,135,25,229,83,22,166,179,233,200,114,63,208,148,76,57,102,214,22,190,140,229,175,32,204,143,97,133,49,235,170,160,8,214,192,187,60,108,83,135,50,152,224,108,74,203,248,50,129,189,8,57,91,244,32,192,239,89,32,79,153,8,47,56,148,170,88,199,22,90,52,13,5,184,90,21,141,205,249,71,24,242,83,175,110,172,173,200,213,59,148,91,158,88,94,89,29,173,202,61,26,202,50,131,48,2,67,105,5,181,47,54,46,134,144,239,32,249,245,106,82,141,70,149,226,36,248,160,199,162,4,133,52,65,93,198,34,38,75,125,202,147,136,141,208,106,9,74,204,24,133,17,71,209,230,252,82,119,217,124,230,208,12,22,141,125,216,3,86,70,193,140,110,16,173,87,45,55,160,45,83,216,33,83,177,233,62,200,5,86,206,11,148,108,161,23,71,27,129,207,39,38,11,229,47,66,102,33,210,231,155,103,32,104,137,228,55,207,5,53,10,58,92,226,55,207,27,93,203,202,151,162,65,107,59,190,121,76,160,169,120,76,37,86,16,13,128,179,61,20,167,150,238,227,111,89,249,154,179,92,66,122,147,69,142,219,114,103,63,214,233,140,6,209,68,56,175,136,163,9,139,236,105,186,84,66,237,54,12,216,155,249,85,100,9,98,75,11,11,116,238,26,47,118,85,215,89,166,154,102,90,53,35,3,220,180,182,50,123,219,228,23,20,229,89,109,87,205,202,21,132,23,108,232,249,110,28,141,181,79,173,1,237,163,83,84,86,3,10,175,188,54,57,160,80,167,166,140,1,13,130,228,235,208,166,115,17,129,121,2,220,90,219,167,243,84,76,46,80,38,232,220,209,112,209,206,74,146,26,208,208,229,94,201,97,215,169,199,165,60,207,59,157,197,181,13,217,49,171,251,82,69,77,211,161,10,249,124,18,152,11,113,174,97,20,82,233,108,59,216,54,33,181,66,91,172,135,40,199,240,231,54,186,191,206,54,226,59,14,182,217,227,27,41,229,155,73,101,79,90,185,52,97,11,27,110,47,41,155,41,60,169,28,125,203,61,161,184,222,98,24,68,67,185,20,104,187,112,133,204,46,212,140,21,8,100,32,229,254,99,47,207,250,183,195,71,106,113,232,103,171,74,64,132,99,208,236,116,10,116,173,204,78,189,79,84,238,44,202,10,229,107,135,132,92,9,108,188,183,136,138,36,94,102,32,139,164,125,187,228,181,233,155,59,100,213,111,87,115,217,142,181,31,138,191,165,84,115,50,161,161,173,121,126,96,203,185,194,242,234,109,47,82,148,50,95,165,240,120,233,140,190,150,240,55,137,60,157,150,191,236,241,150,22,100,245,98,34,89,126,169,102,57,245,191,194,186,201,30,217,7,198,232,19,55,25,71,171,75,121,26,82,121,238,216,85,147,175,91,83,107,218,118,119,6,31,61,184,154,209,144,66,8,232,183,55,90,246,159,158,136,59,106,195,237,75,46,50,177,73,81,153,66,209,44,43,105,15,46,222,217,133,27,190,242,191,18,135,145,189,64,86,96,198,177,248,75,143,141,196,31,128,182,63,67,190,221,150,38,160,165,216,95,165,151,139,94,246,161,170,234,57,92,172,103,66,93,222,8,117,169,246,244,15,204,127,1,181,10,198,145,210,20,0,0};
static const char index_html_filename[] = "/dist/index.63a1e3f9.html";
static const char index_html_gz[] PROGMEM = {31,139,8,0,0,0,0,0,2,10,237,88,91,115,218,56,20,126,239,204,254,7,213,219,157,49,99,98,145,20,18,66,66,102,133,77,154,180,132,152,54,217,221,116,103,103,107,108,249,18,140,205,202,2,67,50,252,247,61,178,13,216,64,218,62,236,219,214,51,88,150,116,116,244,157,79,231,162,225,213,249,107,253,86,187,123,48,186,200,227,227,224,226,213,185,104,80,96,134,110,91,162,161,36,6,168,105,67,51,166,220,68,150,103,178,152,242,182,116,127,119,121,208,148,86,195,161,57,166,109,105,230,211,100,18,49,46,33,43,10,57,13,65,44,241,109,238,181,109,58,243,45,122,144,118,170,200,15,125,238,155,193,65,108,153,1,109,31,170,53,161,134,251,60,160,23,55,126,207,119,61,142,174,166,195,115,156,13,189,58,15,252,112,132,60,70,157,182,100,155,220,108,249,99,211,165,120,126,224,195,46,103,67,51,166,199,245,42,33,164,67,72,151,116,225,45,90,141,116,162,206,128,144,75,23,186,154,120,145,129,120,93,147,213,252,234,233,146,242,83,238,227,183,205,62,233,232,138,150,232,248,113,16,147,211,201,253,45,233,124,156,98,232,95,13,18,162,184,6,35,70,253,102,72,200,231,166,211,36,218,124,120,10,253,119,163,68,251,29,147,136,232,15,143,10,49,26,167,218,64,63,185,36,35,162,97,28,146,247,15,31,240,128,12,112,82,39,150,59,195,196,56,57,212,18,237,147,110,52,137,66,70,15,208,103,96,70,31,43,53,130,231,93,139,24,135,76,75,200,13,142,70,68,119,148,43,114,141,79,192,164,30,110,196,68,55,78,27,132,212,238,1,79,29,187,208,255,131,41,192,196,45,118,245,64,195,160,111,86,235,19,242,22,119,147,78,189,11,248,154,9,59,33,70,237,154,130,254,19,163,78,134,78,179,71,200,244,61,78,180,223,244,25,200,123,214,59,162,93,41,186,219,121,194,73,12,246,157,96,210,185,83,62,15,200,141,54,171,17,211,13,49,121,127,135,245,129,174,116,13,177,255,73,76,110,29,172,19,29,235,115,192,235,30,193,73,212,251,216,237,212,176,155,16,253,243,19,172,239,1,95,128,191,243,64,148,228,159,27,242,227,249,241,252,120,254,231,15,228,185,210,115,31,195,75,233,39,132,188,123,186,94,143,94,63,214,200,7,143,144,43,175,153,143,68,226,213,79,63,59,73,154,162,225,87,88,145,62,99,34,82,190,30,63,22,198,62,245,146,23,160,116,110,194,126,121,132,221,232,201,111,189,143,229,90,160,235,247,246,75,214,188,215,11,178,218,125,93,52,31,244,178,137,151,154,144,177,196,231,113,161,214,252,145,131,16,53,233,247,158,75,76,178,193,217,251,0,85,235,118,32,244,212,203,96,58,35,99,253,109,52,128,3,125,252,25,214,53,71,192,83,111,6,56,53,71,129,181,79,24,210,173,129,5,71,142,2,175,43,236,230,125,168,54,32,31,226,81,46,175,47,238,160,223,24,91,185,62,210,150,16,163,65,91,18,101,86,66,124,49,129,10,95,44,189,18,194,80,156,99,190,16,69,26,161,159,131,200,180,253,208,69,207,208,65,104,18,197,80,229,163,176,133,28,127,78,237,179,116,144,71,147,22,106,212,126,201,122,1,117,120,161,203,153,25,198,78,196,198,173,236,51,48,57,149,15,96,186,138,196,187,146,73,57,112,179,56,136,253,39,218,66,71,245,201,188,48,232,152,99,63,88,180,16,97,112,185,168,162,24,84,28,196,148,249,142,144,89,190,58,199,57,212,243,216,98,254,132,95,200,206,52,180,4,68,36,87,208,243,79,32,4,70,197,28,89,118,216,129,75,5,106,35,201,227,124,18,183,48,134,33,245,49,182,105,224,207,152,26,82,142,93,15,199,190,29,121,152,198,147,230,209,241,241,223,176,181,184,184,252,237,77,135,191,38,116,120,132,211,151,237,199,28,207,40,139,97,151,24,195,77,71,61,198,210,217,102,43,199,15,104,12,27,253,249,83,106,198,115,214,160,148,236,22,146,82,192,177,71,41,151,170,171,41,128,98,152,220,107,173,97,42,72,26,78,67,59,160,170,21,199,27,185,32,130,219,85,38,41,165,48,114,161,183,39,195,134,217,116,204,178,116,70,232,68,220,237,174,67,46,75,205,250,225,169,84,69,135,181,74,46,178,172,190,0,49,229,242,187,224,61,126,7,186,195,26,181,14,45,171,81,18,222,6,119,116,84,107,156,54,246,192,251,11,168,21,237,250,96,45,70,193,137,62,173,105,236,193,77,82,22,55,201,202,202,144,236,28,210,27,102,27,217,145,53,29,195,181,85,205,214,117,3,42,122,178,36,166,165,202,89,182,66,116,84,8,12,225,31,133,3,42,206,138,29,96,90,52,249,48,163,124,202,194,116,54,29,89,238,7,154,146,41,199,204,218,194,151,177,252,21,132,249,49,172,48,102,93,21,20,193,26,120,151,135,109,234,80,6,19,156,77,105,25,95,38,176,23,33,103,139,30,4,248,61,11,228,41,19,225,5,135,82,21,235,216,66,139,166,161,0,87,171,162,177,57,255,8,67,126,234,213,141,181,21,185,122,135,114,203,19,203,43,171,163,85,185,71,67,89,102,16,70,96,40,173,160,246,197,198,197,16,242,29,36,191,94,77,170,209,168,82,156,4,31,244,88,148,160,144,38,168,203,88,196,100,169,79,121,18,177,17,90,45,65,137,25,163,48,226,40,218,156,95,234,46,155,207,28,154,193,162,177,15,123,192,202,40,152,209,13,162,245,170,229,6,180,101,10,59,100,42,54,221,7,185,192,202,121,129,146,45,244,226,104,35,240,249,196,100,161,252,69,200,44,68,250,124,243,12,4,45,145,252,230,185,160,70,65,135,75,252,230,121,163,107,89,249,82,52,104,109,199,55,143,9,52,21,143,169,196,10,162,1,112,182,135,226,212,210,125,252,45,43,95,115,150,75,72,111,178,200,113,91,238,236,199,58,157,209,32,154,8,231,21,113,52,97,145,61,77,151,74,168,221,134,1,123,51,191,138,44,65,108,105,97,129,206,93,227,197,174,234,58,203,84,211,76,171,102,100,128,155,214,86,102,111,155,252,130,162,60,171,237,170,89,185,130,240,130,13,61,223,141,163,177,246,169,53,160,125,116,138,202,106,64,225,149,215,38,7,20,234,212,148,49,160,65,144,124,29,218,116,46,34,48,79,128,91,107,251,116,158,138,201,5,202,4,157,59,26,46,218,89,73,82,3,26,186,220,43,57,236,58,245,184,148,231,121,167,179,184,182,33,59,102,117,95,170,168,105,58,84,33,159,79,2,115,33,206,53,140,66,42,157,109,7,219,38,164,86,104,139,245,16,229,24,254,220,70,247,215,217,70,124,199,193,54,123,124,35,165,124,51,169,236,73,43,151,38,108,97,195,237,37,101,51,133,39,149,163,111,185,39,20,215,91,12,131,104,40,151,2,109,23,174,144,217,133,154,177,2,129,12,164,220,127,236,229,89,255,118,248,72,45,14,253,108,85,9,136,112,12,154,157,78,129,174,149,217,169,247,137,202,157,69,89,161,124,237,144,144,43,129,141,247,22,81,145,196,203,12,100,145,180,111,151,188,54,125,115,135,172,250,237,106,46,219,177,246,67,241,183,148,106,78,38,52,180,53,207,15,108,57,87,88,94,189,237,69,138,82,230,171,20,30,47,157,209,215,18,254,38,145,167,211,242,151,61,222,210,130,172,94,76,36,203,47,213,44,167,254,87,88,55,217,35,251,192,24,125,226,38,227,104,117,41,79,67,42,207,29,187,106,242,117,107,106,77,219,238,206,224,163,7,87,51,26,82,8,1,253,246,70,203,254,211,19,113,71,109,184,125,201,69,38,54,41,42,83,40,154,101,37,237,193,197,59,187,112,195,87,254,87,226,48,178,23,200,10,204,56,22,127,233,177,145,248,3,208,246,103,200,183,219,210,4,180,20,251,171,244,114,209,203,62,84,85,61,135,139,245,76,168,203,27,161,46,213,158,254,129,249,47,126,241,208,9,210,20,0,0};
58 changes: 29 additions & 29 deletions web2/dist/versions/1.0.6/bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions web2/dist/versions/1.0.6/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
{
type: "script",
cdnPath: cdnBase + "bundle.js",
localPath: "dist/bundle.35dd820a.js",
size: parseInt("220535", 10),
localPath: "dist/bundle.10ec1cc5.js",
size: parseInt("220595", 10),
},
];

Expand Down
Empty file removed web2/lib/gateway-state.tsx
Empty file.
5 changes: 0 additions & 5 deletions web2/lib/light-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@ import { z } from "zod";
import { api, schemas } from "@/api";
import { reducer } from "@/components/light/state";

// Define the LightState type
type LightState = z.infer<typeof schemas.GatewayListItem>;

// Define the context type
interface LightContextType {
lightStates: { lights: LightState[]; isLoading: boolean };
dispatch: React.Dispatch<any>;
}

// Create the context
const LightContext = createContext<LightContextType | null>(null);

// Implement the provider
export const LightProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
const [lightStates, dispatch] = useReducer(reducer, {
lights: [],
Expand All @@ -37,7 +33,6 @@ export const LightProvider: React.FC<{ children: ReactNode }> = ({ children }) =
);
};

// Create a custom hook to use the LightContext
export const useLightState = () => {
const context = useContext(LightContext);
if (!context) {
Expand Down
11 changes: 9 additions & 2 deletions web2/lib/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React, {
} from "react";
import { z } from "zod";
import { api, schemas } from "@/api";
import { useLightState } from "./light-state";

type Settings = z.infer<typeof schemas.Settings>;
type About = z.infer<typeof schemas.About>;
Expand All @@ -29,6 +30,7 @@ const SettingsContext = createContext<SettingsContextType | null>(null);
export const SettingsProvider: React.FC<{ children: ReactNode }> = ({
children,
}) => {
const { lightStates } = useLightState();
const [settings, setSettings] = useState<Settings | null>(null);
const [about, setAbout] = useState<About | null>(null);
const [isLoading, setIsLoading] = useState(true);
Expand Down Expand Up @@ -56,7 +58,9 @@ export const SettingsProvider: React.FC<{ children: ReactNode }> = ({
: "light";

setTheme(initialTheme as "light" | "dark");
}, []);

useEffect(() => {
const fetchData = async () => {
const [settings, about] = await Promise.all([
api.getSettings(),
Expand All @@ -68,8 +72,11 @@ export const SettingsProvider: React.FC<{ children: ReactNode }> = ({
setIsLoadingAbout(false);
};

fetchData();
}, []);
// Force serial fetching of /gateways => /settings => /about
if (!lightStates.isLoading && isLoading) {
fetchData();
}
}, [lightStates.isLoading, isLoading]);

const updateSettings = (newSettings: Partial<Settings>) => {
const updatedSettings = { ...settings, ...newSettings };
Expand Down

0 comments on commit a4d0cfe

Please sign in to comment.