Remember last used channel when selected

This commit is contained in:
Jack Kingsman
2026-02-20 17:03:13 -08:00
parent 41bf4eb73a
commit f9eb46f2ab
7 changed files with 409 additions and 20 deletions
+40
View File
@@ -19,6 +19,11 @@ import { Separator } from './ui/separator';
import { toast } from './ui/sonner';
import { api } from '../api';
import { formatTime } from '../utils/messageParser';
import {
captureLastViewedConversationFromHash,
getReopenLastConversationEnabled,
setReopenLastConversationEnabled,
} from '../utils/lastViewedConversation';
// Radio presets for common configurations
interface RadioPreset {
@@ -141,6 +146,9 @@ export function SettingsModal(props: SettingsModalProps) {
const [retentionDays, setRetentionDays] = useState('14');
const [cleaning, setCleaning] = useState(false);
const [autoDecryptOnAdvert, setAutoDecryptOnAdvert] = useState(false);
const [reopenLastConversation, setReopenLastConversation] = useState(
getReopenLastConversationEnabled
);
// Advertisement interval state
const [advertInterval, setAdvertInterval] = useState('0');
@@ -222,6 +230,12 @@ export function SettingsModal(props: SettingsModalProps) {
}
}, [open, pageMode, onRefreshAppSettings]);
useEffect(() => {
if (open || pageMode) {
setReopenLastConversation(getReopenLastConversationEnabled());
}
}, [open, pageMode]);
useEffect(() => {
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return;
@@ -529,6 +543,14 @@ export function SettingsModal(props: SettingsModalProps) {
}
};
const handleToggleReopenLastConversation = (enabled: boolean) => {
setReopenLastConversation(enabled);
setReopenLastConversationEnabled(enabled);
if (enabled) {
captureLastViewedConversationFromHash();
}
};
const handleSaveBotSettings = async () => {
setBusySection('bot');
setSectionError(null);
@@ -1044,6 +1066,24 @@ export function SettingsModal(props: SettingsModalProps) {
</p>
</div>
<Separator />
<div className="space-y-3">
<Label>Interface</Label>
<label className="flex items-center gap-3 cursor-pointer">
<input
type="checkbox"
checked={reopenLastConversation}
onChange={(e) => handleToggleReopenLastConversation(e.target.checked)}
className="w-4 h-4 rounded border-input accent-primary"
/>
<span className="text-sm">Reopen to last viewed channel/conversation</span>
</label>
<p className="text-xs text-muted-foreground">
This applies only to this device/browser. It does not sync to server settings.
</p>
</div>
{getSectionError('database') && (
<div className="text-sm text-destructive">{getSectionError('database')}</div>
)}
+1 -1
View File
@@ -19,7 +19,7 @@ export const SETTINGS_SECTION_LABELS: Record<SettingsSection, string> = {
radio: '📻 Radio',
identity: '🪪 Identity',
connectivity: '📡 Connectivity',
database: '🗄️ Database',
database: '🗄️ Database & Interfacr',
bot: '🤖 Bot',
statistics: '📊 Statistics',
};