Commit Graph

10014 Commits

Author SHA1 Message Date
Damien Elmes
37151213cd Move more of the graph processing into the backend
The existing architecture serializes all cards and revlog entries in
the search range into a protobuf message, which the web frontend needs
to decode and then process. The thinking at the time was that this would
make it easier for add-ons to add extra graphs, but in the ~2.5 years
since the new graphs were introduced, no add-ons appear to have taken
advantage of it.

The cards and revlog entries can grow quite large on large collections -
on a collection I tested with approximately 2.5M reviews, the serialized
data is about 110MB, which is a lot to have to deserialize in JavaScript.

This commit shifts the preliminary processing of the data to the Rust end,
which means the data is able to be processed faster, and less needs to
be sent to the frontend. On the test collection above, this reduces the
serialized data from about 110MB to about 160KB, resulting in a more
than 2x performance improvement, and reducing frontend memory usage from
about 400MB to about 40MB.

This also makes #2043 more feasible - while it is still about 50-100%
slower than protobufjs, with the much smaller message size, the difference
is only about 10ms.
2022-12-16 21:42:17 +10:00
Damien Elmes
fa625d7ad8
Minor Rust cleanups (#2272)
* Run cargo +nightly fmt

* Latest prost-build includes clippy workaround

* Tweak Rust protobuf imports

- Avoid use of stringify!(), as JetBrains editors get confused by it
- Stop merging all protobuf symbols into a single namespace

* Remove some unnecessary qualifications

Found via IntelliJ lint

* Migrate some asserts to assert_eq/ne

* Remove mention of node_modules exclusion

This no longer seems to be necessary after migrating away from Bazel,
and excluding it means TS/Svelte files can't be edited properly.
2022-12-16 21:40:27 +10:00
Damien Elmes
22ecef6fb2
Merge pull request #2255 from RumovZ/replace-pct-str-2
Replace pct-str with local percent_encoding crate
2022-12-16 11:21:04 +00:00
Damien Elmes
01caec2a72 Fix wrong Qt version in macOS bundle 2022-12-16 16:53:58 +10:00
Damien Elmes
35cbde65d7 Revert "Always scan for media changes"
This reverts commit 09cb8b3cf6.

Overhead on larger folders/slower devices is more than I originally
anticipated, and can run into multiple seconds. This seems to be
particularly egregious on mobile, which I presume is due to sandboxing
overhead.
2022-12-15 20:40:20 +10:00
Damien Elmes
2ccc8ca436 Fix sync spinner not showing
Regressed in #2137

Closes #2270
2022-12-15 19:10:05 +10:00
Damien Elmes
e0c4ba4b60 Revert to Qt 6.3.1 on macOS
Due to flicker reported on #2263. 6.3.1 was used in the 2.1.54 and is
the more conservative choice; we can trial 6.3.2 after release.
2022-12-14 15:25:10 +10:00
Damien Elmes
5753fe45d0 Update translations 2022-12-14 14:35:40 +10:00
Hikaru Y
7144949dd5
Fix MathJax popup fails to appear (#2268)
* Fix MathJax popup fails to appear when adding MathJax via Fx button

* Revert "Fix MathJax popup fails to appear when adding MathJax via Fx button"

This reverts commit 11115f59bcbde22bbc0448bfd6b86e887a8a56a7.

* Fix MathJax popup fails to appear when adding MathJax via Fx button

Use setTimeout() according to the PR review
2022-12-14 14:10:23 +10:00
Damien Elmes
1ed2cce648 Use 6 digit hex codes for default colors
The color selector prints a warning otherwise.
2022-12-13 11:35:21 +10:00
Damien Elmes
c5da911f24 Another attempt at fixing reversed toolbar on first startup
May close https://github.com/ankitects/anki/issues/2269
2022-12-13 10:51:13 +10:00
Damien Elmes
449338d7ec Revert "Avoid setting RTL on first run"
This reverts commit 5dc79e22cd.

I appear to have been confused in my earlier testing, as reverting
this change seems to make no difference the top bar on first startup,
and fixes a bunch of other regressions that the original change introduced.

https://github.com/ankitects/anki/issues/2269
2022-12-13 10:45:36 +10:00
Matthias Metelka
968a14784f
Add slight inset shadow to hovered buttons (#2267)
* Replace border-with inset shadow on button hover

* Align gradient-end with base color for primary buttons too

to achieve a more natural hover effect.
2022-12-12 15:41:23 +10:00
Damien Elmes
86b52f7626 Add a small unit test
pct-str encoded the / character as well, but the difference shouldn't
matter in our case.
2022-12-12 14:54:11 +10:00
Matthias Metelka
ec4c1b1a20
Do not append description button for filtered deck (#2266) 2022-12-11 15:03:11 +10:00
Matthias Metelka
a06ee6b0bf
Add style for disabled DropdownItem (#2265)
* Add style for disabled DropdownItem

* Switch back to using disabled as attribute instead of class
2022-12-11 13:06:18 +10:00
Damien Elmes
8d34ba93b0 Fix color defaulting to black
Closes #2261
2022-12-11 11:58:21 +10:00
Damien Elmes
f9f8769ea8 Update certifi to fix security alert 2022-12-11 11:42:08 +10:00
Damien Elmes
8506206c5b Fix cursor moving to field start when closing MathJax editor
Closes #2258
2022-12-11 11:39:03 +10:00
Matthias Metelka
2179f9e133
Remove dark theme exclusive inset shadow from FloatingArrow (#2257) 2022-12-11 11:18:59 +10:00
RumovZ
c888ccc285 Replace pct-str with local ascii_percent_encoding 2022-12-09 11:49:39 +01:00
RumovZ
0b206b8a81 Ignore non-ASCII chars in ascii_percent_encoding 2022-12-09 11:47:59 +01:00
RumovZ
55f27779cf Add local copy of percent_encoding crate 2022-12-09 11:46:00 +01:00
Matthias Metelka
f38c4e2ff9
Fix dropdown items wrapping (#2252) 2022-12-09 13:44:06 +10:00
Damien Elmes
b1a21c5b02 Update translations 2022-12-09 12:37:27 +10:00
Damien Elmes
01f6d618bc Increase initial add-on dialog size
I can't reproduce the reported issue, but this will probably help.

https://forums.ankiweb.net/t/anki-2-1-55-beta-7/25130/10
2022-12-09 12:36:28 +10:00
Henrik Giesel
6d0a242a1b
Fix overwrite surround (#2247)
* Revert "Revert to setFormat() to fix color setting"

This reverts commit 613b5c1034.

* Fix overwrite-surround
2022-12-09 10:10:58 +10:00
Damien Elmes
3413115be7 Fix MathJax editor not hiding on blur again
Originally fixed with e14f87ba99,
accidentally reverted in #2070
2022-12-08 22:46:23 +10:00
Matthias Metelka
8f311f5e8c
Fix popover animation causing placement switching loop (#2246) 2022-12-08 22:35:55 +10:00
Matthias Metelka
fb2dcf1484
Make SpinBox chevrons more subtle (#2243)
* Make SpinBox chevrons more subtle

and keep showing them when input is focused.

* Show chevrons only on hover

* Revert "Show chevrons only on hover"

This reverts commit 20e5ec169116fe3638c53c6ec414151d20c0de6b.
2022-12-08 22:32:35 +10:00
Matthias Metelka
6481899454
Fix some more RTL issues (#2244)
* Swap flag and mark indicator position in RTL mode

* Make buttons of bottom toolbar align to edge of screen in RTL mode

* Use start instead of left and end instead of right
2022-12-08 22:29:56 +10:00
Damien Elmes
1215ee7849 Deck options: hide webview after showing dialog
This seems to reduce flicker, presumably because the webview doesn't pick
up the correct geometry until the dialog is shown.
2022-12-08 22:18:28 +10:00
Damien Elmes
93d14de95c Set night-mode class on web page initialization
Ensures the background is the correct color by the time the webview
is shown. We keep the #night check for now, as it's useful when testing
in an external browser.
2022-12-08 22:02:12 +10:00
Damien Elmes
1870253589 Add default_size argument to restoreGeom(); fix missing dialogs
The starting size of a webview seems to be 640x480, but if it is hidden
without retainSizeWhenHidden being set, the dialog it contains can end
up with a height of 0, which prevents the dialog from being shown.

By being explicit about our desired starting size, we can use a more
useful default, and avoid the issue of missing dialogs.
2022-12-08 22:02:12 +10:00
Damien Elmes
09bfe104d8 Avoid setting path when invoking git
We don't need the amended path, and it seems to break things for
a user:

https://forums.ankiweb.net/t/anki-2-1-55-beta-5-6/24870/89
2022-12-08 12:44:39 +10:00
RumovZ
0e7f02bfb7
Update Chrono Crate (#2242)
* Remove deprecated `and_hms()`

* Update chrono

* Update licenses and fix script

* Remove deprecated Date struct

* Remove chrono pin

* Skip format check on .vscode

Was failing for no reason.

* Replace deprecated chrono functions

* Add cargo-deny to update-licenses & pin versions (dae)

* Remove time 0.1 dependency  (dae)

We don't need to wait for chrono 0.5; it was provided behind a legacy
feature flag.
2022-12-07 17:00:14 +10:00
Yoshi
ef3cfc561c
Facilitate hook updating/replacement (#2213)
* Facilitate updating of hooks

- Add instructions in contributing.md
- Change addon_config_editor_will_update_json hook to work with the new
  hookslib code

* Fix typo in docs

* Always run replaced hook

* Use lowercase list for typing

* Forbid defining both a replaced and a legacy hook
2022-12-07 15:39:57 +10:00
Matthias Metelka
d2fa50dd9f
Persist field states with SessionOptions object (#2241)
* Persist collapsed- and field states with SessionOptions object

* Format types.ts

* Replace format function with f-string

* Give setters more descriptive parameter names

* Do not use default prefix for descriptions and fonts

since they are not meant to be changed via Svelte.
2022-12-07 15:37:46 +10:00
Matthias Metelka
e059aab184
Improve Select component and add it back to Change Notetype screen (#2239)
* Do not include oldIdx in Select change event

I included it due to confusion about the variable names in the Change Notetype components.

* Remove redundant on:change listener from NotetypeSelector

* Use Select component in Change Notetype MapperRow (again)

* Remove redundant --cols and --col-size definitions

Bootstrap divides rows into columns of equal width by default.

* Add highlight to active DropdownItem

* Remove bootstrap dropdown item styling

* Fix JS error on dropdown accept action

cause: When closing the dropdown, buttonRef was removed before the callback in setTimeout was run.
2022-12-07 15:31:37 +10:00
Damien Elmes
9dc6e41153 Switch back to winrt to see if it fixes slow TTS
https://forums.ankiweb.net/t/slow-tts-and-duplicated-voices/25157/7

winrt blocks an upgrade from Python 3.9, so this will be a temporary
solution at best.
2022-12-06 20:30:54 +10:00
Abdo
f0c3256e39
Fix Esc not closing TS pages (#2240) 2022-12-06 20:03:34 +10:00
Damien Elmes
613b5c1034 Revert to setFormat() to fix color setting
The surrounder code is somewhat complicated, and it could do with either
more documentation, or a simplification.

Closes #2121
2022-12-05 17:00:47 +10:00
Abdo
6ef460e74a
Close MathJax editor when Esc is pressed (#2237) 2022-12-05 15:08:38 +10:00
Damien Elmes
8165f95cde Fix the wrong notetype being selected by default
Regressed in #2082

https://forums.ankiweb.net/t/anki-2-1-55-beta-7/25130/7
2022-12-05 15:08:00 +10:00
Damien Elmes
fad1ff7467 Tweak graph margins again
2860ee1424 (commitcomment-91940936)
2022-12-04 21:50:58 +10:00
Damien Elmes
6095b01301 Avoid hiding webview when refreshing
When opening the graphs screen in dark mode, we want to load the
page first and then reveal the webview, to prevent a flash of white
that can appear as the page loads. Previously we did this for any
call to load_ts_page(), but this results in flicker when refreshing
an existing webview, such as the move from deck list to congrats screen.
In those cases, at least on the machines I have to test with here, the
refresh is smoother without the hide and show step.

The new window case is still not ideal - while the hide+show prevents a
flash of white, there is a flash of black instead, presumably as the
webview draws the initially-blank framebuffer with the contents of the
webview.
2022-12-04 21:17:57 +10:00
Damien Elmes
1ca05b00ec Exempt MathJax images from image shrinking
https://forums.ankiweb.net/t/anki-2-1-55-beta-mathjax-preview/23529/18
2022-12-04 20:03:27 +10:00
Damien Elmes
2860ee1424 Fix graphs not taking up full width 2022-12-04 19:48:18 +10:00
Damien Elmes
a05174b411 Collapse margins on narrow screens 2022-12-04 19:47:03 +10:00
Damien Elmes
2531a4dab6 Fix pie chart disappearing in 2/3 column graph modes 2022-12-04 19:24:37 +10:00