mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-10-10 19:32:02 +00:00
fix lint errors
This commit is contained in:
parent
8d30b52fc1
commit
922cd52f1b
5 changed files with 40 additions and 45 deletions
|
@ -1,10 +1,9 @@
|
|||
import {matchEmoji, matchMention, matchIssue} from '../../utils/match.js';
|
||||
import {emojiString} from '../emoji.js';
|
||||
import {getIssueIcon, getIssueColor,isIssueSuggestionsLoaded, fetchIssueSuggestions} from '../issue.js'
|
||||
import {svg} from '../../svg.js'
|
||||
import {getIssueIcon, getIssueColor, isIssueSuggestionsLoaded, fetchIssueSuggestions} from '../issue.js';
|
||||
import {svg} from '../../svg.js';
|
||||
import {createElementFromHTML} from '../../utils/dom.js';
|
||||
import { GET } from '../../modules/fetch.js';
|
||||
import {parseIssueHref} from '../../utils.js'
|
||||
import {parseIssueHref} from '../../utils.js';
|
||||
|
||||
async function issueSuggestions(text) {
|
||||
const key = '#';
|
||||
|
@ -19,7 +18,7 @@ async function issueSuggestions(text) {
|
|||
const li = document.createElement('li');
|
||||
li.setAttribute('role', 'option');
|
||||
li.setAttribute('data-value', `${key}${issue.number}`);
|
||||
li.classList.add('tw-flex', 'tw-gap-2')
|
||||
li.classList.add('tw-flex', 'tw-gap-2');
|
||||
|
||||
const icon = svg(getIssueIcon(issue), 16, ['text', getIssueColor(issue)].join(' '));
|
||||
li.append(createElementFromHTML(icon));
|
||||
|
@ -41,8 +40,6 @@ async function issueSuggestions(text) {
|
|||
export function initTextExpander(expander) {
|
||||
if (!expander) return;
|
||||
|
||||
const textarea = expander.querySelector('textarea');
|
||||
|
||||
expander?.addEventListener('text-expander-change', ({detail: {key, provide, text}}) => {
|
||||
if (key === ':') {
|
||||
const matches = matchEmoji(text);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {GET} from '../modules/fetch.js';
|
||||
import {parseIssueHref, parseRepoOwnerPathInfo} from '../utils.js'
|
||||
import {parseIssueHref, parseRepoOwnerPathInfo} from '../utils.js';
|
||||
|
||||
export function getIssueIcon(issue) {
|
||||
if (issue.pull_request) {
|
||||
|
@ -33,7 +33,7 @@ export function getIssueColor(issue) {
|
|||
}
|
||||
|
||||
export function isIssueSuggestionsLoaded() {
|
||||
return !!window.config.issueValues
|
||||
return Boolean(window.config.issueValues);
|
||||
}
|
||||
|
||||
export async function fetchIssueSuggestions() {
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import emojis from '../../../assets/emoji.json';
|
||||
import {GET} from '../modules/fetch.js';
|
||||
|
||||
|
||||
const maxMatches = 6;
|
||||
|
||||
|
@ -46,12 +44,12 @@ export function matchMention(queryText) {
|
|||
|
||||
export function matchIssue(queryText, currentIssue = null) {
|
||||
const issues = (window.config.issueValues ?? []).filter(
|
||||
issue => issue.number !== currentIssue
|
||||
(issue) => issue.number !== currentIssue,
|
||||
);
|
||||
const query = queryText.toLowerCase().trim();
|
||||
|
||||
if (!query) {
|
||||
return [...issues]
|
||||
return Array.from(issues)
|
||||
.sort((a, b) => b.number - a.number)
|
||||
.slice(0, maxMatches);
|
||||
}
|
||||
|
@ -61,8 +59,8 @@ export function matchIssue(queryText, currentIssue = null) {
|
|||
|
||||
if (isDigital) {
|
||||
// Find issues/prs with number starting with the query (prefix), sorted by number ascending
|
||||
const prefixMatches = issues.filter(issue =>
|
||||
String(issue.number).startsWith(query)
|
||||
const prefixMatches = issues.filter((issue) =>
|
||||
String(issue.number).startsWith(query),
|
||||
).sort((a, b) => a.number - b.number);
|
||||
|
||||
results.push(...prefixMatches);
|
||||
|
@ -71,8 +69,8 @@ export function matchIssue(queryText, currentIssue = null) {
|
|||
if (!isDigital || results.length < maxMatches) {
|
||||
// Fallback: find by title match, sorted by number descending
|
||||
const titleMatches = issues
|
||||
.filter(issue =>
|
||||
issue.title.toLowerCase().includes(query)
|
||||
.filter((issue) =>
|
||||
issue.title.toLowerCase().includes(query),
|
||||
)
|
||||
.sort((a, b) => b.number - a.number);
|
||||
|
||||
|
|
|
@ -26,5 +26,5 @@ window.config = {
|
|||
{number: 3, title: 'Closed issue'},
|
||||
{number: 2, title: 'PR'},
|
||||
{number: 1, title: 'Issue'},
|
||||
]
|
||||
],
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue