Skip to content

Commit

Permalink
mobile: fix ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Dec 26, 2024
1 parent 59d3e06 commit 868ae59
Show file tree
Hide file tree
Showing 19 changed files with 76 additions and 209 deletions.
3 changes: 2 additions & 1 deletion apps/mobile/app/common/filesystem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export default {
deleteCacheFileByPath,
getCacheSize,
requestPermission,
checkAndCreateDir
checkAndCreateDir,
getUploadedFileSize
};

export const FileStorage: IFileStorage = {
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/app/components/dialog/base-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { useAppState } from "../../hooks/use-app-state";

export interface BaseDialogProps extends PropsWithChildren {
animation?: "fade" | "none" | "slide" | undefined;
visible: boolean;
visible?: boolean;
onRequestClose?: () => void;
onShow?: () => void;
premium?: boolean;
Expand Down
1 change: 1 addition & 0 deletions apps/mobile/app/components/dialogs/color-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ const ColorPicker = ({
title: title.current,
colorCode: selectedColor
});
if (!id) return;
useRelationStore.getState().update();
useMenuStore.getState().setColorNotes();
setVisible(false);
Expand Down
1 change: 0 additions & 1 deletion apps/mobile/app/components/list/list-item.wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ function getDate(item: Item, groupType?: GroupingKey): number {
groupType
? db.settings.getGroupOptions(groupType)
: {
groupBy: "default",
sortBy: "dateEdited",
sortDirection: "desc"
},
Expand Down
5 changes: 4 additions & 1 deletion apps/mobile/app/components/premium/pricing-plans.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ export const PricingPlans = ({
if (code.startsWith("com.streetwriters.notesnook")) {
skuId = code;
} else {
skuId = await db.offers?.getCode(code.split(":")[0], Platform.OS);
skuId = await db.offers?.getCode(
code.split(":")[0],
Platform.OS as "ios" | "android"
);
}

const products = await PremiumService.getProducts();
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile/app/components/sheets/publish-note/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const PublishNoteSheet = ({
</View>
) : (
<>
{isPublished && (
{isPublished && publishUrl ? (
<View
style={{
flexDirection: "row",
Expand Down Expand Up @@ -204,7 +204,7 @@ const PublishNoteSheet = ({
name="content-copy"
/>
</View>
)}
) : null}

<TouchableOpacity
onPress={() => {
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile/app/components/sheets/reminder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,9 @@ export default function ReminderSheet({
{Object.keys(ReminderNotificationModes).map((mode) => (
<Button
key={mode}
title={strings.reminderNotificationModes[
title={strings.reminderNotificationModes(
mode as keyof typeof ReminderNotificationModes
]()}
)}
style={{
marginRight: 12,
borderRadius: 100
Expand Down
158 changes: 0 additions & 158 deletions apps/mobile/app/components/ui/animated-button/index.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions apps/mobile/app/components/ui/svg/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import React from "react";
import { View } from "react-native";
import { DimensionValue, View } from "react-native";
import { SvgXml } from "./lazy";
export const SvgView = ({
width = 250,
height = 250,
src
}: {
width?: number | string;
height?: number | number;
width?: DimensionValue;
height?: DimensionValue;
src?: string;
}) => {
if (!src) return null;
Expand Down
11 changes: 2 additions & 9 deletions apps/mobile/app/hooks/use-app-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,11 @@ export function useAppState() {
const subscription = AppState.addEventListener("change", onChange);

return () => {
// @ts-expect-error - React Native >= 0.65
if (typeof subscription?.remove === "function") {
// @ts-expect-error - need update @types/[email protected]
subscription.remove();
} else {
// React Native < 0.65
AppState.removeEventListener("change", onChange);
}
subscription.remove();
};
}, []);

return appState;
}

export { AppStateStatus };
export type { AppStateStatus };
6 changes: 3 additions & 3 deletions apps/mobile/app/hooks/use-keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { useEffect, useState } from "react";
import { Keyboard, KeyboardEventListener, ScreenRect } from "react-native";
import { Keyboard, KeyboardEventListener, KeyboardMetrics } from "react-native";

const emptyCoordinates = Object.freeze({
screenX: 0,
Expand All @@ -34,8 +34,8 @@ const initialValue = {
export default function useKeyboard() {
const [shown, setShown] = useState(false);
const [coordinates, setCoordinates] = useState<{
start: undefined | ScreenRect;
end: ScreenRect;
start: undefined | KeyboardMetrics;
end: KeyboardMetrics;
}>(initialValue);
const [keyboardHeight, setKeyboardHeight] = useState<number>(0);

Expand Down
41 changes: 32 additions & 9 deletions apps/mobile/app/screens/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,38 @@ export const Search = ({ route, navigation }: NavigationProps<"Search">) => {
}
try {
setLoading(true);
const type =
route.params.type === "trash"
? "trash"
: ((route.params?.type + "s") as keyof typeof db.lookup);
console.log(`Searching in ${type} for ${query}`);
const results = await db.lookup[type](
query,
route.params.items as FilteredSelector<Note>
).sorted();
let results: VirtualizedGrouping<Item> | undefined;

switch (route.params.type) {
case "note":
results = await db.lookup
.notes(query, route.params.items as FilteredSelector<Note>)
.sorted();
break;
case "notebook":
results = await db.lookup.notebooks(query).sorted();
break;
case "tag":
results = await db.lookup.tags(query).sorted();
break;
case "reminder":
results = await db.lookup.reminders(query).sorted();
break;
case "trash":
results = await db.lookup.trash(query).sorted();
break;
case "attachment":
results = await db.lookup.attachments(query).sorted();
break;
default:
results = undefined;
}

if (!results) {
setSearchStatus(strings.noResultsFound(query));
setLoading(false);
return;
}

console.log(
`Found ${results.placeholders?.length} results for ${query}`
Expand Down
1 change: 0 additions & 1 deletion apps/mobile/native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"@tsconfig/react-native": "^3.0.2",
"@types/html-to-text": "^8.0.1",
"@types/metro-config": "^0.76.3",
"@types/react": "^18.2.6",
"@types/react-native": "^0.69.1",
"@types/react-native-vector-icons": "^6.4.10",
"@types/react-test-renderer": "^18.0.0",
Expand Down
Loading

0 comments on commit 868ae59

Please sign in to comment.