feat: update session creation to hydrate data immediately
Update `createSession` to return the session ID, allowing the UI to automatically set the active session and trigger a server hydration immediately after creation. This ensures the UI reflects the new session state without a manual refresh.
This commit is contained in:
@@ -370,8 +370,8 @@ export async function connectStream(
|
||||
* Create a new session by publishing retained metadata to its meta topic.
|
||||
* The server picks it up and adds it to the $SESSIONS manifest.
|
||||
*/
|
||||
export function createSession(name: string, players: string[] = []): void {
|
||||
if (!_mqttClient || !_mqttConnected) return;
|
||||
export function createSession(name: string, players: string[] = []): string | null {
|
||||
if (!_mqttClient || !_mqttConnected) return null;
|
||||
|
||||
const id =
|
||||
name
|
||||
@@ -385,6 +385,8 @@ export function createSession(name: string, players: string[] = []): void {
|
||||
qos: 1,
|
||||
retain: true,
|
||||
});
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user