mirror of
https://codeberg.org/emersion/gamja
synced 2025-03-13 07:48:37 +01:00
Ensure config has a server object
Simplifies code accessing the config.
This commit is contained in:
parent
093eecff91
commit
e56deb35c9
@ -18,6 +18,10 @@ import commands from "../commands.js";
|
|||||||
import { setup as setupKeybindings } from "../keybindings.js";
|
import { setup as setupKeybindings } from "../keybindings.js";
|
||||||
import * as store from "../store.js";
|
import * as store from "../store.js";
|
||||||
|
|
||||||
|
const baseConfig = {
|
||||||
|
server: {},
|
||||||
|
};
|
||||||
|
|
||||||
const configPromise = fetch("./config.json")
|
const configPromise = fetch("./config.json")
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
@ -31,6 +35,12 @@ const configPromise = fetch("./config.json")
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error("Failed to fetch config:", err);
|
console.error("Failed to fetch config:", err);
|
||||||
return {};
|
return {};
|
||||||
|
})
|
||||||
|
.then((config) => {
|
||||||
|
return {
|
||||||
|
...baseConfig,
|
||||||
|
...config,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const CHATHISTORY_MAX_SIZE = 4000;
|
const CHATHISTORY_MAX_SIZE = 4000;
|
||||||
@ -127,7 +137,7 @@ export default class App extends Component {
|
|||||||
memberList: false,
|
memberList: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
config = {};
|
config = { ...baseConfig };
|
||||||
clients = new Map();
|
clients = new Map();
|
||||||
endOfHistory = new Map();
|
endOfHistory = new Map();
|
||||||
receipts = new Map();
|
receipts = new Map();
|
||||||
@ -201,9 +211,7 @@ export default class App extends Component {
|
|||||||
|
|
||||||
// When using a custom server, some configuration options don't
|
// When using a custom server, some configuration options don't
|
||||||
// make sense anymore.
|
// make sense anymore.
|
||||||
if (config.server) {
|
config.server.auth = null;
|
||||||
config.server.auth = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (queryParams.nick) {
|
if (queryParams.nick) {
|
||||||
connectParams.nick = queryParams.nick;
|
connectParams.nick = queryParams.nick;
|
||||||
@ -1220,7 +1228,7 @@ export default class App extends Component {
|
|||||||
<${ConnectForm}
|
<${ConnectForm}
|
||||||
error=${this.state.error}
|
error=${this.state.error}
|
||||||
params=${this.state.connectParams}
|
params=${this.state.connectParams}
|
||||||
auth=${this.config.server ? this.config.server.auth : null}
|
auth=${this.config.server.auth}
|
||||||
connecting=${connecting}
|
connecting=${connecting}
|
||||||
onSubmit=${this.handleConnectSubmit}
|
onSubmit=${this.handleConnectSubmit}
|
||||||
key=${this.state.connectParams}
|
key=${this.state.connectParams}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user