Skip to content

Commit

Permalink
UI improvements for long-running searches
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Jan 23, 2022
1 parent 77c7352 commit 747501d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
16 changes: 16 additions & 0 deletions mailbox/index.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ our ($remote_user, $remote_pass);
our $special_folder_id;
our $plen;
our ($cb); # XXX
our $search_folder_id;

require './mailbox-lib.pl';
&ReadParse();
Expand Down Expand Up @@ -102,6 +103,21 @@ my $sel = &folder_select(\@folders, $folder, "id", undef, 1, 1);
# Show page flipping arrows
&show_arrows();

# If this is the search results folder, check if a search is in progress
if ($folder->{'id'} eq $search_folder_id) {
my ($pid, $action) = &test_lock_folder($folder);
if ($pid) {
if ($action && $action->{'search'}) {
print "<b>",&text('index_searching',
"<i>".&html_escape($action->{'search'})."</i>"),
"</b><p>\n";
}
else {
print "<b>",&text('index_searching2'),"</b><p>\n";
}
}
}

# Work out displayed range
my $start = int($in{'start'});
my $end = $in{'start'}+$perpage-1;
Expand Down
14 changes: 13 additions & 1 deletion mailbox/mail_search.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@ if ($folder && $folder->{'id'} eq $search_folder_id) {

# Create a virtual folder for the search results
my $virt;
my $virt_exists = 0;
if ($in{'dest_def'} || !defined($in{'dest'})) {
# Use the default search results folder
($virt) = grep { $_->{'type'} == 6 && $_->{'id'} == 1 } @folders;
if (!$virt) {
if ($virt) {
$virt_exists = 1;
}
else {
$virt = { 'id' => $search_folder_id,
'type' => 6,
};
Expand All @@ -94,6 +98,13 @@ else {
'name' => $in{'dest'} };
}

# Lock the output folder
if ($virt_exists) {
my %act;
$act{'search'} = $in{'search'} if ($in{'simple'});
&lock_folder($virt, \%act);
}

# Show some progress if it's a big folder
my $large_search = 0;
if ($in{'returned_format'} ne "json" &&
Expand Down Expand Up @@ -239,6 +250,7 @@ else {
}
&delete_new_sort_index($virt);
&save_folder($virt, $virt);
&unlock_folder($virt) if ($virt_exists);

if ($in{'returned_format'} eq "json") {
#Return in JSON format if needed
Expand Down
5 changes: 4 additions & 1 deletion mailbox/ulang/en
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
index_title=Mail In $1
index_return=mail list
index_searching=A search for $1 is in progress. Results will be shown here when it completes.
index_searching2=A complex search is in progress. Results will be shown here when it completes.

mail_title=Read Mail
mail_none=There are no messages in folder $1
mail_pos=Messages $1 to $2 of $3 in folder $4
Expand Down Expand Up @@ -223,7 +226,7 @@ search_edest=Missing virtual folder name for results
search_eself=The search results folder cannot be searched
search_doing=Searching for $1 in folder $2.
search_doing2=Searching messages in the selected folder.
search_results=Match messages will be shown in the <a href='$1'>search results</a> folder when the search completes ...
search_results=Matching messages will be shown in the <a href='$1'>search results</a> folder when the search completes ...

virtualize_ename=Missing virtual folder name

Expand Down

0 comments on commit 747501d

Please sign in to comment.