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:
@@ -1,6 +1,9 @@
|
||||
'use client'
|
||||
import {ChangeEvent, forwardRef, useContext, useEffect, useImperativeHandle, useState} from "react";
|
||||
import OfflineContext, {OfflineContextType} from '@/context/OfflineContext';
|
||||
import {isDesktop} from '@/lib/configs';
|
||||
import {apiGet, apiPut} from '@/lib/api/client';
|
||||
import {getSeriesDetail, updateSeries} from '@/lib/tauri';
|
||||
import {AlertContext, AlertContextProps} from "@/context/AlertContext";
|
||||
import {SessionContext, SessionContextProps} from "@/context/SessionContext";
|
||||
import TextInput from "@/components/form/TextInput";
|
||||
@@ -20,6 +23,8 @@ function BasicSeriesInformation(props: object, ref: React.Ref<{ handleSave: () =
|
||||
const {seriesId}: SeriesContextProps = useContext<SeriesContextProps>(SeriesContext);
|
||||
const userToken: string = session?.accessToken ? session?.accessToken : '';
|
||||
const {errorMessage, successMessage}: AlertContextProps = useContext<AlertContextProps>(AlertContext);
|
||||
const {isCurrentlyOffline} = useContext(OfflineContext);
|
||||
const useLocal: boolean = isDesktop && isCurrentlyOffline();
|
||||
|
||||
const [isLoading, setIsLoading] = useState<boolean>(true);
|
||||
const [name, setName] = useState<string>('');
|
||||
@@ -34,12 +39,9 @@ function BasicSeriesInformation(props: object, ref: React.Ref<{ handleSave: () =
|
||||
async function loadSeriesData(): Promise<void> {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const response: SeriesDetailResponse = await apiGet<SeriesDetailResponse>(
|
||||
'series/detail',
|
||||
userToken,
|
||||
lang,
|
||||
{seriesid: seriesId}
|
||||
);
|
||||
const response: SeriesDetailResponse = useLocal
|
||||
? await getSeriesDetail(seriesId) as SeriesDetailResponse
|
||||
: await apiGet<SeriesDetailResponse>('series/detail', userToken, lang, {seriesid: seriesId});
|
||||
if (response) {
|
||||
setName(response.name);
|
||||
setDescription(response.description || '');
|
||||
@@ -67,11 +69,9 @@ function BasicSeriesInformation(props: object, ref: React.Ref<{ handleSave: () =
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response: SeriesUpdateResponse = await apiPut<SeriesUpdateResponse>('series/update', {
|
||||
seriesId: seriesId,
|
||||
name: name,
|
||||
description: description
|
||||
}, userToken, lang);
|
||||
const response: SeriesUpdateResponse = useLocal
|
||||
? {success: await updateSeries({seriesId, name, description})} as SeriesUpdateResponse
|
||||
: await apiPut<SeriesUpdateResponse>('series/update', {seriesId, name, description}, userToken, lang);
|
||||
if (!response.success) {
|
||||
errorMessage(t('seriesBasicInformation.error.update'));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user