Skip to content

Commit

Permalink
mobile: cleanup console.log statements
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Aug 31, 2022
1 parent 8bd9717 commit dcd5c16
Show file tree
Hide file tree
Showing 70 changed files with 127 additions and 2,191 deletions.
9 changes: 6 additions & 3 deletions apps/mobile/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import { GestureHandlerRootView } from "react-native-gesture-handler";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { withErrorBoundry } from "./components/exception-handler";
import Launcher from "./components/launcher";
import { useAppEvents } from "./hooks/use-app-events";
import { ApplicationHolder } from "./navigation";
import Notifications from "./services/notifications";
import SettingsService from "./services/settings";
import { TipManager } from "./services/tip-manager";
import { useUserStore } from "./stores/use-user-store";
import { useAppEvents } from "./hooks/use-app-events";

SettingsService.init();
SettingsService.checkOrientation();
Expand All @@ -38,9 +38,12 @@ const App = () => {
if (appLockMode && appLockMode !== "none") {
useUserStore.getState().setVerifyUser(true);
}
setTimeout(() => {
setTimeout(async () => {
SettingsService.onFirstLaunch();
Notifications.get();
await Notifications.get();
if (SettingsService.get().notifNotes) {
Notifications.pinQuickNote(true);
}
TipManager.init();
}, 100);
}, []);
Expand Down
10 changes: 0 additions & 10 deletions apps/mobile/app/common/filesystem/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ export async function downloadFile(filename, data, cancelToken) {
if (!data) return false;
let { url, headers } = data;

console.log("downloading file: ", filename, url);
let path = `${cacheDir}/${filename}`;
try {
let exists = await RNFetchBlob.fs.exists(path);
if (exists) {
console.log("file is downloaded");
return true;
}

Expand Down Expand Up @@ -120,7 +118,6 @@ export async function downloadAttachment(hash, global = true) {
return;

let key = await db.attachments.decryptKey(attachment.key);
console.log("attachment key", key);
let info = {
iv: attachment.iv,
salt: attachment.salt,
Expand All @@ -142,10 +139,6 @@ export async function downloadAttachment(hash, global = true) {
});

if (attachment.dateUploaded) {
console.log(
"Deleting attachment after download",
attachment.dateUploaded
);
RNFetchBlob.fs
.unlink(RNFetchBlob.fs.dirs.CacheDir + `/${attachment.metadata.hash}`)
.catch(console.log);
Expand Down Expand Up @@ -177,7 +170,6 @@ export async function downloadAttachment(hash, global = true) {
} catch (e) {
console.log("download attachment error: ", e);
if (attachment.dateUploaded) {
console.log("Deleting attachment on error", attachment.dateUploaded);
RNFetchBlob.fs
.unlink(RNFetchBlob.fs.dirs.CacheDir + `/${attachment.metadata.hash}`)
.catch(console.log);
Expand All @@ -196,8 +188,6 @@ export async function getUploadedFileSize(hash) {
});

const contentLength = parseInt(attachmentInfo.headers?.get("content-length"));
console.log("contentLength:", contentLength, attachmentInfo.headers);

return isNaN(contentLength) ? 0 : contentLength;
}

Expand Down
1 change: 0 additions & 1 deletion apps/mobile/app/common/filesystem/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export async function readEncrypted(filename, key, cipherData) {
},
true
);
console.log("output length: ", output?.length);
return output;
} catch (e) {
RNFetchBlob.fs.unlink(path).catch(console.log);
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile/app/components/announcements/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ export const AnnouncementDialog = () => {

const close = useCallback(() => {
if (visible) {
remove(info.id);
remove(info?.id);
setInfo(null);
setVisible(false);
}
}, [info.id, remove, visible]);
}, [info?.id, remove, visible]);

return (
<BaseDialog
Expand Down
4 changes: 0 additions & 4 deletions apps/mobile/app/components/attachments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,18 @@ export const AttachmentDialog = () => {

const onChangeText = (text) => {
attachmentSearchValue.current = text;
console.log(attachmentSearchValue.current?.length);
if (
!attachmentSearchValue.current ||
attachmentSearchValue.current === ""
) {
console.log("resetting all");
setAttachments([...db.attachments.all]);
}
console.log(attachments.length);
clearTimeout(searchTimer.current);
searchTimer.current = setTimeout(() => {
let results = db.lookup.attachments(
db.attachments.all,
attachmentSearchValue.current
);
console.log("results", results.length, attachments.length);
if (results.length === 0) return;
setAttachments(results);
}, 300);
Expand Down
1 change: 0 additions & 1 deletion apps/mobile/app/components/auth/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ export const Login = ({ changeMode }) => {
await sleep(300);
TwoFactorVerification.present(async (mfa) => {
if (mfa) {
console.log(mfa);
await login(mfa);
} else {
setLoading(false);
Expand Down
2 changes: 0 additions & 2 deletions apps/mobile/app/components/auth/session-expired.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export const SessionExpired = () => {

const open = async () => {
try {
console.log("REQUESTING NEW TOKEN");
let res = await db.user.tokenManager.getToken();
if (!res) throw new Error("no token found");
if (db.user.tokenManager._isTokenExpired(res))
Expand Down Expand Up @@ -162,7 +161,6 @@ export const SessionExpired = () => {
if (e.message === "Multifactor authentication required.") {
TwoFactorVerification.present(async (mfa) => {
if (mfa) {
console.log(mfa);
await login(mfa);
} else {
setLoading(false);
Expand Down
5 changes: 0 additions & 5 deletions apps/mobile/app/components/auth/two-factor.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
const length = currentMethod.method === "recoveryCode" ? 8 : 6;

if (!code.current || code.current.length !== length) return;
console.log(currentMethod.method, code.current);
setLoading(true);
inputRef.current?.blur();
await onMfaLogin(
Expand All @@ -77,7 +76,6 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
code: code.current
},
(result) => {
console.log("result recieved");
if (result) {
eSendEvent(eCloseProgressDialog, "two_factor_verify");
}
Expand Down Expand Up @@ -137,7 +135,6 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
// TODO
setSending(true);
try {
console.log("sending code", currentMethod.method, mfaInfo.token);
await db.mfa.sendCode(currentMethod.method, mfaInfo.token);
start(60);
setSending(false);
Expand Down Expand Up @@ -301,12 +298,10 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
};

TwoFactorVerification.present = (onMfaLogin, data, context) => {
console.log("presenting sheet");
presentSheet({
component: <TwoFactorVerification onMfaLogin={onMfaLogin} mfaInfo={data} />,
context: context || "two_factor_verify",
onClose: () => {
console.log("on close called");
onMfaLogin();
},
disableClosing: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const JumpToSectionDialog = ({ scrollRef, data, type }) => {
let ind = notes.findIndex(
(i) => i.title === item.title && i.type === "header"
);
console.log(scrollRef.current);
scrollRef.current?.scrollToIndex({
index: ind,
animated: true
Expand Down
2 changes: 0 additions & 2 deletions apps/mobile/app/components/dialogs/vault/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ export class VaultDialog extends Component {
type: "error",
context: "local"
});
console.log("returning from here");
return;
} else {
await db.vault.add(this.state.note.id);
Expand Down Expand Up @@ -863,7 +862,6 @@ export class VaultDialog extends Component {
((!this.state.biometricUnlock && !changePassword) || !novault) ? (
<Button
onPress={() => {
console.log(this.state.biometricUnlock);
this.setState({
biometricUnlock: !this.state.biometricUnlock
});
Expand Down
20 changes: 18 additions & 2 deletions apps/mobile/app/components/list-items/notebook/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

import React from "react";
import { NotebookItem } from ".";
import Notebook from "../../../screens/notebook";
import { TopicNotes } from "../../../screens/notes/topic-notes";
import { ToastEvent } from "../../../services/event-manager";
import Navigation from "../../../services/navigation";
Expand All @@ -30,6 +29,23 @@ import { db } from "../../../common/database";
import { presentDialog } from "../../dialog/functions";
import SelectionWrapper from "../selection-wrapper";

const navigateToNotebook = (item, canGoBack) => {
if (!item) return;
Navigation.navigate <
"Notebook" >
({
title: item.title,
name: "Notebook",
id: item.id,
type: "notebook"
},
{
title: item.title,
item: item,
canGoBack
});
};

export const openNotebookTopic = (item) => {
const isTrash = item.type === "trash";
if (history.selectedItemsList.length > 0 && history.selectionMode) {
Expand Down Expand Up @@ -79,7 +95,7 @@ export const openNotebookTopic = (item) => {
if (item.type === "topic") {
TopicNotes.navigate(item, true);
} else {
Notebook.navigate(item, true);
navigateToNotebook(item, true);
}
};

Expand Down
1 change: 0 additions & 1 deletion apps/mobile/app/components/premium/expiring.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export const Expiring = () => {
extend: true
});
const pricing = usePricing("yearly");
console.log(pricing?.info?.discount);

const promo = status.offer
? {
Expand Down
9 changes: 2 additions & 7 deletions apps/mobile/app/components/premium/pricing-plans.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ export const PricingPlans = ({
positiveText: "Apply",
positivePress: async (value) => {
if (!value) return;
console.log(value);
eSendEvent(eCloseSimpleDialog);
setBuying(true);
try {
Expand Down Expand Up @@ -534,9 +533,7 @@ export const PricingPlans = ({
onPress={() => {
openLinkInBrowser("https://notesnook.com/tos", colors)
.catch(() => {})
.then(() => {
console.log("closed");
});
.then(() => {});
}}
style={{
textDecorationLine: "underline"
Expand All @@ -551,9 +548,7 @@ export const PricingPlans = ({
onPress={() => {
openLinkInBrowser("https://notesnook.com/privacy", colors)
.catch(() => {})
.then(() => {
console.log("closed");
});
.then(() => {});
}}
style={{
textDecorationLine: "underline"
Expand Down
1 change: 0 additions & 1 deletion apps/mobile/app/components/properties/notebooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export default function Notebooks({ note, close }) {
let notebooks = [];
for (let notebook of item.notebooks) {
let item_notebook = db.notebooks.notebook(notebook.id);
console.log(notebook);
if (item_notebook) {
let data = {
id: notebook.id,
Expand Down
7 changes: 3 additions & 4 deletions apps/mobile/app/components/sheets/add-to/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const MoveNoteComponent = ({ note }) => {
topics: [],
id: null
});
console.log("added notebook id", id);

setExpanded(id);
openAddTopicDialog(db.notebooks.notebook(id).data);
notebookInput.current?.clear();
Expand All @@ -137,7 +137,7 @@ const MoveNoteComponent = ({ note }) => {
});
return false;
}
console.log(item.id);

await db.notebooks.notebook(item.id).topics.add(value);
setNotebooks();
updateNoteExists();
Expand Down Expand Up @@ -198,7 +198,6 @@ const MoveNoteComponent = ({ note }) => {
if (topic.type !== "topic") continue;
for (let id of notes) {
if (topic.notes.indexOf(id) > -1) {
console.log("found", ids.indexOf(notebooks[i].id));
if (ids.indexOf(notebooks[i].id) === -1) {
ids.push(notebooks[i].id);
}
Expand All @@ -208,7 +207,7 @@ const MoveNoteComponent = ({ note }) => {
}
}
}
console.log("ids: ", ids);

setNoteExists(ids);
}, [note?.id, selectedItemsList]);

Expand Down
1 change: 0 additions & 1 deletion apps/mobile/app/components/sheets/manage-tags/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const ManageTagsSheet = () => {

useEffect(() => {
if (visible) {
console.log("sorting tags");
sortTags();
}
}, [allTags, note, query, sortTags, visible]);
Expand Down
Loading

0 comments on commit dcd5c16

Please sign in to comment.