2022-08-30 16:13:11 +05:00
|
|
|
/* This file is part of the Notesnook project (https://notesnook.com/)
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2022 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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-08-26 16:19:39 +05:00
|
|
|
import Clipboard from "@react-native-clipboard/clipboard";
|
2022-08-29 16:19:17 +05:00
|
|
|
import React from "react";
|
2022-08-26 16:19:39 +05:00
|
|
|
import { View } from "react-native";
|
|
|
|
|
import { db } from "../../common/database";
|
2022-08-29 16:19:17 +05:00
|
|
|
import { ToastEvent } from "../../services/event-manager";
|
|
|
|
|
import { useSettingStore } from "../../stores/use-setting-store";
|
2022-08-26 16:19:39 +05:00
|
|
|
import { SIZE } from "../../utils/size";
|
|
|
|
|
import { Button } from "../ui/button";
|
2022-01-22 12:57:05 +05:00
|
|
|
export const DevMode = ({ item }) => {
|
2022-08-26 16:19:39 +05:00
|
|
|
const devMode = useSettingStore((state) => state.settings.devMode);
|
2022-01-07 11:04:38 +05:00
|
|
|
|
2022-03-03 22:58:58 +05:00
|
|
|
return devMode ? (
|
2022-01-07 11:04:38 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
2022-08-26 16:19:39 +05:00
|
|
|
width: "100%",
|
2022-01-07 11:04:38 +05:00
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
marginTop: 10
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-01-07 11:04:38 +05:00
|
|
|
<Button
|
|
|
|
|
onPress={async () => {
|
|
|
|
|
let additionalData = {};
|
2022-08-26 16:19:39 +05:00
|
|
|
if (item.type === "note") {
|
2022-01-07 11:04:38 +05:00
|
|
|
let content = await db.content.raw(item.contentId);
|
|
|
|
|
if (content) {
|
|
|
|
|
content = db.debug.strip(content);
|
|
|
|
|
additionalData.content = content;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
additionalData.lastSynced = await db.lastSynced();
|
2022-01-22 12:57:05 +05:00
|
|
|
let _note = { ...item };
|
2022-01-07 11:04:38 +05:00
|
|
|
_note.additionalData = additionalData;
|
|
|
|
|
Clipboard.setString(db.debug.strip(_note));
|
|
|
|
|
|
|
|
|
|
ToastEvent.show({
|
2022-08-26 16:19:39 +05:00
|
|
|
heading: "Debug data copied!",
|
|
|
|
|
type: "success",
|
|
|
|
|
context: "local"
|
2022-01-07 11:04:38 +05:00
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
fontSize={SIZE.sm}
|
|
|
|
|
title="Copy debug data"
|
|
|
|
|
icon="clipboard"
|
|
|
|
|
height={30}
|
|
|
|
|
type="warn"
|
|
|
|
|
style={{
|
2022-08-26 16:19:39 +05:00
|
|
|
alignSelf: "flex-end"
|
2022-01-07 11:04:38 +05:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
|
|
|
|
) : null;
|
|
|
|
|
};
|