Skip to content
Snippets Groups Projects
Commit c1847394 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Re-assign the dirnum and subnum fields after sorting dirs or subs

The dirnum and subnum are used for the next/previous (left and right) arrow
nav through sub-boards and directories. For message groups or file libs that
are configured to auto-sort the sub-boards or directory list, when importing
an unsorted list, the dirnum and subnum values would then be wrong after the
qsort() at the end of the import thus making the left/right nav thing broken
(jump to other groups/libs and such).

This fixes that.

Could I have fixed this by passing an index value to the next/prev_dirnum()
and _subnum() functions and returning the next/previous index value instead of
relying on the subnum/dirnum elemment to be correct? Maybe. <shrug>
Do I like second guessing myself? Not really.
parent e2d3cd89
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
......@@ -125,6 +125,13 @@ void sort_subs(int grpnum)
{
sort_group = grpnum;
qsort(cfg.sub, cfg.total_subs, sizeof(sub_t*), sub_compare);
// Re-number the sub-boards after sorting:
for(int i = 0; i < cfg.total_subs; ++i) {
if(cfg.sub[i]->grp != grpnum)
continue;
cfg.sub[i]->subnum = i;
}
}
static int sort_lib = 0;
......@@ -152,6 +159,13 @@ void sort_dirs(int libnum)
{
sort_lib = libnum;
qsort(cfg.dir, cfg.total_dirs, sizeof(dir_t*), dir_compare);
// Re-number the directories after sorting:
for(int i = 0; i < cfg.total_dirs; ++i) {
if(cfg.dir[i]->lib != libnum)
continue;
cfg.dir[i]->dirnum = i;
}
}
void wizard_msg(int page, int total, const char* text)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment