Files
notesnook/apps/mobile/app/components/properties/dev-mode.js

54 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-01-07 11:04:38 +05:00
import Clipboard from '@react-native-clipboard/clipboard';
import React from 'react';
import { View } from 'react-native';
2022-04-24 05:59:14 +05:00
import { useSettingStore } from '../../stores/use-setting-store';
2022-02-28 23:25:18 +05:00
import { ToastEvent } from '../../services/event-manager';
2022-08-16 16:48:10 +05:00
import { db } from '../../common/database';
2022-02-28 13:48:59 +05:00
import { SIZE } from '../../utils/size';
import { Button } from '../ui/button';
2022-01-07 11:04:38 +05:00
2022-01-22 12:57:05 +05:00
export const DevMode = ({ item }) => {
const devMode = useSettingStore(state => state.settings.devMode);
2022-01-07 11:04:38 +05:00
return devMode ? (
2022-01-07 11:04:38 +05:00
<View
style={{
width: '100%',
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 = {};
if (item.type === 'note') {
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({
heading: 'Debug data copied!',
type: 'success',
context: 'local'
});
}}
fontSize={SIZE.sm}
title="Copy debug data"
icon="clipboard"
height={30}
type="warn"
style={{
alignSelf: 'flex-end'
}}
/>
</View>
) : null;
};