logseq / logseq

A privacy-first, open-source platform for knowledge management and collaboration. Download link: http://github.com/logseq/logseq/releases. roadmap: http://trello.com/b/8txSM12G/roadmap
https://logseq.com
GNU Affero General Public License v3.0
32.65k stars 1.91k forks source link

Dark mode doesn't persist on app closure and re-opening #10289

Open Biosias opened 1 year ago

Biosias commented 1 year ago

Search first

What Happened?

When Dark mode is enabled and then the app is closed and reopened it opens with Dark mode disabled. I tested that this happens on Default theme and also "Bonofix Theme" so the problem isn't only on the Default theme.

Reproduce the Bug

  1. Enable Dark Mode in the settings
  2. Close LogSeq
  3. Open LogSeq again
  4. LogSeq opens with Dark mode disabled again

Expected Behavior

When Dark mode is enabled it should persist app closure

Screenshots

No response

Desktop or Mobile Platform Information

Linux Fedora 38 KDE Desktop Wayland Session

Tested that this happens on following versions:

LogSeq 0.9.17 Flatpak version LogSeq 0.9.17 Flatpak version

Additional Context

No response

Are you willing to submit a PR? If you know how to fix the bug.

sprocketc commented 1 year ago

I managed to reproduce this, so I tried to follow the trail of events to understand what's going on. The source of the problem seems to be an invalid state of preferences.json. We are storing information about custom themes in there, but we are also using local storage to persist the theme. In various cases, the theme is not properly persisted on preferences.json (installing a third theme might be required to reach this state). When we reload the app, activateUserPreferences is called and loads the prefs from the json , then selectTheme which emits theme-selected that resets the local storage theme mode (state/set-theme-mode! ) to an invalid value.

4741 seems to be related to this functionality.

keesse commented 1 year ago

I have the same problem on Windows 10, but not on Linux (Mint)

abhishekdanej commented 11 months ago

I have the same problem

App Version: 0.9.20 Git Revision: 43c8e1c Platform: Mozilla/5.0 (Windows NT 10.0 Win64 x64) AppleWebKit/537.36 (KHTML like Gecko) Logseq/0.9.20 Chrome/114.0.5735.289 Electron/25.9.3 Safari/537.36 Language: en-US Plugins:

timothywlewis commented 6 months ago

If I delete my $HOME/.logseq/preferences.json and then open and close Logseq it generates this:

{
   "theme": null,
   "themes": {
     "mode": "light",
     "light": null,
     "dark": null
   },
   "externals": []
 }

If I open it and then switch the from light to system to dark and then close Logseq then it saves this, and then when it reopens it is in light mode:

{
  "theme": null,
  "themes": {
    "mode": "light",
    "light": {
      "name": "Default Light Theme",
      "url": null,
      "description": "Logseq default light theme.",
      "mode": "light",
      "selected": true,
      "group-first": true,
      "group-desc": "light themes"
    },
    "dark": null
  },
  "externals": []
}
deskoop commented 5 months ago

I'm having exactly this issue.

Distributor ID: Ubuntu Description: Ubuntu 22.04.4 LTS Release: 22.04 Codename: jammy

Anything I can do to help diagnose the problem?

timothywlewis commented 5 months ago

The workaround I found, at least on macOS, is to choose System Theme within Logseq, and then at the OS level to choose Dark theme.