You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
Got RN working again
This commit is contained in:
@@ -6,12 +6,12 @@ import { ItemListComponent } from 'lib/components/item-list.js';
|
||||
import { Note } from 'lib/models/note.js';
|
||||
import { Folder } from 'lib/models/folder.js';
|
||||
import { _ } from 'lib/locale.js';
|
||||
import { NoteFolderService } from 'lib/services/note-folder-service.js';
|
||||
import { NotesScreenUtils } from 'lib/components/screens/notes-utils.js'
|
||||
|
||||
class FolderListComponent extends ItemListComponent {
|
||||
|
||||
listView_itemPress(folderId) {
|
||||
NoteFolderService.openNoteList(folderId);
|
||||
NotesScreenUtils.openNoteList(folderId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import { ListView, Text, TouchableHighlight, Switch, View } from 'react-native';
|
||||
import { Log } from 'lib/log.js';
|
||||
import { _ } from 'lib/locale.js';
|
||||
import { Checkbox } from 'lib/components/checkbox.js';
|
||||
import { NoteFolderService } from 'lib/services/note-folder-service.js';
|
||||
import { Note } from 'lib/models/note.js';
|
||||
|
||||
class ItemListComponent extends Component {
|
||||
@@ -33,14 +32,9 @@ class ItemListComponent extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
todoCheckbox_change(itemId, checked) {
|
||||
NoteFolderService.setField('note', itemId, 'todo_completed', checked);
|
||||
|
||||
// Note.load(itemId).then((oldNote) => {
|
||||
// let newNote = Object.assign({}, oldNote);
|
||||
// newNote.todo_completed = checked;
|
||||
// return NoteFolderService.save('note', newNote, oldNote);
|
||||
// });
|
||||
async todoCheckbox_change(itemId, checked) {
|
||||
let note = await Note.load(itemId);
|
||||
await Note.save({ id: note.id, todo_completed: checked });
|
||||
}
|
||||
|
||||
listView_itemPress(itemId) {}
|
||||
|
||||
@@ -3,8 +3,8 @@ import { View, Button, TextInput } from 'react-native';
|
||||
import { connect } from 'react-redux'
|
||||
import { Log } from 'lib/log.js'
|
||||
import { Folder } from 'lib/models/folder.js'
|
||||
import { BaseModel } from 'lib/base-model.js'
|
||||
import { ScreenHeader } from 'lib/components/screen-header.js';
|
||||
import { NoteFolderService } from 'lib/services/note-folder-service.js';
|
||||
|
||||
class FolderScreenComponent extends React.Component {
|
||||
|
||||
@@ -41,18 +41,15 @@ class FolderScreenComponent extends React.Component {
|
||||
this.folderComponent_change('title', text);
|
||||
}
|
||||
|
||||
saveFolderButton_press() {
|
||||
console.warn('CHANGE NOT TESTED');
|
||||
let toSave = BaseModel.diffObjects(this.originalFolder, this.state.folder);
|
||||
toSave.id = this.state.folder.id;
|
||||
Folder.save(toSave).then((folder) => {
|
||||
this.originalFolder = Object.assign({}, folder);
|
||||
this.setState({ folder: folder });
|
||||
});
|
||||
// NoteFolderService.save('folder', this.state.folder, this.originalFolder).then((folder) => {
|
||||
// this.originalFolder = Object.assign({}, folder);
|
||||
// this.setState({ folder: folder });
|
||||
// });
|
||||
async saveFolderButton_press() {
|
||||
let toSave = {
|
||||
title: this.state.folder.title,
|
||||
};
|
||||
|
||||
if (this.originalFolder) toSave.id = this.originalFolder.id;
|
||||
|
||||
this.originalFolder = await Folder.save(toSave);
|
||||
this.setState({ folder: this.originalFolder });
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -4,7 +4,6 @@ import { connect } from 'react-redux'
|
||||
import { Log } from 'lib/log.js'
|
||||
import { Folder } from 'lib/models/folder.js'
|
||||
import { ScreenHeader } from 'lib/components/screen-header.js';
|
||||
import { NoteFolderService } from 'lib/services/note-folder-service.js';
|
||||
|
||||
class LoadingScreenComponent extends React.Component {
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import { Log } from 'lib/log.js'
|
||||
import { Note } from 'lib/models/note.js'
|
||||
import { ScreenHeader } from 'lib/components/screen-header.js';
|
||||
import { Checkbox } from 'lib/components/checkbox.js'
|
||||
import { NoteFolderService } from 'lib/services/note-folder-service.js';
|
||||
import { _ } from 'lib/locale.js';
|
||||
|
||||
class NoteScreenComponent extends React.Component {
|
||||
@@ -17,17 +16,14 @@ class NoteScreenComponent extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = { note: Note.new() }
|
||||
this.originalNote = null;
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
if (!this.props.noteId) {
|
||||
let note = this.props.itemType == 'todo' ? Note.newTodo(this.props.folderId) : Note.new(this.props.folderId);
|
||||
Log.info(note);
|
||||
this.setState({ note: note });
|
||||
} else {
|
||||
Note.load(this.props.noteId).then((note) => {
|
||||
this.originalNote = Object.assign({}, note);
|
||||
this.setState({ note: note });
|
||||
});
|
||||
}
|
||||
@@ -49,23 +45,11 @@ class NoteScreenComponent extends React.Component {
|
||||
this.noteComponent_change('body', text);
|
||||
}
|
||||
|
||||
saveNoteButton_press() {
|
||||
|
||||
console.warn('CHANGE NOT TESTED');
|
||||
|
||||
async saveNoteButton_press() {
|
||||
let isNew = !this.state.note.id;
|
||||
let toSave = BaseModel.diffObjects(this.originalNote, this.state.note);
|
||||
toSave.id = this.state.note.id;
|
||||
Note.save(toSave).then((note) => {
|
||||
this.originalNote = Object.assign({}, note);
|
||||
this.setState({ note: note });
|
||||
if (isNew) return Note.updateGeolocation(note.id);
|
||||
});
|
||||
|
||||
// NoteFolderService.save('note', this.state.note, this.originalNote).then((note) => {
|
||||
// this.originalNote = Object.assign({}, note);
|
||||
// this.setState({ note: note });
|
||||
// });
|
||||
let note = await Note.save(this.state.note);
|
||||
this.setState({ note: note });
|
||||
if (isNew) Note.updateGeolocation(note.id);
|
||||
}
|
||||
|
||||
deleteNote_onPress(noteId) {
|
||||
|
||||
24
ReactNativeClient/lib/components/screens/notes-utils.js
Normal file
24
ReactNativeClient/lib/components/screens/notes-utils.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Note } from 'lib/models/note.js'
|
||||
|
||||
class NotesScreenUtils {
|
||||
|
||||
static openNoteList(folderId) {
|
||||
return Note.previews(folderId).then((notes) => {
|
||||
this.dispatch({
|
||||
type: 'NOTES_UPDATE_ALL',
|
||||
notes: notes,
|
||||
});
|
||||
|
||||
this.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
routeName: 'Notes',
|
||||
folderId: folderId,
|
||||
});
|
||||
}).catch((error) => {
|
||||
Log.warn('Cannot load notes from ' + folderId, error);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { NotesScreenUtils }
|
||||
@@ -2,7 +2,7 @@ import { connect } from 'react-redux'
|
||||
import { Button } from 'react-native';
|
||||
import { Log } from 'lib/log.js';
|
||||
import { Note } from 'lib/models/note.js';
|
||||
import { NoteFolderService } from 'lib/services/note-folder-service.js';
|
||||
import { NotesScreenUtils } from 'lib/components/screens/notes-utils.js'
|
||||
|
||||
const React = require('react');
|
||||
const {
|
||||
@@ -46,7 +46,7 @@ class SideMenuContentComponent extends Component {
|
||||
type: 'SIDE_MENU_CLOSE',
|
||||
});
|
||||
|
||||
NoteFolderService.openNoteList(folder.id);
|
||||
NotesScreenUtils.openNoteList(folder.id);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user