Refactor decryption logic to handle empty fields consistently across services
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user