Skip to content

Commit

Permalink
routin fixed
Browse files Browse the repository at this point in the history
- fixed “translate_value” exists for add-words.js notification
- sorting array by translate_votes
- fixed endpoints in objects of search result
  • Loading branch information
bikenik committed Feb 10, 2019
1 parent f659f07 commit 1fc000b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2780,7 +2780,7 @@ custome translate</string>
</dict>
</dict>
<key>version</key>
<string>1.3.0</string>
<string>1.3.1</string>
<key>webaddress</key>
<string>https://github.com/bikenik/alfred-lingualeo#readme</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion src/api/add-words.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const addWords = async () => {
alfredworkflow: {
variables: {
text_notify_title: result.xp_points_added ? `${search.user_word_value}` : `Added: "${JSON.parse(process.env.search).user_word_value}" (to ${process.env.currentSetName})`,
text_notify_subtitle: result.xp_points_added ? `${search.translate_value}\n[${process.env.currentSetName}] \n🦁 ${result.hungry}% | XP: ${result.xp_points_daily} / ${result.xp_points_daily_norm} | ${result.xp_points_remaining} | 📈: ${result.xp_level}` : `${result.userdict3.related_words[0].translate_value}`,
text_notify_subtitle: result.xp_points_added ? `${search.translate_value}\n[${process.env.currentSetName}] \n🦁 ${result.hungry}% | XP: ${result.xp_points_daily} / ${result.xp_points_daily_norm} | ${result.xp_points_remaining} | 📈: ${result.xp_level}` : result.userdict3.related_words ? `${result.userdict3.related_words[0].translate_value}` : `${result.userdict3.user_translates.map(x => x.translate_value).join(', ')}`,
error: false
}
}
Expand Down
16 changes: 9 additions & 7 deletions src/api/words.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const starVotes = (versions, i) => {
do {
current--
stars += '⭑'
} while (current !== 0)
} while (current > 0)

return stars
}
Expand Down Expand Up @@ -111,7 +111,9 @@ const fetchingMissingWords = async data => {
}

if (data.error_msg === '' && data.userdict3.translations.length > 0) {
data.userdict3.translations.forEach((translate, i) => {
data.userdict3.translations.sort((a, b) => {
return b.translate_votes - a.translate_votes
}).forEach((translate, i) => {
const item = new Render('missing words',
'title', 'subtitle', 'metaInfo', 'icon')
item.title = translate.translate_value
Expand All @@ -134,8 +136,8 @@ const fetchingMissingWords = async data => {
item.valid = false
item.autocomplete = translate.lemma_value
item.metaInfo = {
id: translate.id,
word_id: data.word_id,
id: translate.translate_id,
word_id: data.userdict3.word_id,
user_word_value: alfy.input
}
item.icon = data.userdict3.word_top > 0 ? wordProgress('keyword', data.userdict3.word_top) : 'icons/keyword.png'
Expand All @@ -158,8 +160,8 @@ const fetchingMissingWords = async data => {
item.valid = false
item.autocomplete = translate.lemma_value
item.metaInfo = {
id: translate.id,
word_id: data.word_id,
id: translate.translate_id,
word_id: data.userdict3.word_id,
user_word_value: alfy.input
}
item.icon = 'icons/keyword.png'
Expand All @@ -174,7 +176,7 @@ const fetchingMissingWords = async data => {
item.icon = 'icons/Option.png'
item.metaInfo = {
id: null,
word_id: data.word_id,
word_id: data.userdict3.word_id,
user_word_value: alfy.input
}
addToItemsAdditional.push(item.getProperties())
Expand Down

0 comments on commit 1fc000b

Please sign in to comment.