diff --git a/server/src/airtable-interface.js b/server/src/airtable-interface.js index 07b10e2c..998f8079 100644 --- a/server/src/airtable-interface.js +++ b/server/src/airtable-interface.js @@ -9,6 +9,32 @@ const chalk = require("chalk"); const logUpdates = false; + +/*** + * @type {Server} + */ +let io = null; +let _isRebuilding = true; +function setup(_io) { + io = _io; + + io.on("connect", (socket) => { + io.emit("server_rebuilding", _isRebuilding); + }); + + return this; +} + +function setRebuilding(isRebuilding) { + _isRebuilding = isRebuilding; + if (isRebuilding) { + io.emit("server_rebuilding", true); + } else { + io.emit("server_rebuilding", false); + } +} + + // Starting with syncing Matches // const tables = ["Matches", "Teams", "Themes", "Events", "Players", "Player Relationships"]; @@ -109,6 +135,8 @@ function t(ms) { }); } +let firstRun = true; + async function sync() { for (let table of staticTables) { await processTableData(table, await getAllTableData(table), true); @@ -120,6 +148,8 @@ async function sync() { setInterval(async () => processTableData(table, await getAllTableData(table)), 30 * 1000); registerUpdater(table); } + if (firstRun) setRebuilding(false); + firstRun = false; } sync(); @@ -131,5 +161,6 @@ module.exports = { }, async select(table, filter) { return await slmngg(table).select(filter).all(); - } + }, + setup }; diff --git a/server/src/index.js b/server/src/index.js index 572c63ca..b6afe6ae 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -42,7 +42,7 @@ const auction = require("./discord/new_auction.js")({ const Cache = (require("./cache.js")).setup(io); -require("./airtable-interface.js"); +(require("./airtable-interface.js")).setup(io); app.use(bodyParser.urlencoded({ extended: true })); diff --git a/website/src/components/website/WebsiteNav.vue b/website/src/components/website/WebsiteNav.vue index 489593f4..7e87a8b0 100644 --- a/website/src/components/website/WebsiteNav.vue +++ b/website/src/components/website/WebsiteNav.vue @@ -1,5 +1,12 @@