2017-07-05 22:29:00 +01:00
|
|
|
import { Note } from 'lib/models/note.js'
|
2017-07-13 00:01:15 +01:00
|
|
|
import { Folder } from 'lib/models/folder.js'
|
2017-07-10 21:48:17 +01:00
|
|
|
import { Log } from 'lib/log.js'
|
2017-07-05 22:29:00 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-07-13 00:01:15 +01:00
|
|
|
static async openDefaultNoteList() {
|
|
|
|
const selectedFolder = await Folder.defaultFolder();
|
|
|
|
if (selectedFolder) {
|
|
|
|
this.openNoteList(selectedFolder.id);
|
|
|
|
} else {
|
|
|
|
this.dispatch({
|
|
|
|
type: 'Navigation/NAVIGATE',
|
2017-07-13 18:47:31 +00:00
|
|
|
routeName: 'Welcome',
|
2017-07-13 00:01:15 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-05 22:29:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export { NotesScreenUtils }
|