1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +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> <!DOCTYPE html>
<!-- NOTE: I think this is not used at all -->
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">

View File

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

View File

@ -127,6 +127,26 @@ class AppComponent extends Component {
this.setState({ this.setState({
contentScriptLoaded: true, 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() { componentDidUpdate() {

View File

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

View File

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