Refactor decryption logic to handle empty fields consistently across services

This commit is contained in:
natreex
2026-03-22 15:50:36 -04:00
parent 32d2b0fa5a
commit e8aaef108b
26 changed files with 226 additions and 120 deletions

View File

@@ -1,4 +1,5 @@
import React, {useContext, useState} from "react";
import * as tauri from '@/lib/tauri';
import {ChapterProps, chapterVersions} from "@/lib/models/Chapter";
import {ChapterContext} from "@/context/ChapterContext";
import {BookContext} from "@/context/BookContext";
@@ -39,11 +40,16 @@ export default function ScribeControllerBar() {
async function handleChapterVersionChanged(version: number) {
try {
const response: ChapterProps = await System.authGetQueryToServer<ChapterProps>(`chapter/whole`, session.accessToken, lang, {
bookid: book?.bookId,
id: chapter?.chapterId,
version: version,
});
let response: ChapterProps | null;
if (isCurrentlyOffline() || book?.localBook) {
response = await tauri.getWholeChapter(chapter?.chapterId ?? '', version, book?.bookId ?? '');
} else {
response = await System.authGetQueryToServer<ChapterProps>(`chapter/whole`, session.accessToken, lang, {
bookid: book?.bookId,
id: chapter?.chapterId,
version: version,
});
}
if (!response) {
errorMessage(t("controllerBar.chapterNotFound"));
return;