Files
notesnook/apps/mobile/src/components/properties/devmode.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';
import { useSettingStore } from '../../provider/stores';
import { ToastEvent } from '../../services/EventManager';
import { db } from '../../utils/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 }) => {
2022-01-07 11:04:38 +05:00
const settings = useSettingStore(state => state.settings);
return settings.devMode ? (
<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;
};