Skip to content

Commit

Permalink
Depreacted Priority type. 👽
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbeutler committed Apr 13, 2022
1 parent 1627442 commit 4f440a8
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 139 deletions.
30 changes: 16 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,23 @@ namespace ScanCategorizer {
Logger.log('Apply category: ' + sorted[0].name);
handleMatch(file, sorted[0]);

for (let i = 1; i < sorted.length; i++) {
const category = sorted[i];

// Check if category allows for secondary categorization.
if (!category.allowSecondary) {
Logger.log(
`Category ${category.name} is not allowed to be a secondary category and will be skipped.`,
);

// Skip
continue;
if (sorted.length > 1) {
for (let i = 1; i < sorted.length; i++) {
const category = sorted[i];

// Check if category allows for secondary categorization.
if (!category.allowSecondary) {
Logger.log(
`Category ${category.name} is not allowed to be a secondary category and will be skipped.`,
);

// Skip
continue;
}

Logger.log('Creating shortcuts for category: ' + category.name);
handleMatch(file, category, true);
}

Logger.log('Creating shortcuts for category: ' + category.name);
handleMatch(file, category, true);
}

Logger.log('Finished processing file: ' + file.getName());
Expand Down
10 changes: 2 additions & 8 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import {Helpers} from './helpers';

/* eslint-disable no-unused-vars */
export namespace Query {
export const enum Priority {
LOW = -1,
DEFAULT = 0,
HIGH = 1,
}

export interface Condition {
type: 'and' | 'or';
values: (RegExp | string)[];
Expand Down Expand Up @@ -190,10 +184,10 @@ export namespace Query {
export const sortMatchesByPriority = (matches: Category[]): Category[] => {
return matches.sort((a: Category, b: Category) => {
if (!a.priority) {
a.priority = Priority.DEFAULT;
a.priority = 0;
}
if (!b.priority) {
b.priority = Priority.DEFAULT;
b.priority = 0;
}
if (a.priority > b.priority) {
return -1;
Expand Down
Loading

0 comments on commit 4f440a8

Please sign in to comment.