From e01393c550ed8a0049926ceaaf555f999a20f631 Mon Sep 17 00:00:00 2001
From: Mikhail Romanko
Date: Sun, 25 Oct 2026 10:11:32 +0300
Subject: [PATCH] Add room prefiling setting
---
frontend/src/pages/PlanMeetingPage.jsx | 25 +++++++++++++++++++++++--
frontend/src/pages/ProfilePage.jsx | 18 ++++++++++++++++++
frontend/src/settings.js | 24 ++++++++++++++++++++++++
3 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/frontend/src/pages/PlanMeetingPage.jsx b/frontend/src/pages/PlanMeetingPage.jsx
index 6efb256..69c904f 100644
--- a/frontend/src/pages/PlanMeetingPage.jsx
+++ b/frontend/src/pages/PlanMeetingPage.jsx
@@ -1,6 +1,6 @@
-import React, { useState } from 'react'
+import React, { useEffect, useState } from 'react'
import { api } from '../api.js'
-import { notifyTelegramEnabled } from '../settings.js'
+import { notifyTelegramEnabled, prefillLastRoomDisabled } from '../settings.js'
// Formats a Date as the value a `datetime-local` input expects, in local time
// (YYYY-MM-DDTHH:mm).
@@ -27,6 +27,27 @@ export default function PlanMeetingPage({ onCreated, onCancel }) {
const [saving, setSaving] = useState(false)
const [error, setError] = useState('')
+ // Offer the most recently joined room as the default unless the device-local
+ // preference disables it. The recent-rooms list is ordered newest first, and
+ // the room field is only filled while it is still empty so a manual edit is
+ // preserved.
+ useEffect(() => {
+ if (prefillLastRoomDisabled()) return
+ let active = true
+ api
+ .listRooms()
+ .then((rooms) => {
+ const last = rooms?.[0]?.roomName
+ if (active && last) setRoom((current) => current || last)
+ })
+ .catch(() => {
+ // Prefilling is best-effort; leave the field empty on failure.
+ })
+ return () => {
+ active = false
+ }
+ }, [])
+
const create = async (event) => {
event.preventDefault()
setError('')
diff --git a/frontend/src/pages/ProfilePage.jsx b/frontend/src/pages/ProfilePage.jsx
index 359de3e..be9f9d1 100644
--- a/frontend/src/pages/ProfilePage.jsx
+++ b/frontend/src/pages/ProfilePage.jsx
@@ -2,7 +2,9 @@ import React, { useEffect, useRef, useState } from 'react'
import { api } from '../api.js'
import {
notifyTelegramEnabled,
+ prefillLastRoomDisabled,
setNotifyTelegram,
+ setPrefillLastRoomDisabled,
setSkipGuard,
skipGuardEnabled,
} from '../settings.js'
@@ -70,6 +72,7 @@ export default function ProfilePage({ user, onUserChange }) {
// Device/browser-only preferences (stored in localStorage, not on the account).
const [skipGuard, setSkipGuardState] = useState(skipGuardEnabled)
const [notifyTelegram, setNotifyTelegramState] = useState(notifyTelegramEnabled)
+ const [disablePrefillLastRoom, setDisablePrefillLastRoomState] = useState(prefillLastRoomDisabled)
// Query the backend for the avatar limits instead of hardcoding them, so the
// file picker, the size hint and the client-side check always match what the
@@ -300,6 +303,21 @@ export default function ProfilePage({ user, onUserChange }) {
When enabled, the "Send a Telegram notification" checkbox on the
plan-meeting page starts checked. Off by default.
+
+
+ By default the plan-meeting page fills the room field with the most
+ recently joined room. Enable this to leave the field empty instead.
+
)
diff --git a/frontend/src/settings.js b/frontend/src/settings.js
index 2481729..b0a176a 100644
--- a/frontend/src/settings.js
+++ b/frontend/src/settings.js
@@ -3,6 +3,7 @@
const SKIP_GUARD_KEY = 'gochat.skipGuard'
const NOTIFY_TELEGRAM_KEY = 'gochat.notifyTelegram'
+const PREFILL_LAST_ROOM_KEY = 'gochat.disablePrefillLastRoom'
// When enabled, opening a room URL joins it directly instead of running the
// recent-room guard.
@@ -50,3 +51,26 @@ export function setNotifyTelegram(enabled) {
// Ignore: the preference simply will not persist.
}
}
+
+// When enabled, the plan-meeting page no longer prefills the room field with
+// the most recently joined room. Off by default (prefilling is on).
+export function prefillLastRoomDisabled() {
+ try {
+ return window.localStorage.getItem(PREFILL_LAST_ROOM_KEY) === '1'
+ } catch {
+ // Storage can be unavailable (private mode, disabled cookies).
+ return false
+ }
+}
+
+export function setPrefillLastRoomDisabled(disabled) {
+ try {
+ if (disabled) {
+ window.localStorage.setItem(PREFILL_LAST_ROOM_KEY, '1')
+ } else {
+ window.localStorage.removeItem(PREFILL_LAST_ROOM_KEY)
+ }
+ } catch {
+ // Ignore: the preference simply will not persist.
+ }
+}