File tree 4 files changed +24
-18
lines changed
4 files changed +24
-18
lines changed Original file line number Diff line number Diff line change 6
6
import { projects , selectedFile , selectedUnit } from ' ../../stores/data' ;
7
7
import { forEachBlocking , getUnit } from ' ../../../lib/util' ;
8
8
import Tooltip from ' ../shared/Tooltip.svelte' ;
9
+ import { onMount } from ' svelte' ;
9
10
10
11
export let file: TranslationFile ;
11
12
$ : canShowSource = $preferences .langSelect .displayMode == ' src' || $preferences .langSelect .displayMode == ' both' ;
62
63
$ : if ($selectedFile && file ) checkTranslatedUnits ();
63
64
64
65
$ : percentage = totalUnit == 0 ? 1 : (translatedUnit / totalUnit );
66
+
67
+ let btn;
68
+
69
+ onMount (() => {
70
+ if ($selectedFile === file ) btn .scrollIntoView (false ); // Ensure visible
71
+ });
65
72
</script >
66
73
67
- <button on:click ={() => select ()} on:keydown ={() => select ()} class:selected ={$selectedFile === file }>
74
+ <button bind:this ={ btn } on:click ={() => select ()} on:keydown ={() => select ()} class:selected ={$selectedFile === file }>
68
75
<div >
69
76
{#if canShowSource }
70
77
{getLangName (displayFileName , file .sourceLanguage )}
Original file line number Diff line number Diff line change 8
8
import { DialogProperty } from " ../../../../utils/types" ;
9
9
import MoveUnitDialog from " ../../../overlay/dialogs/MoveUnitDialog.svelte" ;
10
10
import { findGroup } from " ../../../../../lib/util" ;
11
+ import { onMount } from " svelte" ;
11
12
export let unit: Unit ;
12
13
13
14
function openMoveDialog() {
29
30
}
30
31
$selectedFile = $selectedFile ;
31
32
}
33
+
34
+ let btn;
35
+
36
+ onMount (() => {
37
+ if ($selectedUnit === unit ) btn .scrollIntoView (false ); // Ensure visible
38
+ });
32
39
</script >
33
40
34
- <button class ="container" class:active ={$selectedUnit == unit } on:click ={() => $selectedUnit = unit }>
41
+ <button bind:this ={ btn } class ="container" class:active ={$selectedUnit == unit } on:click ={() => $selectedUnit = unit }>
35
42
<div class =" translate-status" >
36
43
<Tooltip tooltip =" {unit .target == " " ? " Not " : " " }Translated" >
37
44
<span class ="status" class:translated ={unit .target != " " }></span >
Original file line number Diff line number Diff line change 60
60
}
61
61
62
62
function sortSuggestions(arr : any []) {
63
- // Speghetti code, don't ask me why this works, I tried reworking it but it no work.
63
+ let targetLanguage = selectedFile . targetLanguage ?? selectedFile . sourceLanguage ;
64
64
arr .sort ((a , b ) => {
65
- let targetLanguage = selectedFile .targetLanguage ?? selectedFile .sourceLanguage ;
66
- let point = 0 ;
67
- let aMatchedPath = a .unit .getFullPathStr () == $selectedUnit .getFullPathStr () ? - 1 : 0 ;
68
- let bMatchedPath = b .unit .getFullPathStr () == $selectedUnit .getFullPathStr () ? 1 : 0 ;
69
- let aMatchedId = a .unit .id == $selectedUnit .id ? - 1 : 0 ;
70
- let bMatchedId = b .unit .id == $selectedUnit .id ? 1 : 0 ;
71
-
72
- let aSameLangGroup = a .lang .targetLanguage == null ? 0 : a .lang .targetLanguage .split (" -" )[0 ] == targetLanguage .split (" -" )[0 ] ? - 1 : 0 ;
65
+ let aSamePath = a .unit .getFullPathStr () == $selectedUnit .getFullPathStr () ? 1 : 0 ;
66
+ let bSamePath = b .unit .getFullPathStr () == $selectedUnit .getFullPathStr () ? 1 : 0 ;
67
+ let aSameLang = a .lang ?.targetLanguage == targetLanguage ? 1 : 0 ;
68
+ let bSameLang = b .lang ?.targetLanguage == targetLanguage ? 1 : 0 ;
69
+ let aSameLangGroup = a .lang .targetLanguage == null ? 0 : a .lang .targetLanguage .split (" -" )[0 ] == targetLanguage .split (" -" )[0 ] ? 1 : 0 ;
73
70
let bSameLangGroup = b .lang .targetLanguage == null ? 0 : b .lang .targetLanguage .split (" -" )[0 ] == targetLanguage .split (" -" )[0 ] ? 1 : 0 ;
74
-
75
- point += b .match > a .match ? 1 : b .match == a .match ? 0 : - 1 ;
76
- point += aSameLangGroup + bSameLangGroup + aMatchedId + bMatchedId + aMatchedPath + bMatchedPath ;
77
- point += ((a .lang .targetLanguage != null && b .lang .targetLanguage != null ) && a .lang .targetLanguage .split (" -" )[0 ] == b .lang .targetLanguage .split (" -" )[0 ]) ? 1 : 0 ; // Match primary subtag
78
-
79
- return point ;
71
+ return (bSameLang - aSameLang ) || (bSameLangGroup - aSameLangGroup ) || (bSamePath - aSamePath ) || (b .match - a .match );
80
72
});
81
73
}
82
74
Original file line number Diff line number Diff line change 1
- const VERSION = "0.4.1 " ;
1
+ const VERSION = "0.4.2 " ;
2
2
3
3
export default {
4
4
VERSION : VERSION
You can’t perform that action at this time.
0 commit comments