Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
Fix Compose view not picking up remote changed (#421)
Browse files Browse the repository at this point in the history
* chore(deps): update sn-textview & standard-notes-rn

* fix: update compose view when receiving remote changes

* chore(version): 3.6.8

* fix: set screenshot privacy on app launch

Co-authored-by: Antonella Sgarlatta <[email protected]>
  • Loading branch information
arielsvg and antsgar authored Apr 30, 2021
1 parent 0f7322a commit 71175ab
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 155 deletions.
8 changes: 4 additions & 4 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ PODS:
- React
- RNVectorIcons (7.1.0):
- React
- sn-textview (1.0.0):
- sn-textview (1.0.1):
- React-Core
- SNReactNative (1.0.0):
- SNReactNative (1.0.1):
- React-Core
- TrustKit (1.6.5)
- Yoga (1.14.0)
Expand Down Expand Up @@ -513,8 +513,8 @@ SPEC CHECKSUMS:
RNSearchBar: 5ed8e13ba8a6c701fbd2afdfe4164493d24b2aee
RNStoreReview: 62d6afd7c37db711a594bbffca6b0ea3a812b7a8
RNVectorIcons: bc69e6a278b14842063605de32bec61f0b251a59
sn-textview: 43135d1feb6e97994b8475b6a1e6e3c902d6b189
SNReactNative: 3fa6096f78bea7dbd329c897ee854f73666d20db
sn-textview: 0211237b3e0edeeb23aed2a9c47b78af35a81e95
SNReactNative: b5e9e529c175c13f3a618e27c76cf3071213d5e1
TrustKit: 073855e3adecd317417bda4ac9e9ac54a2e3b9f2
Yoga: 4bd86afe9883422a7c4028c00e34790f560923d6

Expand Down
172 changes: 56 additions & 116 deletions ios/StandardNotes.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "StandardNotes",
"version": "3.6.7",
"user-version": "3.6.7",
"version": "3.6.8",
"user-version": "3.6.8",
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
Expand Down Expand Up @@ -55,8 +55,8 @@
"react-native-version-info": "^1.1.0",
"react-native-webview": "^11.0.3",
"react-navigation-header-buttons": "^6.0.2",
"sn-textview": "standardnotes/sn-textview#3b56f5c2c87c24370f00ee5a0cee0da9a9fc66c3",
"standard-notes-rn": "standardnotes/standard-notes-rn#996b016",
"sn-textview": "standardnotes/sn-textview#14cd6fded5c746569a9c6c365d2edc41913811bb",
"standard-notes-rn": "standardnotes/standard-notes-rn#d8e5c21b049dd4b97006688617736efbdb7dc4e7",
"styled-components": "^5.2.1"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/application_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ export class ApplicationState extends ApplicationService {
);

await this.loadUnlockTiming();
this.screenshotPrivacyEnabled =
(await this.getScreenshotPrivacyEnabled()) ?? true;
this.setAndroidScreenshotPrivacy(this.screenshotPrivacyEnabled);
}

