Merge pull request #57 from streetwriters/feat-attachments

v1.6.0
This commit is contained in:
Ammar Ahmed
2021-11-03 09:57:51 +05:00
committed by GitHub
6 changed files with 62 additions and 36 deletions

View File

@@ -43,4 +43,6 @@
-dontwarn java.awt.*
-keep class com.sun.jna.* { *; }
-keep class net.jpountz.** { *; }
-keep class com.goterl.** { *; }
-keepclassmembers class * extends com.sun.jna.* { public *; }

View File

@@ -1118,7 +1118,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1600;
CURRENT_PROJECT_VERSION = 1601;
DEVELOPMENT_TEAM = 53CWBG3QUC;
ENABLE_BITCODE = NO;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
@@ -1191,7 +1191,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.6.00;
MARKETING_VERSION = 1.6.01;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
@@ -1219,7 +1219,7 @@
CODE_SIGN_ENTITLEMENTS = Notesnook/Notesnook.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1600;
CURRENT_PROJECT_VERSION = 1601;
DEVELOPMENT_TEAM = 53CWBG3QUC;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
HEADER_SEARCH_PATHS = (
@@ -1291,7 +1291,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.6.00;
MARKETING_VERSION = 1.6.01;
ONLY_ACTIVE_ARCH = NO;
OTHER_LDFLAGS = (
"$(inherited)",
@@ -1449,7 +1449,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1600;
CURRENT_PROJECT_VERSION = 1601;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 53CWBG3QUC;
GCC_C_LANGUAGE_STANDARD = gnu11;
@@ -1460,7 +1460,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.6.00;
MARKETING_VERSION = 1.6.01;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.streetwriters.notesnook.notewidget;
@@ -1490,7 +1490,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1600;
CURRENT_PROJECT_VERSION = 1601;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 53CWBG3QUC;
GCC_C_LANGUAGE_STANDARD = gnu11;
@@ -1501,7 +1501,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.6.00;
MARKETING_VERSION = 1.6.01;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.streetwriters.notesnook.notewidget;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1530,7 +1530,7 @@
CODE_SIGN_ENTITLEMENTS = "Make Note/Make Note.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1600;
CURRENT_PROJECT_VERSION = 1601;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 53CWBG3QUC;
GCC_C_LANGUAGE_STANDARD = gnu11;
@@ -1603,7 +1603,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.6.00;
MARKETING_VERSION = 1.6.01;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.streetwriters.notesnook.share;
@@ -1633,7 +1633,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1600;
CURRENT_PROJECT_VERSION = 1601;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 53CWBG3QUC;
GCC_C_LANGUAGE_STANDARD = gnu11;
@@ -1706,7 +1706,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.6.00;
MARKETING_VERSION = 1.6.01;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.streetwriters.notesnook.share;
PRODUCT_NAME = "$(TARGET_NAME)";

View File

@@ -16,12 +16,7 @@ import {
useWindowDimensions,
View
} from 'react-native';
import Animated, {
color,
Easing,
timing,
useValue
} from 'react-native-reanimated';
import Animated, {Easing, timing, useValue} from 'react-native-reanimated';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import WebView from 'react-native-webview';
@@ -34,7 +29,6 @@ import {
} from '../src/services/EventManager';
import {getElevation} from '../src/utils';
import {db} from '../src/utils/database';
import {SIZE} from '../src/utils/SizeUtils';
import Storage from '../src/utils/storage';
import {sleep} from '../src/utils/TimeUtils';
import {Search} from './search';
@@ -254,6 +248,11 @@ const NotesnookShare = ({quicknote = false}) => {
const onLoad = () => {
postMessage(webviewRef, 'htmldiff', note.content?.data || '');
setTimeout(() => {
webviewRef.current?.injectJavaScript(`document
.querySelector('.htmldiff_div')
.setAttribute('contenteditable', 'true');`);
}, 300);
let theme = {...colors};
theme.factor = 1;
postMessage(webviewRef, 'theme', JSON.stringify(theme));
@@ -425,7 +424,7 @@ const NotesnookShare = ({quicknote = false}) => {
<Text
style={{
color: colors.pri,
fontSize: SIZE.md,
fontSize: 17,
fontFamily: 'OpenSans-Regular'
}}>
Quick note
@@ -562,7 +561,7 @@ const NotesnookShare = ({quicknote = false}) => {
style={{
width: '100%'
}}>
{!quicknote && (
{!quicknote ? (
<Button
color={colors.accent}
onPress={onPress}
@@ -580,7 +579,7 @@ const NotesnookShare = ({quicknote = false}) => {
bottom: -35
}}
/>
)}
) : null}
<View
style={{
@@ -662,7 +661,7 @@ const NotesnookShare = ({quicknote = false}) => {
paddingRight: 80,
alignItems: 'center'
}}>
{validator.isURL(rawData.value) && (
{rawData.value && validator.isURL(rawData.value) ? (
<Button
color={mode == 2 ? colors.shade : colors.nav}
icon={modes[2].icon}
@@ -674,7 +673,7 @@ const NotesnookShare = ({quicknote = false}) => {
type="rounded"
style={{paddingHorizontal: 12}}
/>
)}
) : null}
<Button
color={mode == 1 ? colors.shade : colors.nav}
icon={modes[1].icon}

View File

@@ -977,21 +977,25 @@ export const ActionSheetComponent = ({
style={{
width: '100%',
paddingHorizontal: 12,
marginTop: 10
marginTop: 10,
}}>
<Button
onPress={async () => {
console.log('copy data');
let additionalData = {}
if (note.type === "note") {
let content = await db.content.raw(note.contentId);
content = db.debug.strip(content);
additionalData.content = content;
if (content) {
content = db.debug.strip(content);
additionalData.content = content;
}
}
additionalData.lastSynced = await db.lastSynced();
console.log(_note);
let _note = {...note};
_note.additionalData = additionalData;
Clipboard.setString(db.debug.strip(_note));
ToastEvent.show({
heading:"Debug data copied!",
type:'success',

View File

@@ -1,5 +1,6 @@
import React, { useEffect, useRef, useState } from 'react';
import { Appearance, Platform, SafeAreaView, View } from 'react-native';
import deviceInfoModule from 'react-native-device-info';
import Animated, { Easing } from 'react-native-reanimated';
import AnimatedProgress from 'react-native-reanimated-progress-bar';
import SpInAppUpdates, {
@@ -21,7 +22,7 @@ import {
eUnSubscribeEvent,
ToastEvent
} from '../../services/EventManager';
import { editing } from '../../utils';
import { APP_VERSION, editing } from '../../utils';
import { COLOR_SCHEME_DARK } from '../../utils/Colors';
import { db } from '../../utils/database';
import {
@@ -141,6 +142,7 @@ const AppLoader = ({onLoad}) => {
};
const checkAppUpdates = async () => {
return false;
if (Platform.OS === 'android') {
try {
let needsUpdate = await inAppUpdates.checkNeedsUpdate();

View File

@@ -70,6 +70,7 @@ async function uploadFile(filename, {url, headers}, cancelToken) {
});
const uploadUrl = await res.text();
console.log(uploadUrl);
console.log(uploadUrl);
let request = RNFetchBlob.config({
IOSBackgroundTask: true
})
@@ -95,12 +96,13 @@ async function uploadFile(filename, {url, headers}, cancelToken) {
useAttachmentStore.getState().remove(filename);
if (result) {
let attachment = db.attachments.attachment(filename);
if (!attachment) return result;
if (!attachment.metadata.type.startsWith('image/')) {
RNFetchBlob.fs.unlink(`${cacheDir}/${filename}`).catch(console.log);
}
}
return attachment;
return result;
} catch (e) {
useAttachmentStore.getState().remove(filename);
console.log('upload file: ', e, url, headers);
@@ -114,9 +116,10 @@ async function downloadFile(filename, {url, headers}, cancelToken) {
let path = `${cacheDir}/${filename}`;
let exists = await RNFetchBlob.fs.exists(path);
if (exists) {
console.log('file is downloaded');
return true;
}
console.log('downloading again');
let res = await fetch(url, {
method: 'GET',
headers
@@ -179,7 +182,7 @@ function cancelable(operation) {
execute: () => operation(filename, {url, headers}, cancelToken),
cancel: async () => {
await cancelToken.cancel();
RNFetchBlob.fs.unlink(`${cacheDir}/${filename}`).catch(console.log)
RNFetchBlob.fs.unlink(`${cacheDir}/${filename}`).catch(console.log);
}
};
};
@@ -229,9 +232,9 @@ async function downloadAttachment(hash, global = true) {
message: attachment.metadata.filename + ' downloaded',
type: 'success'
});
RNFetchBlob.fs.unlink(
RNFetchBlob.fs.dirs.CacheDir + `/${attachment.metadata.hash}`
).catch(console.log);
RNFetchBlob.fs
.unlink(RNFetchBlob.fs.dirs.CacheDir + `/${attachment.metadata.hash}`)
.catch(console.log);
if (Platform.OS === 'ios') {
fileUri = folder.uri + `/${attachment.metadata.filename}`;
@@ -263,6 +266,21 @@ async function downloadAttachment(hash, global = true) {
}
}
async function clearFileStorage() {
try {
let files = await RNFetchBlob.fs.ls(cacheDir);
for (let file of files) {
try {
await RNFetchBlob.fs.unlink(cacheDir + `/${file}`);
} catch (e) {
console.log(e);
}
}
} catch (e) {
console.log(e);
}
}
export default {
readEncrypted,
writeEncrypted,
@@ -270,5 +288,6 @@ export default {
downloadFile: cancelable(downloadFile),
deleteFile,
exists,
downloadAttachment
downloadAttachment,
clearFileStorage
};