A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: fix ts errors
Ammar Ahmed868ae597aec8
diff --git a/apps/mobile/app/common/filesystem/index.ts b/apps/mobile/app/common/filesystem/index.tsindex 676ec4665..e236bbe3a 100644--- a/apps/mobile/app/common/filesystem/index.ts+++ b/apps/mobile/app/common/filesystem/index.ts@@ -47,7 +47,8 @@ export default {deleteCacheFileByPath,getCacheSize,requestPermission,- checkAndCreateDir+ checkAndCreateDir,+ getUploadedFileSize};export const FileStorage: IFileStorage = {diff --git a/apps/mobile/app/components/dialog/base-dialog.tsx b/apps/mobile/app/components/dialog/base-dialog.tsxindex f6be7ea6b..0ffa62fb4 100644--- a/apps/mobile/app/components/dialog/base-dialog.tsx+++ b/apps/mobile/app/components/dialog/base-dialog.tsx@@ -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;diff --git a/apps/mobile/app/components/dialogs/color-picker/index.tsx b/apps/mobile/app/components/dialogs/color-picker/index.tsxindex d6b29f2fd..734c7e3f0 100644--- a/apps/mobile/app/components/dialogs/color-picker/index.tsx+++ b/apps/mobile/app/components/dialogs/color-picker/index.tsx@@ -179,6 +179,7 @@ const ColorPicker = ({title: title.current,colorCode: selectedColor});+ if (!id) return;useRelationStore.getState().update();useMenuStore.getState().setColorNotes();setVisible(false);diff --git a/apps/mobile/app/components/list/list-item.wrapper.tsx b/apps/mobile/app/components/list/list-item.wrapper.tsxindex 209b00ee4..aad136170 100644--- a/apps/mobile/app/components/list/list-item.wrapper.tsx+++ b/apps/mobile/app/components/list/list-item.wrapper.tsx@@ -297,7 +297,6 @@ function getDate(item: Item, groupType?: GroupingKey): number {groupType? db.settings.getGroupOptions(groupType): {- groupBy: "default",sortBy: "dateEdited",sortDirection: "desc"},diff --git a/apps/mobile/app/components/premium/pricing-plans.tsx b/apps/mobile/app/components/premium/pricing-plans.tsxindex a7ce08fd7..d0ef060da 100644--- a/apps/mobile/app/components/premium/pricing-plans.tsx+++ b/apps/mobile/app/components/premium/pricing-plans.tsx@@ -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();diff --git a/apps/mobile/app/components/sheets/export-notes/share.js b/apps/mobile/app/components/sheets/export-notes/share.jsxsimilarity index 100%rename from apps/mobile/app/components/sheets/export-notes/share.jsrename to apps/mobile/app/components/sheets/export-notes/share.jsxdiff --git a/apps/mobile/app/components/sheets/publish-note/index.tsx b/apps/mobile/app/components/sheets/publish-note/index.tsxindex 581d21cba..042c7b6e7 100644--- a/apps/mobile/app/components/sheets/publish-note/index.tsx+++ b/apps/mobile/app/components/sheets/publish-note/index.tsx@@ -150,7 +150,7 @@ const PublishNoteSheet = ({</View>) : (<>- {isPublished && (+ {isPublished && publishUrl ? (<Viewstyle={{flexDirection: "row",@@ -204,7 +204,7 @@ const PublishNoteSheet = ({name="content-copy"/></View>- )}+ ) : null}<TouchableOpacityonPress={() => {diff --git a/apps/mobile/app/components/sheets/reminder/index.tsx b/apps/mobile/app/components/sheets/reminder/index.tsxindex b100d0d68..f9669e2d7 100644--- a/apps/mobile/app/components/sheets/reminder/index.tsx+++ b/apps/mobile/app/components/sheets/reminder/index.tsx@@ -556,9 +556,9 @@ export default function ReminderSheet({{Object.keys(ReminderNotificationModes).map((mode) => (<Buttonkey={mode}- title={strings.reminderNotificationModes[+ title={strings.reminderNotificationModes(mode as keyof typeof ReminderNotificationModes- ]()}+ )}style={{marginRight: 12,borderRadius: 100diff --git a/apps/mobile/app/components/ui/animated-button/index.tsx b/apps/mobile/app/components/ui/animated-button/index.tsxdeleted file mode 100644index d041d71cb..000000000--- a/apps/mobile/app/components/ui/animated-button/index.tsx+++ /dev/null@@ -1,158 +0,0 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2023 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--import React from "react";-import { ActivityIndicator, DimensionValue, ViewStyle } from "react-native";-import Animated, {- FadeIn,- FadeOut,- Layout,- LightSpeedInLeft-} from "react-native-reanimated";-import Icon from "react-native-vector-icons/MaterialCommunityIcons";-import { SIZE } from "../../../utils/size";-import NativeTooltip from "../../../utils/tooltip";-import { ButtonProps } from "../button";-import { Pressable, useButton } from "../pressable";-import Heading from "../typography/heading";-import Paragraph from "../typography/paragraph";-const AnimatedIcon = Animated.createAnimatedComponent(Icon);--export const AnimatedButton = ({- height = 45,- width = null,- onPress,- loading = false,- title = null,- icon,- fontSize = SIZE.sm,- type = "transparent",- iconSize = SIZE.md,- style = {},- accentColor = "accent",- accentText = "light",- onLongPress,- tooltipText,- textStyle,- iconPosition = "left",- buttonType,- bold,- iconColor,- fwdRef,- ...restProps-}: ButtonProps) => {- const { text } = useButton({- type,- accent: accentColor,- text: accentText- });- const textColor = buttonType?.text ? buttonType.text : text;- const Component = bold ? Heading : Paragraph;-- return (- <Animated.View- entering={FadeIn}- exiting={FadeOut}- layout={Layout.springify()}- >- <Pressable- {...restProps}- fwdRef={fwdRef}- onPress={onPress}- onLongPress={(event) => {- if (onLongPress) {- onLongPress(event);- return;- }- if (tooltipText) {- NativeTooltip.show(event, tooltipText, NativeTooltip.POSITIONS.TOP);- }- }}- disabled={loading}- type={type}- accentColor={accentColor}- accentText={accentText}- customColor={buttonType?.color}- customSelectedColor={buttonType?.selected}- customOpacity={buttonType?.opacity}- customAlpha={buttonType?.alpha}- style={{- height: height,- width: (width as DimensionValue) || undefined,- paddingHorizontal: 12,- borderRadius: 5,- alignSelf: "center",- justifyContent: "center",- alignItems: "center",- flexDirection: "row",- ...(style as ViewStyle)- }}- >- {loading ? (- <ActivityIndicator color={textColor} size={fontSize + 4} />- ) : null}- {icon && !loading && iconPosition === "left" ? (- <AnimatedIcon- exiting={FadeOut.duration(100)}- entering={LightSpeedInLeft}- layout={Layout.springify()}- name={icon}- style={{- marginRight: 0- }}- color={iconColor || buttonType?.text || textColor}- size={iconSize}- />- ) : null}-- {!title ? null : (- <Component- layout={Layout.springify()}- animated={true}- color={textColor as string}- size={fontSize}- numberOfLines={1}- style={[- {- marginLeft:- icon || (loading && iconPosition === "left") ? 5 : 0,- marginRight:- icon || (loading && iconPosition === "right") ? 5 : 0- },- textStyle- ]}- >- {title}- </Component>- )}-- {icon && !loading && iconPosition === "right" ? (- <Icon- name={icon}- style={{- marginLeft: 0- }}- color={iconColor || buttonType?.text || textColor}- size={iconSize}- />- ) : null}- </Pressable>- </Animated.View>- );-};diff --git a/apps/mobile/app/components/ui/svg/index.tsx b/apps/mobile/app/components/ui/svg/index.tsxindex d51c6929f..2746f3c01 100644--- a/apps/mobile/app/components/ui/svg/index.tsx+++ b/apps/mobile/app/components/ui/svg/index.tsx@@ -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;diff --git a/apps/mobile/app/hooks/use-app-state.ts b/apps/mobile/app/hooks/use-app-state.tsindex 7275b2135..4f36df861 100644--- a/apps/mobile/app/hooks/use-app-state.ts+++ b/apps/mobile/app/hooks/use-app-state.ts@@ -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 };diff --git a/apps/mobile/app/hooks/use-keyboard.ts b/apps/mobile/app/hooks/use-keyboard.tsindex 04b04a4d3..4d0820615 100644--- a/apps/mobile/app/hooks/use-keyboard.ts+++ b/apps/mobile/app/hooks/use-keyboard.ts@@ -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,@@ -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);diff --git a/apps/mobile/app/screens/search/index.tsx b/apps/mobile/app/screens/search/index.tsxindex 1b591ef8a..df1870a60 100644--- a/apps/mobile/app/screens/search/index.tsx+++ b/apps/mobile/app/screens/search/index.tsx@@ -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}`diff --git a/apps/mobile/native/package.json b/apps/mobile/native/package.jsonindex cd570b69c..502527f02 100644--- a/apps/mobile/native/package.json+++ b/apps/mobile/native/package.json@@ -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",diff --git a/apps/mobile/package-lock.json b/apps/mobile/package-lock.jsonindex 365e1be88..85260ec2b 100644--- a/apps/mobile/package-lock.json+++ b/apps/mobile/package-lock.json@@ -1,12 +1,12 @@{"name": "@notesnook/mobile",- "version": "3.0.23",+ "version": "3.0.24","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "@notesnook/mobile",- "version": "3.0.23",+ "version": "3.0.24","hasInstallScript": true,"license": "GPL-3.0-or-later","workspaces": [@@ -27,11 +27,13 @@"@trpc/client": "^10.45.2","@trpc/react-query": "^10.45.2","@trpc/server": "^10.45.2",+ "@types/validator": "^13.12.2","diffblazer": "^1.0.1","react": "18.2.0","react-native": "0.74.5"},"devDependencies": {+ "@types/react": "^18.2.39","fonteditor-core": "^2.1.11","listr": "^0.14.3","otplib": "12.0.1",@@ -29007,7 +29009,6 @@"@types/html-to-text": "^8.0.1","@types/jest": "^29.5.14","@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",@@ -34355,12 +34356,13 @@"license": "MIT"},"node_modules/@types/react": {- "version": "18.2.13",+ "version": "18.3.18",+ "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.18.tgz",+ "integrity": "sha512-t4yC+vtgnkYjNSKlFx1jkAhH8LgTo2N/7Qvi83kdEaUtMDiwpbLAktKDaAMlRcJ5eSxZkH74eEGt1ky31d7kfQ==","devOptional": true,"license": "MIT","dependencies": {"@types/prop-types": "*",- "@types/scheduler": "*","csstype": "^3.0.2"}},@@ -34397,11 +34399,6 @@"@types/react": "*"}},- "node_modules/@types/scheduler": {- "version": "0.16.3",- "devOptional": true,- "license": "MIT"- },"node_modules/@types/semver": {"version": "7.5.0","dev": true,@@ -34411,6 +34408,12 @@"version": "2.0.1","license": "MIT"},+ "node_modules/@types/validator": {+ "version": "13.12.2",+ "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.12.2.tgz",+ "integrity": "sha512-6SlHBzUW8Jhf3liqrGGXyTJSIFe4nqlJ5A5KaMZ2l/vbM3Wh3KSybots/wfWVzNLK4D1NZluDlSQIbIEPx6oyA==",+ "license": "MIT"+ },"node_modules/@types/yargs": {"version": "17.0.24","license": "MIT",diff --git a/apps/mobile/package.json b/apps/mobile/package.jsonindex 07f85a0e8..12e9d72dd 100644--- a/apps/mobile/package.json+++ b/apps/mobile/package.json@@ -24,6 +24,7 @@"release-android-bundle": "cd native/android && ./gradlew bundleRelease --no-daemon"},"devDependencies": {+ "@types/react": "^18.2.39","fonteditor-core": "^2.1.11","listr": "^0.14.3","otplib": "12.0.1",@@ -37,19 +38,20 @@"dependencies": {"@notesnook/common": "file:../../packages/common","@notesnook/core": "file:../../packages/core",+ "@notesnook/crypto": "file:../../packages/crypto","@notesnook/editor": "file:../../packages/editor","@notesnook/editor-mobile": "file:../../packages/editor-mobile","@notesnook/intl": "file:../../packages/intl","@notesnook/logger": "file:../../packages/logger","@notesnook/theme": "file:../../packages/theme","@notesnook/themes-server": "file:../../servers/themes",- "@notesnook/crypto": "file:../../packages/crypto",- "diffblazer": "^1.0.1",- "react": "18.2.0",- "react-native": "0.74.5",+ "@tanstack/react-query": "^4.36.1","@trpc/client": "^10.45.2","@trpc/react-query": "^10.45.2","@trpc/server": "^10.45.2",- "@tanstack/react-query": "^4.36.1"+ "@types/validator": "^13.12.2",+ "diffblazer": "^1.0.1",+ "react": "18.2.0",+ "react-native": "0.74.5"}-}\ No newline at end of file+}diff --git a/apps/mobile/share/search.tsx b/apps/mobile/share/search.tsxindex b6f5d4616..90f2f4642 100644--- a/apps/mobile/share/search.tsx+++ b/apps/mobile/share/search.tsx@@ -496,6 +496,7 @@ export const Search = ({const tagId = await db.tags.add({title: searchKeyword});+ if (!tagId) return;SearchSetters.selectTags(tagId);onSearch();checkQueryExists(searchKeyword);diff --git a/apps/mobile/tsconfig.json b/apps/mobile/tsconfig.jsonindex 815fbc48f..d2aad52bc 100644--- a/apps/mobile/tsconfig.json+++ b/apps/mobile/tsconfig.json@@ -20,5 +20,5 @@"maxNodeModuleJsDepth": 5,"downlevelIteration": true},- "exclude": ["native"]+ "exclude": ["native", "e2e"]}diff --git a/packages/core/src/api/index.ts b/packages/core/src/api/index.tsindex 5301da7be..0f2533f5b 100644--- a/packages/core/src/api/index.ts+++ b/packages/core/src/api/index.ts@@ -189,7 +189,7 @@ class Database {tokenManager = new TokenManager(this.kv);mfa = new MFAManager(this.tokenManager);subscriptions = new Subscriptions(this.tokenManager);- offers = new Offers();+ offers = Offers;debug = new Debug();pricing = Pricing;