Add room prefiling setting

This commit is contained in:
blankhex committed 2026-10-25 10:11:32 +03:00
1 parent f6c68aa7d5
commit e01393c550
3 files changed
+65 -2

No files matched your search

+23 -2
View File
@@ -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('')