orbolay updates (#1099)

* add x y options, add live update for config

* missing
This commit is contained in:
creations 2026-05-21 15:33:53 -04:00 • committed by GitHub
parent 23bcef5608
commit 0897845552
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,6 +20,8 @@ interface ChannelState {
selfStream: boolean;
}
const liveUpdate = () => sendConfig();
const settings = definePluginSettings({
port: {
type: OptionType.NUMBER,
@ -31,7 +33,7 @@ const settings = definePluginSettings({
type: OptionType.BOOLEAN,
description: "Enable/disable the global keybind (Ctrl + `)",
default: true,
restartNeeded: true,
onChange: liveUpdate,
},
messageAlignment: {
type: OptionType.SELECT,
@ -41,9 +43,25 @@ const settings = definePluginSettings({
{ label: "Top right", value: "topright" },
{ label: "Bottom left", value: "bottomleft" },
{ label: "Bottom right", value: "bottomright" },
{ label: "Top center", value: "topcenter" },
{ label: "Bottom center", value: "bottomcenter" },
{ label: "Center left", value: "centerleft" },
{ label: "Center right", value: "centerright" },
],
default: "topright",
restartNeeded: true
onChange: liveUpdate,
},
messageOffsetX: {
type: OptionType.NUMBER,
description: "Horizontal offset for messages, in pixels",
default: 0,
onChange: liveUpdate,
},
messageOffsetY: {
type: OptionType.NUMBER,
description: "Vertical offset for messages, in pixels",
default: 0,
onChange: liveUpdate,
},
userAlignment: {
type: OptionType.SELECT,
@ -53,24 +71,54 @@ const settings = definePluginSettings({
{ label: "Top right", value: "topright" },
{ label: "Bottom left", value: "bottomleft" },
{ label: "Bottom right", value: "bottomright" },
{ label: "Top center", value: "topcenter" },
{ label: "Bottom center", value: "bottomcenter" },
{ label: "Center left", value: "centerleft" },
{ label: "Center right", value: "centerright" },
],
default: "topleft",
restartNeeded: true
onChange: liveUpdate,
},
userOffsetX: {
type: OptionType.NUMBER,
description: "Horizontal offset for users, in pixels",
default: 0,
onChange: liveUpdate,
},
userOffsetY: {
type: OptionType.NUMBER,
description: "Vertical offset for users, in pixels",
default: 0,
onChange: liveUpdate,
},
voiceSemitransparent: {
type: OptionType.BOOLEAN,
description: "Make voice channel members transparent",
default: true,
restartNeeded: true
onChange: liveUpdate,
},
messagesSemitransparent: {
type: OptionType.BOOLEAN,
description: "Make message notifications transparent",
default: false,
restartNeeded: true
onChange: liveUpdate,
},
});
const sendConfig = () => {
if (ws?.readyState !== WebSocket.OPEN) return;
const userId = UserStore.getCurrentUser()?.id;
if (!userId) return;
const config: Record<string, unknown> = { userId };
for (const key of Object.keys(settings.def)) {
config[key] = settings.store[key];
}
ws?.send(JSON.stringify({ cmd: "REGISTER_CONFIG", ...config }));
};
let ws: WebSocket | null = null;
let currentChannel: string | null = null;
@ -273,17 +321,12 @@ const createWebsocket = () => {
id: Toasts.genId(),
});
const config = {
...settings.store,
userId: null,
};
const userId = await waitForPopulate(() => UserStore.getCurrentUser().id);
if (!userId) return;
config.userId = await waitForPopulate(() => UserStore.getCurrentUser().id);
if (!config.userId) return;
sendConfig();
ws?.send(JSON.stringify({ cmd: "REGISTER_CONFIG", ...config }));
const userVoiceState = VoiceStateStore.getVoiceStateForUser(config.userId);
const userVoiceState = VoiceStateStore.getVoiceStateForUser(userId);
if (!userVoiceState || !userVoiceState.channelId) return;
const channel = ChannelStore.getChannel(userVoiceState.channelId);