Skip to content

Commit

Permalink
No default repo
Browse files Browse the repository at this point in the history
  • Loading branch information
nyagami committed Jun 23, 2024
1 parent ea33690 commit 0bda5fd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/database/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import {
} from './tables/ChapterTable';
import { dbTxnErrorCallback } from './utils/helpers';
import { noop } from 'lodash-es';
import {
createRepositoryTableQuery,
insertDefaultRepository,
} from './tables/RepositoryTable';
import { createRepositoryTableQuery } from './tables/RepositoryTable';

const dbName = 'lnreader.db';

Expand All @@ -35,7 +32,6 @@ export const createTables = () => {

db.transaction(tx => {
tx.executeSql(createRepositoryTableQuery);
tx.executeSql(insertDefaultRepository);
});
};

Expand Down
3 changes: 0 additions & 3 deletions src/database/tables/RepositoryTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@ export const createRepositoryTableQuery = `
UNIQUE(url)
);
`;

export const insertDefaultRepository =
'INSERT OR REPLACE INTO Repository (id, url) VALUES (1, "https://raw.githubusercontent.com/LNReader/lnreader-plugins/plugins/v2.2.0/.dist/plugins.min.json");';
25 changes: 25 additions & 0 deletions src/navigators/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect } from 'react';

import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import * as Linking from 'expo-linking';

import {
changeNavigationBarColor,
Expand Down Expand Up @@ -37,9 +38,15 @@ import { RootStackParamList } from './types';
import Color from 'color';
import { useMMKVBoolean } from 'react-native-mmkv';
import OnboardingScreen from '@screens/onboarding/OnboardingScreen';
import {
createRepository,
isRepoUrlDuplicate,
} from '@database/queries/RepositoryQueries';
import { showToast } from '@utils/showToast';
const Stack = createStackNavigator<RootStackParamList>();

const MainNavigator = () => {
const url = Linking.useURL();
const theme = useTheme();
const { updateLibraryOnLaunch } = useAppSettings();
const { refreshPlugins } = usePlugins();
Expand All @@ -66,6 +73,24 @@ const MainNavigator = () => {
}
}, [isOnboarded]);

useEffect(() => {
if (url) {
const { hostname, path, queryParams } = Linking.parse(url);
if (hostname === 'repo' && path === 'add') {
const repoUrl = queryParams?.url;
if (typeof repoUrl === 'string') {
isRepoUrlDuplicate(repoUrl).then(isDuplicated => {
if (isDuplicated) {
showToast('A respository with this url already exists!');
} else {
createRepository(repoUrl);
}
});
}
}
}
}, [url]);

const { isNewVersion, latestRelease } = useGithubUpdateChecker();

if (!isOnboarded) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const RepositoryCard: FC<RepositoryCardProps> = ({
style={styles.manageBtn}
onPress={showDeleteRepositoryModal}
theme={theme}
disabled={repository.id === 1} /** Disabled for Default Repository */
/>
</View>
<Portal>
Expand Down

0 comments on commit 0bda5fd

Please sign in to comment.