Skip to content

Commit

Permalink
fix settings, fix reload button, serverStats query on login
Browse files Browse the repository at this point in the history
  • Loading branch information
Jazcash committed Sep 8, 2024
1 parent 5b04888 commit d35c6c3
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class Application {
return steamSessionTicket.getBytes().toString("hex");
});

ipcMain.handle("reload-window", () => {
ipcMain.handle("reload-window", async () => {
this.mainWindow?.window.reload();
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/api/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export class SessionAPI {
api.session.onlineBattle.value = null;
api.session.users.clear();
api.session.customBattles.clear();

// TODO: reset online user
}

public updateCurrentUser(userData: Partial<PrivateUser>) {
Expand Down
1 change: 1 addition & 0 deletions src/renderer/components/controls/Range.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function onInput(input: number | number[]) {
align-self: center;
}
:deep(.p-slider) {
position: relative;
width: 100%;
margin: 0 15px;
&:before {
Expand Down
19 changes: 18 additions & 1 deletion src/renderer/components/controls/Select.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<template>
<Control class="select" v-bind="$props">
<Dropdown v-bind="$attrs" filterPlaceholder="Search" :autoFilterFocus="true" :autoOptionFocus="true" :resetFilterOnHide="true">
<Dropdown
v-bind="($attrs, $props)"
filterPlaceholder="Search"
:autoFilterFocus="true"
:autoOptionFocus="true"
:resetFilterOnHide="true"
>
<template v-for="(_, name) in ($slots as {})" #[name]="slotData">
<slot :name="name" v-bind="slotData || {}" />
</template>
Expand All @@ -14,6 +20,10 @@ import Dropdown, { DropdownProps } from "primevue/dropdown";
import Control from "@/components/controls/Control.vue";
defineOptions({
inheritAttrs: false,
});
export interface Props extends DropdownProps {
disabled?: boolean;
label?: string;
Expand All @@ -35,6 +45,7 @@ const props = defineProps<Props>();
padding: 5px 10px;
width: 100%;
overflow: hidden;
justify-content: space-between;
&-panel {
background: #111;
border: 1px solid rgba(255, 255, 255, 0.2);
Expand All @@ -49,7 +60,13 @@ const props = defineProps<Props>();
}
}
&-empty-message,
&-items {
list-style: none;
padding: 0;
margin: 0;
}
&-item {
display: flex;
color: #eee;
padding: 5px 10px;
}
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/components/misc/Error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ window.addEventListener("error", (event) => {
});
function onReload() {
//window.document.location.reload(); // doesn't work for some reason
ipcRenderer.send("reload-window");
ipcRenderer.invoke("reloadWindow");
}
function sanitizeStack(stack: string) {
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/components/navbar/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ watch(
);
function onOpen() {
console.log("test");
displayOptions.value = Array(api.info.hardware.numOfDisplays)
.fill(0)
.map((x, i) => {
Expand Down
25 changes: 25 additions & 0 deletions src/renderer/utils/poll-server-stats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const invervalMs = 10000;
let intervalId: number | null = null;

export function pollServerStats() {
if (intervalId) {
clearInterval(intervalId);
}

fetchServerStats();

intervalId = window.setInterval(fetchServerStats, invervalMs);
}

async function fetchServerStats() {
try {
const serverStatsResponse = await api.comms.request("system/serverStats");
if (serverStatsResponse.status === "success") {
api.session.serverStats.value = serverStatsResponse.data;
}
} catch (err) {
if (intervalId) {
clearInterval(intervalId);
}
}
}
3 changes: 3 additions & 0 deletions src/renderer/views/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { Ref, ref } from "vue";
import Loader from "@/components/common/Loader.vue";
import Button from "@/components/controls/Button.vue";
import { pollServerStats } from "@/utils/poll-server-stats";
const serverAddress = `${api.comms.config.host}:${api.comms.config.port}`;
const state: Ref<"connecting" | "waiting_for_auth" | "connected" | "error"> = ref("connecting");
Expand Down Expand Up @@ -68,6 +69,8 @@ async function connect() {
const userResponse = await api.comms.nextEvent("privateUser/add");
pollServerStats();
api.comms.isConnectedRef.value = true;
api.session.offlineMode.value = false;
Expand Down

0 comments on commit d35c6c3

Please sign in to comment.