From f6c68aa7d59ad0a1dd238bef2c603bccc32c5b25 Mon Sep 17 00:00:00 2001
From: Mikhail Romanko
Date: Sun, 25 Oct 2026 10:07:18 +0300
Subject: [PATCH] Reduce grace period, add setting for telegram notifications
---
frontend/src/pages/MeetingsPage.jsx | 12 ++++++------
frontend/src/pages/PlanMeetingPage.jsx | 7 ++++---
frontend/src/pages/ProfilePage.jsx | 23 ++++++++++++++++++++++-
frontend/src/pages/RoomsPage.jsx | 11 ++++++-----
frontend/src/settings.js | 25 +++++++++++++++++++++++++
5 files changed, 63 insertions(+), 15 deletions(-)
diff --git a/frontend/src/pages/MeetingsPage.jsx b/frontend/src/pages/MeetingsPage.jsx
index 93ece9a..e4d7676 100644
--- a/frontend/src/pages/MeetingsPage.jsx
+++ b/frontend/src/pages/MeetingsPage.jsx
@@ -2,13 +2,13 @@ import React, { useCallback, useEffect, useState } from 'react'
import { api } from '../api.js'
// Meetings are split into three buckets relative to the current time:
-// * current - occurred within the past day, or happens within the next week
-// (the default, always visible view). Including the last day
-// keeps meetings that just happened visible for a while.
-// * past - occurred more than a day ago
+// * current - occurred within the past 30 minutes, or happens within the next
+// week (the default, always visible view). The short grace period
+// keeps a meeting that just started visible for a while.
+// * past - occurred more than 30 minutes ago
// * future - happens more than a week from now
const WEEK_MS = 7 * 24 * 60 * 60 * 1000
-const DAY_MS = 24 * 60 * 60 * 1000
+const CURRENT_GRACE_MS = 30 * 60 * 1000
function categorize(meetings) {
const now = Date.now()
@@ -17,7 +17,7 @@ function categorize(meetings) {
const future = []
for (const meeting of meetings) {
const at = new Date(meeting.scheduledAt).getTime()
- if (at < now - DAY_MS) {
+ if (at < now - CURRENT_GRACE_MS) {
past.push(meeting)
} else if (at <= now + WEEK_MS) {
current.push(meeting)
diff --git a/frontend/src/pages/PlanMeetingPage.jsx b/frontend/src/pages/PlanMeetingPage.jsx
index 0333939..6efb256 100644
--- a/frontend/src/pages/PlanMeetingPage.jsx
+++ b/frontend/src/pages/PlanMeetingPage.jsx
@@ -1,5 +1,6 @@
import React, { useState } from 'react'
import { api } from '../api.js'
+import { notifyTelegramEnabled } from '../settings.js'
// Formats a Date as the value a `datetime-local` input expects, in local time
// (YYYY-MM-DDTHH:mm).
@@ -20,9 +21,9 @@ export default function PlanMeetingPage({ onCreated, onCancel }) {
// When checked the author is recorded as joining straight away. Checked by
// default, since planning a meeting usually means you intend to attend.
const [autoJoin, setAutoJoin] = useState(true)
- // When checked the Telegram bot announces the meeting. Checked by default;
- // users uncheck it to create a meeting silently.
- const [hasNotification, setHasNotification] = useState(true)
+ // When checked the Telegram bot announces the meeting. Off by default; the
+ // profile's device-local preference decides whether it starts checked.
+ const [hasNotification, setHasNotification] = useState(notifyTelegramEnabled)
const [saving, setSaving] = useState(false)
const [error, setError] = useState('')
diff --git a/frontend/src/pages/ProfilePage.jsx b/frontend/src/pages/ProfilePage.jsx
index 34629e7..359de3e 100644
--- a/frontend/src/pages/ProfilePage.jsx
+++ b/frontend/src/pages/ProfilePage.jsx
@@ -1,6 +1,11 @@
import React, { useEffect, useRef, useState } from 'react'
import { api } from '../api.js'
-import { skipGuardEnabled, setSkipGuard } from '../settings.js'
+import {
+ notifyTelegramEnabled,
+ setNotifyTelegram,
+ setSkipGuard,
+ skipGuardEnabled,
+} from '../settings.js'
// Fallback used until GET /api/config answers. Kept in sync with the backend
// defaults (user.MaxImageSize and the accepted image formats).
@@ -64,6 +69,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)
// 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
@@ -279,6 +285,21 @@ export default function ProfilePage({ user, onUserChange }) {
When enabled, opening a room link joins it directly instead of asking
whether to rejoin your most recent room.
+
+
+ When enabled, the "Send a Telegram notification" checkbox on the
+ plan-meeting page starts checked. Off by default.
+
)
diff --git a/frontend/src/pages/RoomsPage.jsx b/frontend/src/pages/RoomsPage.jsx
index 30423d3..5ec158f 100644
--- a/frontend/src/pages/RoomsPage.jsx
+++ b/frontend/src/pages/RoomsPage.jsx
@@ -2,9 +2,10 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'
import { api } from '../api.js'
import { skipGuardEnabled, setSkipGuard } from '../settings.js'
-// Meetings on the rooms page stay visible for a day after they started, so a
-// meeting the user just missed (or is still running) can still be rejoined.
-const DAY_MS = 24 * 60 * 60 * 1000
+// Meetings on the rooms page stay visible for 30 minutes after they started, so
+// a meeting that just started (or is about to) can still be joined, while
+// anything older is dropped from the list.
+const CURRENT_GRACE_MS = 30 * 60 * 1000
// Room names are case-sensitive on the Jitsi side, so we only trim, collapse
// disallowed characters into a dash, and strip leading/trailing dashes. Case is
@@ -192,8 +193,8 @@ export default function RoomsPage({ room: routeRoom, noguard, onNavigate }) {
}
// Meetings the user committed to attend that are upcoming or started within
- // the last day (long-past meetings drop off).
- const cutoff = Date.now() - DAY_MS
+ // the last 30 minutes (older meetings drop off).
+ const cutoff = Date.now() - CURRENT_GRACE_MS
const joiningMeetings = meetings.filter(
(meeting) =>
meeting.myVote === 'join' &&
diff --git a/frontend/src/settings.js b/frontend/src/settings.js
index 78fae70..2481729 100644
--- a/frontend/src/settings.js
+++ b/frontend/src/settings.js
@@ -2,6 +2,7 @@
// never sent to the backend; they live in localStorage for this browser only.
const SKIP_GUARD_KEY = 'gochat.skipGuard'
+const NOTIFY_TELEGRAM_KEY = 'gochat.notifyTelegram'
// When enabled, opening a room URL joins it directly instead of running the
// recent-room guard.
@@ -25,3 +26,27 @@ export function setSkipGuard(enabled) {
// Ignore: the preference simply will not persist.
}
}
+
+// When enabled, the "Send a Telegram notification" checkbox on the plan-meeting
+// page starts checked. Off by default so creating a meeting does not announce it
+// in the Telegram group unless the user opts in.
+export function notifyTelegramEnabled() {
+ try {
+ return window.localStorage.getItem(NOTIFY_TELEGRAM_KEY) === '1'
+ } catch {
+ // Storage can be unavailable (private mode, disabled cookies).
+ return false
+ }
+}
+
+export function setNotifyTelegram(enabled) {
+ try {
+ if (enabled) {
+ window.localStorage.setItem(NOTIFY_TELEGRAM_KEY, '1')
+ } else {
+ window.localStorage.removeItem(NOTIFY_TELEGRAM_KEY)
+ }
+ } catch {
+ // Ignore: the preference simply will not persist.
+ }
+}