Skip to content

Commit

Permalink
add switch in prefs for new timezone handling code; bump sync version
Browse files Browse the repository at this point in the history
AD devs: before updating the sync version to 10, please make sure
the new timezone code has been ported over. The core change to the
scheduler is in _updateCutoff():

https://github.com/ankitects/anki/blob/9736e4a970df9b67776282cde083a7b007061e87/pylib/anki/schedv2.py#L1357

with the following supporting Python functions:

https://github.com/ankitects/anki/blob/9736e4a970df9b67776282cde083a7b007061e87/pylib/anki/schedv2.py#L1410

 _timing_today() is calculated in Rust (lines up to 92, the rest are
tests):

https://github.com/ankitects/anki/blob/9736e4a970df9b67776282cde083a7b007061e87/rslib/src/sched/cutoff.rs#L20

The change went through a few iterations before stabilising, so it's
probably easier to refer to the above code than the patches that got
us to that point.
  • Loading branch information
dae committed Mar 10, 2020
1 parent 9736e4a commit 131d37d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pylib/anki/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
SYNC_ZIP_SIZE = int(2.5 * 1024 * 1024)
SYNC_ZIP_COUNT = 25
SYNC_BASE = "https://sync%s.ankiweb.net/"
SYNC_VER = 9
SYNC_VER = 10

HELP_SITE = "https://apps.ankiweb.net/docs/manual.html"

Expand Down
10 changes: 10 additions & 0 deletions qt/aqt/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ def setupCollection(self):
f.dayLearnFirst.setChecked(qc.get("dayLearnFirst", False))
if self.mw.col.schedVer() != 2:
f.dayLearnFirst.setVisible(False)
f.new_timezone.setVisible(False)
else:
f.newSched.setChecked(True)
f.new_timezone.setChecked(self.mw.col.sched._new_timezone_enabled())

def updateCollection(self):
f = self.form
Expand All @@ -118,6 +120,14 @@ def updateCollection(self):
qc["addToCur"] = not f.useCurrent.currentIndex()
qc["dayLearnFirst"] = f.dayLearnFirst.isChecked()
self._updateDayCutoff()
if self.mw.col.schedVer() != 1:
was_enabled = self.mw.col.sched._new_timezone_enabled()
is_enabled = f.new_timezone.isChecked()
if was_enabled != is_enabled:
if is_enabled:
self.mw.col.sched.set_creation_offset()
else:
self.mw.col.sched.clear_creation_offset()
self._updateSchedVer(f.newSched.isChecked())
d.setMod()

Expand Down
11 changes: 10 additions & 1 deletion qt/designer/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>422</width>
<height>611</height>
<height>636</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -136,6 +136,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="new_timezone">
<property name="text">
<string notr="true">New timezone handling (not yet supported by AnkiDroid)</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="useCurrent">
<item>
Expand Down Expand Up @@ -559,6 +566,7 @@
<tabstop>nightMode</tabstop>
<tabstop>dayLearnFirst</tabstop>
<tabstop>newSched</tabstop>
<tabstop>new_timezone</tabstop>
<tabstop>useCurrent</tabstop>
<tabstop>newSpread</tabstop>
<tabstop>uiScale</tabstop>
Expand All @@ -571,6 +579,7 @@
<tabstop>syncOnProgramOpen</tabstop>
<tabstop>fullSync</tabstop>
<tabstop>syncDeauth</tabstop>
<tabstop>media_log</tabstop>
</tabstops>
<resources/>
<connections>
Expand Down

0 comments on commit 131d37d

Please sign in to comment.