mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-13 09:19:56 -05:00
Fix: MacOS TitleBar & History Reactive-Glitch
This commit is contained in:
@@ -1,10 +1,27 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
const win = getCurrentWindow();
|
||||
import { platform } from "@tauri-apps/plugin-os";
|
||||
|
||||
const win = getCurrentWindow();
|
||||
const isMac = platform() === "macos";
|
||||
|
||||
let isFullscreen = $state(false);
|
||||
|
||||
onMount(async () => {
|
||||
isFullscreen = await win.isFullscreen();
|
||||
const unlisten = await win.onResized(async () => {
|
||||
isFullscreen = await win.isFullscreen();
|
||||
});
|
||||
return unlisten;
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if !isFullscreen}
|
||||
<div class="bar" data-tauri-drag-region>
|
||||
{#if isMac}<div class="mac-spacer"></div>{/if}
|
||||
<span class="title" data-tauri-drag-region>Moku</span>
|
||||
{#if !isMac}
|
||||
<div class="controls">
|
||||
<button onclick={() => win.minimize()} title="Minimize" aria-label="Minimize">
|
||||
<svg width="10" height="1" viewBox="0 0 10 1">
|
||||
@@ -23,7 +40,9 @@
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.bar {
|
||||
@@ -38,6 +57,12 @@
|
||||
user-select: none;
|
||||
-webkit-app-region: drag;
|
||||
}
|
||||
/* Spacer to clear the native macOS traffic lights (~70px) */
|
||||
.mac-spacer {
|
||||
width: 70px;
|
||||
flex-shrink: 0;
|
||||
-webkit-app-region: drag;
|
||||
}
|
||||
.title {
|
||||
font-family: var(--font-ui);
|
||||
font-size: var(--text-2xs);
|
||||
|
||||
@@ -115,6 +115,9 @@
|
||||
let abortCtrl: AbortController | null = null;
|
||||
let loadingId: number | null = null;
|
||||
let navToken = 0;
|
||||
// Only write history after the user has genuinely moved past the opening page.
|
||||
// Prevents the "started on page 1" entry being saved as last position on close.
|
||||
let hasNavigated = false;
|
||||
|
||||
// ─── Derived ──────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -188,9 +191,10 @@
|
||||
abortCtrl = ctrl;
|
||||
loadingId = id;
|
||||
navToken++;
|
||||
appending = false;
|
||||
markedRead = new Set();
|
||||
loading = true;
|
||||
appending = false;
|
||||
markedRead = new Set();
|
||||
hasNavigated = false;
|
||||
loading = true;
|
||||
error = null;
|
||||
pageGroups = [];
|
||||
pageReady = false;
|
||||
@@ -394,17 +398,33 @@
|
||||
});
|
||||
|
||||
// ─── Progress / history tracking ─────────────────────────────────────────────
|
||||
// Only records history after the user has genuinely navigated (pageNumber > 1,
|
||||
// or scrolled past page 1 in longstrip). This prevents the chapter-open event
|
||||
// from writing "page 1" as the last-read position, which caused the history to
|
||||
// always show the chapter you started on rather than where you left off.
|
||||
|
||||
$effect(() => {
|
||||
if (store.activeChapter && lastPage && store.activeManga) {
|
||||
const chapterId = store.activeChapter.id;
|
||||
const chapterName = store.activeChapter.name;
|
||||
// Use displayChapter, not store.activeChapter — in longstrip with autoNext,
|
||||
// store.activeChapter stays as the chapter you *opened* (e.g. ch61) while
|
||||
// displayChapter tracks visibleChapterId (the chapter actually on screen).
|
||||
// Using store.activeChapter here caused every history write to stamp ch61
|
||||
// even when the user had scrolled all the way to ch72.
|
||||
const ch = displayChapter ?? store.activeChapter;
|
||||
if (ch && lastPage && store.activeManga) {
|
||||
const chapterId = ch.id;
|
||||
const chapterName = ch.name;
|
||||
const mangaId = store.activeManga.id;
|
||||
const mangaTitle = store.activeManga.title;
|
||||
const thumb = store.activeManga.thumbnailUrl;
|
||||
const pageNum = store.pageNumber;
|
||||
const atLast = store.pageNumber === lastPage;
|
||||
|
||||
// Mark that the user has moved past the initial load.
|
||||
if (pageNum > 1) hasNavigated = true;
|
||||
|
||||
untrack(() => {
|
||||
// Skip the very first page-1 write that fires on chapter load.
|
||||
if (!hasNavigated) return;
|
||||
addHistory({ mangaId, mangaTitle, thumbnailUrl: thumb, chapterId, chapterName, pageNumber: pageNum, readAt: Date.now() });
|
||||
if (style !== "longstrip" && store.settings.autoMarkRead && atLast) markChapterRead(chapterId);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user