client: Application.Controller: Disable flood prevention after a small timeout

Marking a message with same command is legit in those scenarios:
- Previous mark command failed, we do not want Geary to be unable to
  mark message again
- Multiple clients connected to same IMAP box:
    - Geary marked message as read
    - Another client marked it as unread
    - Geary is unable to mark it as read again
This commit is contained in:
Cédric Bellegarde 2023-07-23 16:51:19 +02:00 committed by Niels De Graef
parent 9d57346861
commit cb60bdd3ea

View file

@ -1711,16 +1711,26 @@ internal class Application.ControllerCommandStack : CommandStack {
private EmailCommand? last_executed = null;
private Geary.TimeoutManager last_executed_timeout;
public ControllerCommandStack() {
this.last_executed_timeout = new Geary.TimeoutManager.milliseconds(
250,
() => { this.last_executed = null; }
);
}
/** {@inheritDoc} */
public override async void execute(Command target,
GLib.Cancellable? cancellable)
throws GLib.Error {
this.last_executed_timeout.reset();
// Guard against things like Delete being held down by only
// executing a command if it is different to the last one.
if (this.last_executed == null || !this.last_executed.equal_to(target)) {
this.last_executed = target as EmailCommand;
this.last_executed_timeout.start();
yield base.execute(target, cancellable);
}
}