feat: Add chat seperator and restore last viewed chat on restart

This commit is contained in:
2026-04-02 00:47:44 +02:00
parent bbb6deb0a2
commit 5d7e045764
10 changed files with 412 additions and 18 deletions

View File

@@ -9,6 +9,29 @@
</div>
<div class="space-y-3">
<div class="rounded-lg border border-border bg-secondary/20 p-4">
<div class="flex items-center justify-between gap-4">
<div>
<p class="text-sm font-medium text-foreground">Reopen last chat on launch</p>
<p class="text-xs text-muted-foreground">Open the same server and text channel the next time MetoYou starts.</p>
</div>
<label class="relative inline-flex cursor-pointer items-center">
<input
type="checkbox"
[checked]="reopenLastViewedChat()"
(change)="onReopenLastViewedChatChange($event)"
id="general-reopen-last-chat-toggle"
aria-label="Toggle reopen last chat on launch"
class="sr-only peer"
/>
<div
class="w-10 h-5 bg-secondary rounded-full peer peer-checked:bg-primary peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-0.5 after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all"
></div>
</label>
</div>
</div>
<div
class="rounded-lg border border-border bg-secondary/20 p-4 transition-opacity"
[class.opacity-60]="!isElectron"

View File

@@ -9,6 +9,10 @@ import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucidePower } from '@ng-icons/lucide';
import type { DesktopSettingsSnapshot } from '../../../../core/platform/electron/electron-api.models';
import {
loadGeneralSettingsFromStorage,
saveGeneralSettingsToStorage
} from '../../../../infrastructure/persistence';
import { ElectronBridgeService } from '../../../../core/platform/electron/electron-bridge.service';
import { PlatformService } from '../../../../core/platform';
@@ -28,17 +32,29 @@ export class GeneralSettingsComponent {
private electronBridge = inject(ElectronBridgeService);
readonly isElectron = this.platform.isElectron;
reopenLastViewedChat = signal(true);
autoStart = signal(false);
closeToTray = signal(true);
savingAutoStart = signal(false);
savingCloseToTray = signal(false);
constructor() {
this.loadGeneralSettings();
if (this.isElectron) {
void this.loadDesktopSettings();
}
}
onReopenLastViewedChatChange(event: Event): void {
const input = event.target as HTMLInputElement;
const settings = saveGeneralSettingsToStorage({
reopenLastViewedChat: !!input.checked
});
this.reopenLastViewedChat.set(settings.reopenLastViewedChat);
}
async onAutoStartChange(event: Event): Promise<void> {
const input = event.target as HTMLInputElement;
const enabled = !!input.checked;
@@ -99,6 +115,12 @@ export class GeneralSettingsComponent {
} catch {}
}
private loadGeneralSettings(): void {
const settings = loadGeneralSettingsFromStorage();
this.reopenLastViewedChat.set(settings.reopenLastViewedChat);
}
private applyDesktopSettings(snapshot: DesktopSettingsSnapshot): void {
this.autoStart.set(snapshot.autoStart);
this.closeToTray.set(snapshot.closeToTray);