Bump app version to 0.5.0 and implement offline mode support across components
- Added offline detection logic with `OfflineContext` to improve app functionality in offline scenarios. - Integrated Tauri IPC functions to handle local tool settings and character attributes when offline. - Refined indentation logic in `TextEditor` for better compatibility with WebKit engines. - Removed unused `indent` property and related settings in editor components to simplify configuration. - Updated locale files with improved translation consistency and parameterized placeholders.
This commit is contained in:
@@ -10,7 +10,10 @@ import {BookContext, BookContextProps} from "@/context/BookContext";
|
||||
import {SessionContext, SessionContextProps} from "@/context/SessionContext";
|
||||
import {AlertContext, AlertContextProps} from "@/context/AlertContext";
|
||||
import {LangContext, LangContextProps} from "@/context/LangContext";
|
||||
import OfflineContext, {OfflineContextType} from "@/context/OfflineContext";
|
||||
import {isDesktop} from "@/lib/configs";
|
||||
import {apiPatch} from "@/lib/api/client";
|
||||
import {updateBookToolSetting} from "@/lib/tauri";
|
||||
import {SettingRef} from "@/lib/types/settings";
|
||||
import {BookProps} from "@/lib/types/book";
|
||||
|
||||
@@ -73,6 +76,7 @@ export default function BookSettingOption({setting}: BookSettingOptionProps): Re
|
||||
const {session}: SessionContextProps = useContext<SessionContextProps>(SessionContext);
|
||||
const {errorMessage}: AlertContextProps = useContext<AlertContextProps>(AlertContext);
|
||||
const {lang}: LangContextProps = useContext<LangContextProps>(LangContext);
|
||||
const {isCurrentlyOffline} = useContext(OfflineContext);
|
||||
const userToken: string = session?.accessToken ?? '';
|
||||
|
||||
const isToggleable: boolean = setting in toggleableSettings;
|
||||
@@ -107,13 +111,20 @@ export default function BookSettingOption({setting}: BookSettingOptionProps): Re
|
||||
|
||||
async function handleToggleTool(enabled: boolean): Promise<void> {
|
||||
const toolName: ToolName | undefined = toggleableSettings[setting];
|
||||
if (!toolName) return;
|
||||
if (!toolName || !book?.bookId) return;
|
||||
const useLocal: boolean = isDesktop && (isCurrentlyOffline() || !!book.localBook);
|
||||
if (useLocal && toolName === 'quillsense') {
|
||||
errorMessage(t('bookSettingOption.quillsenseOffline'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const result: boolean = await apiPatch<boolean>('book/tool-setting', {
|
||||
bookId: book?.bookId,
|
||||
toolName: toolName,
|
||||
enabled: enabled
|
||||
}, userToken, lang);
|
||||
const result: boolean = useLocal
|
||||
? await updateBookToolSetting(book.bookId, toolName, enabled)
|
||||
: await apiPatch<boolean>('book/tool-setting', {
|
||||
bookId: book.bookId,
|
||||
toolName: toolName,
|
||||
enabled: enabled
|
||||
}, userToken, lang);
|
||||
if (result && setBook && book) {
|
||||
setToolEnabled(enabled);
|
||||
if (toolName === 'quillsense') {
|
||||
|
||||
Reference in New Issue
Block a user