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

Commit

Permalink
More accurate saving status, disable editor change on locked notes an…
Browse files Browse the repository at this point in the history
…d SNJS upgrade (#409)

* fix: more accurate saving status

* fix: disallow changing editor on locked note

* chore(version-snjs): 2.0.75

* refactor: support snjs session history refactor
  • Loading branch information
Antonella Sgarlatta authored Apr 21, 2021
1 parent b9483dc commit 0f7322a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@react-navigation/native": "^5.9.3",
"@react-navigation/stack": "^5.14.3",
"@standardnotes/sncrypto-common": "1.2.9",
"@standardnotes/snjs": "2.0.72",
"@standardnotes/snjs": "2.0.75",
"js-base64": "^3.5.2",
"moment": "^2.29.1",
"react": "16.13.1",
Expand Down
14 changes: 10 additions & 4 deletions src/screens/Compose/Compose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ export class Compose extends React.Component<{}, State> {
{
title: newNote.title,
},
() => this.reloadComponentEditorState()
() => {
this.reloadComponentEditorState();
if (newNote.dirty) {
this.showSavingStatus();
}
}
);
}
);
Expand All @@ -103,14 +108,15 @@ export class Compose extends React.Component<{}, State> {
this.setState({ title: newNote.title });
}

if (newNote.lastSyncBegan) {
if (newNote.lastSyncBegan || newNote.dirty) {
if (newNote.lastSyncEnd) {
if (
newNote.lastSyncBegan?.getTime() > newNote.lastSyncEnd.getTime()
newNote.dirty ||
newNote.lastSyncBegan!.getTime() > newNote.lastSyncEnd.getTime()
) {
this.showSavingStatus();
} else if (
newNote.lastSyncEnd.getTime() > newNote.lastSyncBegan.getTime()
newNote.lastSyncEnd.getTime() > newNote.lastSyncBegan!.getTime()
) {
this.showAllChangesSavedStatus();
}
Expand Down
6 changes: 3 additions & 3 deletions src/screens/NoteHistory/SessionHistory.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApplicationContext } from '@Root/ApplicationContext';
import { ItemSessionHistory, SNNote } from '@standardnotes/snjs';
import { HistoryEntry, SNNote } from '@standardnotes/snjs';
import { NoteHistoryEntry } from '@standardnotes/snjs/dist/@types/services/history/entries/note_history_entry';
import React, { useCallback, useContext, useEffect, useState } from 'react';
import { FlatList, ListRenderItem } from 'react-native';
Expand All @@ -16,7 +16,7 @@ export const SessionHistory: React.FC<Props> = ({ note, onPress }) => {
const insets = useSafeAreaInsets();

// State
const [sessionHistory, setSessionHistory] = useState<ItemSessionHistory>();
const [sessionHistory, setSessionHistory] = useState<HistoryEntry[]>();

useEffect(() => {
if (note) {
Expand Down Expand Up @@ -52,7 +52,7 @@ export const SessionHistory: React.FC<Props> = ({ note, onPress }) => {
initialNumToRender={10}
windowSize={10}
keyboardShouldPersistTaps={'never'}
data={sessionHistory?.entries as NoteHistoryEntry[]}
data={sessionHistory as NoteHistoryEntry[]}
renderItem={RenderItem}
/>
);
Expand Down
6 changes: 6 additions & 0 deletions src/screens/SideMenu/NoteSideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ export const NoteSideMenu = React.memo((props: Props) => {

const onEditorPress = useCallback(
async (selectedComponent?: SNComponent) => {
if (note?.locked) {
application?.alertService.alert(
"This note is locked. If you'd like to edit its options, unlock it, and try again."
);
return;
}
if (editor?.isTemplateNote) {
await editor?.insertTemplatedNote();
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1390,10 +1390,10 @@
resolved "https://registry.yarnpkg.com/@standardnotes/sncrypto-common/-/sncrypto-common-1.2.9.tgz#5212a959e4ec563584e42480bfd39ef129c3cbdf"
integrity sha512-xJ5IUGOZztjSgNP/6XL+Ut5+q9UgSTv6xMtKkcQC5aJxCOkJy9u6RamPLdF00WQgwibxx2tu0e43bKUjTgzMig==

"@standardnotes/[email protected].72":
version "2.0.72"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.0.72.tgz#1ff7d691f0d907a1513ec88e6b5d5ae0691f2947"
integrity sha512-OL1jeb0sEz4SZwGHeceoKttVcBmcKAh5y/96TELJxM1ZHL2Ayf6DxAXCz3KZBoD7JZllbJ9QWR37/bp+E4y2TA==
"@standardnotes/[email protected].75":
version "2.0.75"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.0.75.tgz#aeb0ead927da63dc85e28f78da2362126bb16602"
integrity sha512-QL5YgDT0aN9t95gxgURqNudXr5dteVsc1ylsKKSw0DpEGiq0bACPxbI+sUFppoWTFmprxmDh3+vc+FFcFg7Lyw==
dependencies:
"@standardnotes/auth" "^2.0.0"
"@standardnotes/sncrypto-common" "^1.2.9"
Expand Down

0 comments on commit 0f7322a

Please sign in to comment.