Skip to content

Commit

Permalink
Replace locale to be local variable in sorting function
Browse files Browse the repository at this point in the history
  • Loading branch information
kommunarr committed Oct 26, 2023
1 parent 3f108f8 commit 732fd29
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/renderer/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export const CHANNEL_HANDLE_REGEX = /^@[\w.-]{3,30}$/

const PUBLISHED_TEXT_REGEX = /(\d+)\s?([a-z]+)/i

function locale() {
return i18n.locale.replace('_', '-')
}

/**
* @param {string} publishedText
*/
Expand Down Expand Up @@ -679,14 +675,15 @@ export function deepCopy(obj) {
}

export function sortListUsingMethod(list, property, method) {
const locale = i18n.locale.replace('_', '-')
switch (method) {
case 'defaultSort':
break
case 'alphabeticalAscending':
list.sort((a, b) => a[property]?.toLowerCase().localeCompare(b[property]?.toLowerCase(), locale()))
list.sort((a, b) => a[property]?.toLowerCase().localeCompare(b[property]?.toLowerCase(), locale))
break
case 'alphabeticalDescending':
list.sort((a, b) => b[property]?.toLowerCase().localeCompare(a[property]?.toLowerCase(), locale()))
list.sort((a, b) => b[property]?.toLowerCase().localeCompare(a[property]?.toLowerCase(), locale))
break
}
}

0 comments on commit 732fd29

Please sign in to comment.