async onAppLaunch() {
MobileApplication.setPreviouslyLaunched();
this.screenshotPrivacyEnabled =
(await this.getScreenshotPrivacyEnabled()) ?? true;
this.setAndroidScreenshotPrivacy(this.screenshotPrivacyEnabled);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/screens/Compose/Compose.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const StyledTextView = React.memo(
prevProps: ComponentProps<typeof SNTextView>
) => {
if (
newProps.value !== prevProps.value ||
newProps.selectionColor !== prevProps.selectionColor ||
newProps.handlesColor !== prevProps.handlesColor ||
newProps.autoFocus !== prevProps.autoFocus ||
Expand Down
47 changes: 25 additions & 22 deletions src/screens/Compose/Compose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const SAVE_TIMEOUT_DEBOUNCE = 250;
const SAVE_TIMEOUT_NO_DEBOUNCE = 100;

type State = {
title: string | undefined;
title: string;
text: string;
saveError: boolean;
editorComponent: SNComponent | undefined;
webViewError: boolean;
Expand All @@ -65,27 +66,30 @@ export class Compose extends React.Component<{}, State> {
removeAppEventObserver?: () => void;
removeComponentHandler?: () => void;

state: State = {
title: '',
editorComponent: undefined,
saveError: false,
webViewError: false,
loadingWebview: false,
};
constructor(
props: {},
context: React.ContextType<typeof ApplicationContext>
) {
super(props);
this.context = context;
const initialEditor = context?.editorGroup.activeEditor;
this.state = {
title: initialEditor?.note?.title ?? '',
text: initialEditor?.note?.text ?? '',
editorComponent: undefined,
saveError: false,
webViewError: false,
loadingWebview: false,
};
}

componentDidMount() {
const initialEditor = this.context?.editorGroup.activeEditor;

// eslint-disable-next-line react/no-did-mount-set-state
this.setState({
title: initialEditor?.note?.safeTitle(),
});

this.removeEditorNoteChangeObserver = this.editor?.addNoteChangeObserver(
newNote => {
this.setState(
{
title: newNote.title,
text: newNote.text,
},
() => {
this.reloadComponentEditorState();
Expand All @@ -102,11 +106,9 @@ export class Compose extends React.Component<{}, State> {
if (isPayloadSourceRetrieved(source!)) {
this.setState({
title: newNote.title,
text: newNote.text,
});
}
if (!this.state.title) {
this.setState({ title: newNote.title });
}

if (newNote.lastSyncBegan || newNote.dirty) {
if (newNote.lastSyncEnd) {
Expand Down Expand Up @@ -399,14 +401,15 @@ export class Compose extends React.Component<{}, State> {
);
};

onContentChange = (newNoteText: string) => {
onContentChange = (text: string) => {
this.setState({ text });
if (Platform.OS === 'android' && this.note?.locked) {
this.context?.alertService?.alert(
'This note is locked. Please unlock this note to make changes.'
);
return;
}
this.saveNote(false, true, false, false, newNoteText);
this.saveNote(false, true, false, false, text);
};

render() {
Expand Down Expand Up @@ -510,7 +513,7 @@ export class Compose extends React.Component<{}, State> {
testID="noteContentField"
ref={this.editorViewRef}
autoFocus={false}
value={this.note?.text}
value={this.state.text}
selectionColor={lighten(
theme.stylekitInfoColor,
0.35
Expand All @@ -528,7 +531,7 @@ export class Compose extends React.Component<{}, State> {
ref={this.editorViewRef}
autoFocus={false}
multiline
value={this.note?.text}
value={this.state.text}
keyboardDismissMode={'interactive'}
keyboardAppearance={themeService?.keyboardColorForActiveTheme()}
selectionColor={lighten(theme.stylekitInfoColor)}
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7657,9 +7657,9 @@ slide@^1.1.5:
resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707"
integrity sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=

sn-textview@standardnotes/sn-textview#3b56f5c2c87c24370f00ee5a0cee0da9a9fc66c3:
version "1.0.0"
resolved "https://codeload.github.com/standardnotes/sn-textview/tar.gz/3b56f5c2c87c24370f00ee5a0cee0da9a9fc66c3"
sn-textview@standardnotes/sn-textview#14cd6fded5c746569a9c6c365d2edc41913811bb:
version "1.0.1"
resolved "https://codeload.github.com/standardnotes/sn-textview/tar.gz/14cd6fded5c746569a9c6c365d2edc41913811bb"

snapdragon-node@^2.0.1:
version "2.1.1"
Expand Down Expand Up @@ -7824,9 +7824,9 @@ stacktrace-parser@^0.1.3:
dependencies:
type-fest "^0.7.1"

standard-notes-rn@standardnotes/standard-notes-rn#996b016:
version "1.0.0"
resolved "https://codeload.github.com/standardnotes/standard-notes-rn/tar.gz/996b016f5a63e0e36fb50a86f5ad41c0c072b41e"
standard-notes-rn@standardnotes/standard-notes-rn#d8e5c21b049dd4b97006688617736efbdb7dc4e7:
version "1.0.1"
resolved "https://codeload.github.com/standardnotes/standard-notes-rn/tar.gz/d8e5c21b049dd4b97006688617736efbdb7dc4e7"

static-extend@^0.1.1:
version "0.1.2"
Expand Down

0 comments on commit 71175ab

Please sign in to comment.