1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

Clipper: Fixes #672: Make sure selected notebook is saved and restored correctly

This commit is contained in:
Laurent Cozic 2018-09-23 18:44:39 +01:00
parent 77f089654e
commit fc8ffcbe46
5 changed files with 25 additions and 8 deletions

View File

@ -1,5 +1,7 @@
<!DOCTYPE html>
<!-- NOTE: I think this is not used at all -->
<html>
<head>
<meta charset="utf-8">

View File

@ -115,13 +115,7 @@
margin-right: .5em;
}
.App .Folders select,
.App .Tags .AwesompleteInput {
flex: 1;
}
.App .Tags .AwesompleteInput, .awesomplete {
display: flex !important;
.App .Folders select {
flex: 1;
}

View File

@ -127,6 +127,26 @@ class AppComponent extends Component {
this.setState({
contentScriptLoaded: true,
});
let foundSelectedFolderId = false;
const searchSelectedFolder = (folders) => {
for (let i = 0; i < folders.length; i++) {
const folder = folders[i];
if (folder.id === this.props.selectedFolderId) foundSelectedFolderId = true;
if (folder.children) searchSelectedFolder(folder.children);
}
}
searchSelectedFolder(this.props.folders);
if (!foundSelectedFolderId) {
const newFolderId = this.props.folders.length ? this.props.folders[0].id : null;
this.props.dispatch({
type: 'SELECTED_FOLDER_SET',
id: newFolderId,
});
}
}
componentDidUpdate() {

View File

@ -126,6 +126,8 @@ class Bridge {
const tags = await this.clipperApiExec('GET', 'tags');
this.dispatch({ type: 'TAGS_SET', tags: tags });
bridge().restoreState();
return;
}
} catch (error) {

View File

@ -100,7 +100,6 @@ async function main() {
console.info('Popup: Init bridge and restore state...');
await bridge().init(window.browser ? window.browser : window.chrome, !!window.browser, store.dispatch);
bridge().restoreState();
console.info('Popup: Creating React app...');