Notes disappear with blank search term

Bug report

Blank search term returns zero notes.
This is the same problem as described previously in:

No errors in the console.

Info

  • Platform: Ubuntu 18.04
  • App Version: 5.1.1

Reproduce

See attached GIF:

I enter the letter “a” and see a lot of notes.
I delete the letter “a” and all notes disappear.

Expected behaviour

Clear search term will show all notes, with pinned notes at the top.

Hi Dav,

Thank you for reporting it.
Hmm, I can’t reproduce it.
I tried:

  1. Launch Inkdrop, shows All notes
  2. Search with “a”, gets results with some notes
  3. Clear the search term
  4. It goes back to All notes as expected

Hi, it’s easily reproducible on my system (Ubuntu), see previous animated gif.

The problem resolves when I reapply “All Notes”.
ie: whenever I see no notes, I re-select “All notes”, then I see the notes again.

I’m guessing you have a “currently selected” variable which is supposed to default to “All notes”, but in some cases get’s set to null instead.

So, if you can make sure that the currently selected node in the note tree can never be null, but instead “All notes” instead of null, then the problem will be fixed.

The odd thing is that I never select anything else, ever, I’m always on “All Notes”.

David

I’m a bit confused, but could you exactly explain how you did it step by step?

Yes, But did you search notes when nothing being selected?
The app remembers the last opened note with the note list state.
Because it assumes that you always start searching when you are seeing some notes on the list with a selection.
If you were viewing an empty notebook, it could happen though.

It has nothing to do with platforms.

Problem occurs often:

  1. I open the app, with nothing selected and I see all the notes
  2. I search for something, then I clear the search bar.
  3. all notes disappear.
  4. I click “All Notes” and I see all the notes.

Yes, But did you search notes when nothing being selected?

Correct, nothing selected, but initially I see all the notes.

The state changes seem to be these:
a) open the app and “All Notes” is implicitly selected.
b) search then clear the search bar, then no notes are seen.
c) explicitly click All Notes and all the notes are there.

So, either

  1. when opening the app there should be no notes until you explicitly click All Notes
    (bad solution).
  2. when opening the app it should remember the previous selection and reapply that selection when you clear the search bar.

Do you follow?
Essentially in some states the app implicitly selects all the notes, but in other states it implicitly selects no notes at all.

So, the question is really: what selection should the app implicitly select if there is no explicit selection?

I would suggest that the rule should be:

  • show the last selected notebook.
  • if there is no selected notebook, or if the selected notebook has been deleted by another instance, then set selected notebook to All Notes.

Pretty clear to me that you’re not catching the situation where no notebook was explicitly selected.

Take at look at your logic regarding clearing the search bar.
What does it do if there is no notebook selected?

That’s weird. In the latest version, it should restore the last editing state.
I mean, it should reopen the last editing note.
What does your config look like in config.cson which is stored in here?
It should be like:

"*":
  core:
    lastNavigationState:
      editingNoteId: "note:Aa70pM075"
      queryContext:
        mode: "all"
      sidebar:
        workspace:
          bookId: ""
          visible: false

When you quit the app, it saves the editing note ID.
Nothing selected means that the app is failing to restore it or the config doesn’t have core. lastNavigationState .editingNoteId.

Clearing the search bar restores back to the last editing state (editing note, sidebar, and note list query).
But if there is no state to go back, it shows nothing as you get.
That’s the main cause of the problem, but I don’t understand that you get no selections on the app launch.
It’s easy to change that to show all notes though, I’d like to clarify it.
It might be a race condition or something.

Thanks for your detailed explanation!

Here is the current config.cson:

"*":
  core:
    db:
      backupPath: "/home/davem/backups/inkdrop"
      machineId: "jyVxcX6vk"
    lastNavigationState:
      editingNoteId: "note:FPsJaRRub"
      queryContext:
        mode: "search"
        searchKeyword: "docker"
      sidebar:
        workspace:
          bookId: ""
          visible: false
    mainWindow:
      fullscreen: false
      maximized: false
      noteListBar:
        w: 272
      position:
        x: 382
        y: 170
      sideBar:
        collapsedBooks: [
          "book:T0WxWyOkJ"
          "book:fK18xLnmF"
          "book:1xPJeMPOH"
          "book:PzQO8zbWt"
        ]
        visible: false
        w: 170
      size:
        h: 957
        w: 1234
    themes: [
      "default-light-ui"
      "solarized-light-syntax"
      "colorfi-preview"
    ]
  editor:
    fontSize: 14
    styleActiveLine: true
    viewMode: "edit"

When the problem resolves, I will look for:

core.lastNavigationState .editingNoteId

and report back what I see.
Thanks for the link to the “hacking” page.
I have been meaning to make a few plugins at some point.

Just happened again, here is a screenshot.
On the left is the config.cson
On the right you can see that the notes have disappeared.
Comments:
a) editingNoteId is not blank.
b) searchKeyword is “docker” yet I’ve not typed in that search term for several days!

I have three questions to clarify:

  1. Did you get the blank editor (not opened anything) when launched the app?
  2. With editingNoteId has a value, does the app open the last editing note when launched or not?
  3. The core.lastNavigationState is saved only when you quit the app.
    Looks like editingNoteId hasn’t changed since the last report.
    When you quit it, does the config value get updated?

I still don’t understand what’s exactly going wrong.

See attached animated gif.
On the left in the config file open in VSCode.
On the right is Inkdrop.
When I open / close notebooks, the config file behaves correctly.
When I edit a note, editingNoteId does not change at, not even if I save the note.

Thanks but it’s intended, as I said:

Looks like core.lastNavigationState is saved sometimes, other times not.

I think the problem occurs in this state:
a) All Notebooks selected
b) close Inkdrop, open again, and create/edit/delete notes without clicking on any notebooks, ie: using the All notebooks state from the previous session.
c) Close and Open Indrop again, also not clicking on any notebooks, so now the state is also All Notebooks, but it wasn’t persisted into the 3rd session.

Does that make sense to you?

David

Hi Dav,

Thanks for letting me know.
The config value is not saved sometimes. I guess that’s because there is no difference from the previous session because you did nothing.
At the step c), what state did you get in the 3rd session? All Notebooks is not selected? No note is opened? If so, what does core.lastNavigationState look like?
Also, I want you to answer those remained questions:

I have to clarify the condition that the app doesn’t open anything when launched.

Thanks again for sticking with it.