Skip to content

Commit

Permalink
Set flag names
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuuuube committed Nov 5, 2024
1 parent 31bdbf9 commit a9399fe
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion ext/js/display/display-anki.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,13 @@ export class DisplayAnki {
return;
}

/** @type {Set<string>} */
const displayFlags = new Set();
for (const item of noteInfos) {
if (item === null) { continue; }
for (const cardInfo of item.cardsInfo) {
if (cardInfo.flags !== 0) {
displayFlags.add(cardInfo.flags);
displayFlags.add(this._getFlagName(cardInfo.flags));
}
}
}
Expand All @@ -562,6 +563,31 @@ export class DisplayAnki {
}
}

/**
* @param {number} flag
* @returns {string}
*/
_getFlagName(flag) {
/** @type {Record<number, string>} */
const flagNames = {
0: 'No Flag',
1: 'Red',
2: 'Orange',
3: 'Green',
4: 'Blue',
5: 'Pink',
6: 'Turquoise',
7: 'Purple',
};
if (flag in flagNames) {
return flagNames[flag];
}
return '';
}

}
}

/**
* @param {string} message
*/
Expand Down

0 comments on commit a9399fe

Please sign in to comment.