mirror of https://github.com/djcb/mu.git
mu: better handle updating mail being viewed
instead of the the 'noupdate', add 'noview', so the headers still get update but we don't render unread mail twice.
This commit is contained in:
parent
93c6ff1f85
commit
82e7d7c65d
|
@ -1180,11 +1180,11 @@ get_flags (const char *path, const char *flagstr)
|
|||
|
||||
static MuError
|
||||
do_move (MuStore *store, unsigned docid, MuMsg *msg, const char *maildir,
|
||||
MuFlags flags, gboolean new_name, gboolean no_update, GError **err)
|
||||
MuFlags flags, gboolean new_name, gboolean no_view, GError **err)
|
||||
{
|
||||
unsigned rv;
|
||||
gchar *sexp;
|
||||
gboolean different_mdir;
|
||||
unsigned rv;
|
||||
gchar *sexp;
|
||||
gboolean different_mdir;
|
||||
|
||||
if (!maildir) {
|
||||
maildir = mu_msg_get_maildir (msg);
|
||||
|
@ -1207,12 +1207,13 @@ do_move (MuStore *store, unsigned docid, MuMsg *msg, const char *maildir,
|
|||
print_and_clear_g_error (err);
|
||||
}
|
||||
|
||||
if (!no_update) {
|
||||
if (!no_view) {
|
||||
sexp = mu_msg_to_sexp (msg, docid, NULL, MU_MSG_OPTION_VERIFY);
|
||||
/* note, the :move t thing is a hint to the frontend that it
|
||||
* could remove the particular header */
|
||||
print_expr ("(:update %s :move %s)", sexp,
|
||||
different_mdir ? "t" : "nil");
|
||||
print_expr ("(:update %s :move %s :view)", sexp,
|
||||
different_mdir ? "t" : "nil",
|
||||
no_view ? "nil" : "t");
|
||||
g_free (sexp);
|
||||
}
|
||||
|
||||
|
@ -1221,7 +1222,7 @@ do_move (MuStore *store, unsigned docid, MuMsg *msg, const char *maildir,
|
|||
|
||||
static MuError
|
||||
move_docid (MuStore *store, unsigned docid, const char* flagstr,
|
||||
gboolean new_name, gboolean no_update, GError **err)
|
||||
gboolean new_name, gboolean no_view, GError **err)
|
||||
{
|
||||
MuMsg *msg;
|
||||
MuError rv;
|
||||
|
@ -1243,7 +1244,7 @@ move_docid (MuStore *store, unsigned docid, const char* flagstr,
|
|||
}
|
||||
|
||||
rv = do_move (store, docid, msg, NULL, flags,
|
||||
new_name, no_update, err);
|
||||
new_name, no_view, err);
|
||||
|
||||
leave:
|
||||
if (msg)
|
||||
|
@ -1265,13 +1266,13 @@ move_msgid_maybe (ServerContext *ctx, GHashTable *args, GError **err)
|
|||
{
|
||||
GSList *docids, *cur;
|
||||
const char* maildir, *msgid, *flagstr;
|
||||
gboolean new_name, no_update;
|
||||
gboolean new_name, no_view;
|
||||
|
||||
maildir = get_string_from_args (args, "maildir", TRUE, err);
|
||||
msgid = get_string_from_args (args, "msgid", TRUE, err);
|
||||
flagstr = get_string_from_args (args, "flags", TRUE, err);
|
||||
new_name = get_bool_from_args (args, "newname", TRUE, err);
|
||||
no_update = get_bool_from_args (args, "noupdate", TRUE, err);
|
||||
no_view = get_bool_from_args (args, "noupdate", TRUE, err);
|
||||
|
||||
/* you cannot use 'maildir' for multiple messages at once */
|
||||
if (!msgid || !flagstr || maildir)
|
||||
|
@ -1285,7 +1286,7 @@ move_msgid_maybe (ServerContext *ctx, GHashTable *args, GError **err)
|
|||
|
||||
for (cur = docids; cur; cur = g_slist_next(cur))
|
||||
if (move_docid (ctx->store, GPOINTER_TO_SIZE(cur->data),
|
||||
flagstr, new_name, no_update, err) != MU_OK)
|
||||
flagstr, new_name, no_view, err) != MU_OK)
|
||||
break;
|
||||
|
||||
g_slist_free (docids);
|
||||
|
@ -1311,7 +1312,7 @@ cmd_move (ServerContext *ctx, GHashTable *args, GError **err)
|
|||
MuMsg *msg;
|
||||
MuFlags flags;
|
||||
const char *maildir, *flagstr;
|
||||
gboolean new_name, no_update;
|
||||
gboolean new_name, no_view;
|
||||
|
||||
/* check if the move is based on the message id; if so, handle
|
||||
* it in move_msgid_maybe */
|
||||
|
@ -1321,7 +1322,7 @@ cmd_move (ServerContext *ctx, GHashTable *args, GError **err)
|
|||
maildir = get_string_from_args (args, "maildir", TRUE, err);
|
||||
flagstr = get_string_from_args (args, "flags", TRUE, err);
|
||||
new_name = get_bool_from_args (args, "newname", TRUE, err);
|
||||
no_update = get_bool_from_args (args, "noupdate", TRUE, err);
|
||||
no_view = get_bool_from_args (args, "noupdate", TRUE, err);
|
||||
|
||||
docid = determine_docid (ctx->query, args, err);
|
||||
if (docid == MU_STORE_INVALID_DOCID ||
|
||||
|
@ -1348,7 +1349,7 @@ cmd_move (ServerContext *ctx, GHashTable *args, GError **err)
|
|||
}
|
||||
|
||||
if ((do_move (ctx->store, docid, msg, maildir, flags,
|
||||
new_name, no_update, err)
|
||||
new_name, no_view, err)
|
||||
!= MU_OK))
|
||||
print_and_clear_g_error (err);
|
||||
|
||||
|
|
|
@ -351,7 +351,7 @@ In the format needed for `mu4e-read-option'.")
|
|||
(with-current-buffer (mu4e-get-view-buffer)
|
||||
(eq docid (plist-get mu4e~view-msg :docid)))))
|
||||
|
||||
(defun mu4e~headers-update-handler (msg is-move)
|
||||
(defun mu4e~headers-update-handler (msg is-move maybe-view)
|
||||
"Update handler, will be called when a message has been updated
|
||||
in the database. This function will update the current list of
|
||||
headers."
|
||||
|
@ -383,7 +383,7 @@ headers."
|
|||
;; if we're actually viewing this message (in mu4e-view mode), we
|
||||
;; update it; that way, the flags can be updated, as well as the path
|
||||
;; (which is useful for viewing the raw message)
|
||||
(when (mu4e~headers-view-this-message-p docid)
|
||||
(when (and maybe-view (mu4e~headers-view-this-message-p docid))
|
||||
(mu4e-view msg))
|
||||
;; now, if this update was about *moving* a message, we don't show it
|
||||
;; anymore (of course, we cannot be sure if the message really no
|
||||
|
|
|
@ -194,7 +194,9 @@ The server output is as follows:
|
|||
;; something got moved/flags changed
|
||||
((plist-get sexp :update)
|
||||
(funcall mu4e-update-func
|
||||
(plist-get sexp :update) (plist-get sexp :move)))
|
||||
(plist-get sexp :update)
|
||||
(plist-get sexp :move)
|
||||
(plist-get sexp :view)))
|
||||
|
||||
;; a message got removed
|
||||
((plist-get sexp :remove)
|
||||
|
@ -348,7 +350,7 @@ or an error."
|
|||
(if skip-dups "true" "false")
|
||||
(if include-related "true" "false")))
|
||||
|
||||
(defun mu4e~proc-move (docid-or-msgid &optional maildir flags no-update)
|
||||
(defun mu4e~proc-move (docid-or-msgid &optional maildir flags no-view)
|
||||
"Move message identified by DOCID-OR-MSGID to optional MAILDIR
|
||||
and optionally setting FLAGS. If MAILDIR is nil, message will be
|
||||
moved within the same maildir.
|
||||
|
@ -377,8 +379,9 @@ If the variable `mu4e-change-filenames-when-moving' is
|
|||
non-nil, moving to a different maildir generates new names forq
|
||||
the target files; this helps certain tools (such as mbsync).
|
||||
|
||||
Unless NO-UPDATE is non-nil, the results are reported through
|
||||
either (:update ... ) or (:error ) sexp, which are handled my
|
||||
If NO-VIEW is non-nil, don't updat the view.
|
||||
|
||||
Returns either (:update ... ) or (:error ) sexp, which are handled my
|
||||
`mu4e-update-func' and `mu4e-error-func', respectively."
|
||||
(unless (or maildir flags)
|
||||
(mu4e-error "At least one of maildir and flags must be specified"))
|
||||
|
@ -401,7 +404,7 @@ either (:update ... ) or (:error ) sexp, which are handled my
|
|||
(or flagstr "")
|
||||
(or path "")
|
||||
(format "newname:%s" rename)
|
||||
(format "noupdate:%s" (if no-update "true" "false")))))
|
||||
(format "noview:%s" (if no-view "true" "false")))))
|
||||
|
||||
(defun mu4e~proc-index (path my-addresses cleanup lazy-check)
|
||||
"Update the message database for filesystem PATH, which should
|
||||
|
|
|
@ -903,7 +903,7 @@ changes, it triggers a refresh."
|
|||
;; mark /all/ messages with this message-id as read, so all copies of
|
||||
;; this message will be marked as read. We don't want an update thougn,
|
||||
;; we want a full message, so images etc. work correctly.
|
||||
(mu4e~proc-move msgid nil "+S-u-N" 'noupdate)
|
||||
(mu4e~proc-move msgid nil "+S-u-N" 'noview)
|
||||
(mu4e~proc-view docid mu4e-view-show-images (mu4e~decrypt-p msg))
|
||||
t))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue