mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-27 08:21:03 +02:00
Electron: Fixed issue with conflict folder and fixed sync tests
This commit is contained in:
parent
f8bcb56964
commit
be77f15ef7
@ -3,7 +3,6 @@
|
||||
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
BUILD_DIR="$ROOT_DIR/build"
|
||||
|
||||
#rm -f "$BUILD_DIR/lib/"
|
||||
rsync -a --exclude "node_modules/" "$ROOT_DIR/app/" "$BUILD_DIR/"
|
||||
rsync -a "$ROOT_DIR/../ReactNativeClient/lib/" "$BUILD_DIR/lib/"
|
||||
cp "$ROOT_DIR/package.json" "$BUILD_DIR"
|
||||
|
@ -1,11 +1,10 @@
|
||||
#!/bin/bash
|
||||
CLIENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
BUILD_DIR="$ROOT_DIR/tests-build"
|
||||
|
||||
rm -f "$CLIENT_DIR/tests-build/lib"
|
||||
mkdir -p "$CLIENT_DIR/tests-build/data"
|
||||
ln -s "$CLIENT_DIR/build/lib" "$CLIENT_DIR/tests-build"
|
||||
rsync -a --exclude "node_modules/" "$ROOT_DIR/tests/" "$BUILD_DIR/"
|
||||
rsync -a "$ROOT_DIR/../ReactNativeClient/lib/" "$BUILD_DIR/lib/"
|
||||
rsync -a "$ROOT_DIR/build/locales/" "$BUILD_DIR/locales/"
|
||||
mkdir -p "$BUILD_DIR/data"
|
||||
|
||||
npm run build && NODE_PATH="$CLIENT_DIR/tests-build/" npm test tests-build/synchronizer.js
|
||||
|
||||
#npm run build && NODE_PATH="$CLIENT_DIR/tests-build/" npm test tests-build/synchronizer.js
|
||||
#npm run build && NODE_PATH="$CLIENT_DIR/tests-build/" npm test tests-build/base-model.js
|
||||
npm test tests-build/synchronizer.js
|
@ -1,3 +1,5 @@
|
||||
require('app-module-path').addPath(__dirname);
|
||||
|
||||
const { time } = require('lib/time-utils.js');
|
||||
const { setupDatabase, setupDatabaseAndSynchronizer, db, synchronizer, fileApi, sleep, clearDatabase, switchClient, syncTargetId } = require('test-utils.js');
|
||||
const { Folder } = require('lib/models/folder.js');
|
||||
|
@ -14,7 +14,7 @@ const { Synchronizer } = require('lib/synchronizer.js');
|
||||
const { FileApi } = require('lib/file-api.js');
|
||||
const { FileApiDriverMemory } = require('lib/file-api-driver-memory.js');
|
||||
const { FileApiDriverLocal } = require('lib/file-api-driver-local.js');
|
||||
const { FsDriverNode } = require('../app/fs-driver-node.js');
|
||||
const { FsDriverNode } = require('lib/fs-driver-node.js');
|
||||
const { time } = require('lib/time-utils.js');
|
||||
|
||||
let databases_ = [];
|
||||
@ -107,6 +107,7 @@ function setupDatabase(id = null) {
|
||||
}).then(() => {
|
||||
databases_[id] = new JoplinDatabase(new DatabaseDriverNode());
|
||||
// databases_[id].setLogger(logger);
|
||||
// console.info(filePath);
|
||||
return databases_[id].open({ name: filePath }).then(() => {
|
||||
BaseModel.db_ = databases_[id];
|
||||
return setupDatabase(id);
|
||||
|
@ -38,6 +38,10 @@ class SideBarComponent extends React.Component {
|
||||
listItemSelected: {
|
||||
backgroundColor: theme.selectedColor2,
|
||||
},
|
||||
conflictFolder: {
|
||||
color: theme.colorError2,
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
header: {
|
||||
height: itemHeight * 1.8,
|
||||
fontFamily: theme.fontFamily,
|
||||
@ -134,6 +138,7 @@ class SideBarComponent extends React.Component {
|
||||
folderItem(folder, selected) {
|
||||
let style = Object.assign({}, this.style().listItem);
|
||||
if (selected) style = Object.assign(style, this.style().listItemSelected);
|
||||
if (folder.id === Folder.conflictFolderId()) style = Object.assign(style, this.style().conflictFolder);
|
||||
return <a className="list-item" href="#" data-id={folder.id} data-type={BaseModel.TYPE_FOLDER} onContextMenu={(event) => this.itemContextMenu(event)} key={folder.id} style={style} onClick={() => {this.folderItem_click(folder)}}>{folder.title}</a>
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ const globalStyle = {
|
||||
backgroundColor2: "#2B2634",
|
||||
color2: "#ffffff",
|
||||
selectedColor2: "#5A4D70",
|
||||
colorError2: "#ff6c6c",
|
||||
|
||||
headerHeight: 35,
|
||||
headerButtonHPadding: 6,
|
||||
|
@ -136,8 +136,6 @@ class BaseApplication {
|
||||
process.exit(code);
|
||||
}
|
||||
|
||||
//async refreshNotes(parentType, parentId) {
|
||||
//async refreshNotes(parentType, parentId) {
|
||||
async refreshNotes(state) {
|
||||
let parentType = state.notesParentType;
|
||||
let parentId = null;
|
||||
@ -245,6 +243,13 @@ class BaseApplication {
|
||||
await this.refreshNotes(newState);
|
||||
}
|
||||
|
||||
if (action.type === 'NOTE_UPDATE_ONE') {
|
||||
// If there is a conflict, we refresh the folders so as to display "Conflicts" folder
|
||||
if (action.note && action.note.is_conflict) {
|
||||
await FoldersScreenUtils.refreshFolders();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.hasGui() && action.type == 'SETTING_UPDATE_ONE' && action.key == 'sync.interval' || action.type == 'SETTING_UPDATE_ALL') {
|
||||
reg.setupRecurrentSync();
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ class Tag extends BaseItem {
|
||||
}
|
||||
|
||||
static async save(o, options = null) {
|
||||
if (options.userSideValidation) {
|
||||
if (options && options.userSideValidation) {
|
||||
if ('title' in o) {
|
||||
o.title = o.title.trim().toLowerCase();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
const { Note } = require('lib/models/note.js');
|
||||
const { Folder } = require('lib/models/folder.js');
|
||||
|
||||
const defaultState = {
|
||||
notes: [],
|
||||
@ -160,6 +161,12 @@ const reducer = (state = defaultState, action) => {
|
||||
|
||||
const modNote = action.note;
|
||||
|
||||
const noteIsInFolder = function(note, folderId) {
|
||||
if (note.is_conflict) return folderId === Folder.conflictFolderId();
|
||||
if (!('parent_id' in modNote) || note.parent_id == folderId) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
let noteFolderHasChanged = false;
|
||||
let newNotes = state.notes.slice();
|
||||
var found = false;
|
||||
@ -168,7 +175,7 @@ const reducer = (state = defaultState, action) => {
|
||||
if (n.id == modNote.id) {
|
||||
|
||||
// Note is still in the same folder
|
||||
if (!('parent_id' in modNote) || modNote.parent_id == n.parent_id) {
|
||||
if (noteIsInFolder(modNote, n.parent_id)) {
|
||||
// Merge the properties that have changed (in modNote) into
|
||||
// the object we already have.
|
||||
newNotes[i] = Object.assign({}, newNotes[i]);
|
||||
@ -187,7 +194,13 @@ const reducer = (state = defaultState, action) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && ('parent_id' in modNote) && modNote.parent_id == state.selectedFolderId) newNotes.push(modNote);
|
||||
// Note was not found - if the current folder is the same as the note folder,
|
||||
// add it to it.
|
||||
if (!found) {
|
||||
if (noteIsInFolder(modNote, state.selectedFolderId)) {
|
||||
newNotes.push(modNote);
|
||||
}
|
||||
}
|
||||
|
||||
newNotes = Note.sortNotes(newNotes, state.notesOrder, newState.settings.uncompletedTodosOnTop);
|
||||
newState = Object.assign({}, state);
|
||||
|
@ -30,6 +30,7 @@
|
||||
"CliClient/build",
|
||||
"CliClient/node_modules",
|
||||
"CliClient/tests-build",
|
||||
"CliClient/tests-build/lib",
|
||||
"CliClient/tests/fuzzing -*",
|
||||
"CliClient/tests/fuzzing",
|
||||
"CliClient/tests/src",
|
||||
|
Loading…
Reference in New Issue
Block a user