Skip to content

Commit

Permalink
Fix: backup/restore covers | clean build configs (#976)
Browse files Browse the repository at this point in the history
fix: backup/restore covers | clean build configs
  • Loading branch information
nyagami authored Feb 26, 2024
1 parent 3344754 commit 0208b42
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
3 changes: 0 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ dependencies {

implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")

implementation project(':react-native-lottie-splash-screen')
implementation project(':react-native-fs')

def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
Expand Down
6 changes: 0 additions & 6 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,3 @@ includeBuild('../node_modules/react-native-gradle-plugin')

apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
useExpoModules()

include ':react-native-lottie-splash-screen'
project(':react-native-lottie-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-lottie-splash-screen/android')

include ':react-native-fs'
project(':react-native-fs').projectDir = new File(settingsDir, '../node_modules/react-native-fs/android')
13 changes: 10 additions & 3 deletions src/services/backup/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import {
import { BackupCategory } from '@database/types';
import { BackupEntryName } from './types';
import TextFile from '@native/TextFile';
import { AppDownloadFolder } from '@utils/constants/download';

const AppDownloadUriPrefix = 'file://' + AppDownloadFolder;
export const CACHE_DIR_PATH = RNFS.ExternalCachesDirectoryPath + '/BackupData';

const backupMMKVData = () => {
Expand Down Expand Up @@ -74,6 +76,7 @@ export const prepareBackupData = async (cacheDirPath: string) => {
JSON.stringify({
chapters: chapters,
...novel,
cover: novel.cover?.replace(AppDownloadUriPrefix, ''),
}),
);
}
Expand Down Expand Up @@ -115,9 +118,13 @@ export const restoreData = async (cacheDirPath: string) => {
await RNFS.readDir(novelDirPath).then(async items => {
for (const item of items) {
if (item.isFile()) {
await TextFile.readFile(item.path).then(content =>
_restoreNovelAndChapters(JSON.parse(content)),
);
await TextFile.readFile(item.path).then(content => {
const backupNovel = JSON.parse(content);
if (!backupNovel.cover?.startsWith('http')) {
backupNovel.cover = AppDownloadUriPrefix + backupNovel.cover;
}
return _restoreNovelAndChapters(backupNovel);
});
}
}
});
Expand Down

0 comments on commit 0208b42

Please sign in to comment.