Merge branch 'main' into migrate-app-stores-to-state

This commit is contained in:
Abdo 2025-08-26 21:26:49 +03:00 committed by GitHub
commit b22fed1fba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 30 additions and 12 deletions

View file

@ -533,7 +533,7 @@ deck-config-health-check = Check health when optimizing
deck-config-fsrs-bad-fit-warning = Health Check: deck-config-fsrs-bad-fit-warning = Health Check:
Your memory is difficult for FSRS to predict. Recommendations: Your memory is difficult for FSRS to predict. Recommendations:
- Suspend or reformulate leeches. - Suspend or reformulate any cards you constantly forget.
- Use the answer buttons consistently. Keep in mind that "Hard" is a passing grade, not a failing grade. - Use the answer buttons consistently. Keep in mind that "Hard" is a passing grade, not a failing grade.
- Understand before you memorize. - Understand before you memorize.

View file

@ -73,7 +73,7 @@ def handle_sync_error(mw: aqt.main.AnkiQt, err: Exception) -> None:
elif isinstance(err, Interrupted): elif isinstance(err, Interrupted):
# no message to show # no message to show
return return
show_warning(str(err)) show_warning(str(err), parent=mw)
def on_normal_sync_timer(mw: aqt.main.AnkiQt) -> None: def on_normal_sync_timer(mw: aqt.main.AnkiQt) -> None:

View file

@ -226,29 +226,45 @@ def ask_user_dialog(
) )
def show_info(text: str, callback: Callable | None = None, **kwargs: Any) -> MessageBox: def show_info(
text: str,
callback: Callable | None = None,
parent: QWidget | None = None,
**kwargs: Any,
) -> MessageBox:
"Show a small info window with an OK button." "Show a small info window with an OK button."
if "icon" not in kwargs: if "icon" not in kwargs:
kwargs["icon"] = QMessageBox.Icon.Information kwargs["icon"] = QMessageBox.Icon.Information
return MessageBox( return MessageBox(
text, text,
callback=(lambda _: callback()) if callback is not None else None, callback=(lambda _: callback()) if callback is not None else None,
parent=parent,
**kwargs, **kwargs,
) )
def show_warning( def show_warning(
text: str, callback: Callable | None = None, **kwargs: Any text: str,
callback: Callable | None = None,
parent: QWidget | None = None,
**kwargs: Any,
) -> MessageBox: ) -> MessageBox:
"Show a small warning window with an OK button." "Show a small warning window with an OK button."
return show_info(text, icon=QMessageBox.Icon.Warning, callback=callback, **kwargs) return show_info(
text, icon=QMessageBox.Icon.Warning, callback=callback, parent=parent, **kwargs
)
def show_critical( def show_critical(
text: str, callback: Callable | None = None, **kwargs: Any text: str,
callback: Callable | None = None,
parent: QWidget | None = None,
**kwargs: Any,
) -> MessageBox: ) -> MessageBox:
"Show a small critical error window with an OK button." "Show a small critical error window with an OK button."
return show_info(text, icon=QMessageBox.Icon.Critical, callback=callback, **kwargs) return show_info(
text, icon=QMessageBox.Icon.Critical, callback=callback, parent=parent, **kwargs
)
def showWarning( def showWarning(

View file

@ -142,10 +142,11 @@ impl Collection {
// calculate any missing memory state // calculate any missing memory state
for c in &mut cards { for c in &mut cards {
if is_included_card(c) && c.memory_state.is_none() { if is_included_card(c) && c.memory_state.is_none() {
let original = c.clone(); let fsrs_data = self.compute_memory_state(c.id)?;
let new_state = self.compute_memory_state(c.id)?.state; c.memory_state = fsrs_data.state.map(Into::into);
c.memory_state = new_state.map(Into::into); c.desired_retention = Some(fsrs_data.desired_retention);
self.update_card_inner(c, original, self.usn()?)?; c.decay = Some(fsrs_data.decay);
self.storage.update_card(c)?;
} }
} }
let days_elapsed = self.timing_today().unwrap().days_elapsed as i32; let days_elapsed = self.timing_today().unwrap().days_elapsed as i32;
@ -293,7 +294,8 @@ impl Collection {
( (
*result.memorized_cnt_per_day.last().unwrap_or(&0.), *result.memorized_cnt_per_day.last().unwrap_or(&0.),
result.cost_per_day.iter().sum::<f32>(), result.cost_per_day.iter().sum::<f32>(),
result.review_cnt_per_day.iter().sum::<usize>() as u32, result.review_cnt_per_day.iter().sum::<usize>() as u32
+ result.learn_cnt_per_day.iter().sum::<usize>() as u32,
), ),
)) ))
}) })