Skip to content

Commit 67de03d

Browse files
committed
feat: order tag entries
1 parent bf3c6d0 commit 67de03d

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/components/LoCha/LoChaDiff.vue

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import type { Change } from 'diff'
3-
import type { Action, ActionType, ApiLink, IFeature } from '@/composables/useApi'
3+
import type { ApiLink, IFeature } from '@/composables/useApi'
44
import { diffChars } from 'diff'
55
import { groupBy, sortBy, uniq } from 'underscore'
66
import { computed } from 'vue'
@@ -29,10 +29,15 @@ const groupedTagKeys = computed((): string[][] => {
2929
...Object.keys(props.src?.tags || {}),
3030
...Object.keys(props.dst?.tags || {}),
3131
]),
32-
(key: string) =>
33-
props.diff?.[key]
34-
? -maxActionPriority(props.diff[key])
35-
: 0,
32+
(key: string) => {
33+
return props.diff?.[key]
34+
&& (
35+
!props.src?.tags || !(key in props.src.tags)
36+
? 0
37+
: props.dst && !props.dst.tags[key]
38+
? 2
39+
: 1)
40+
},
3641
)
3742
3843
return Object.values(
@@ -43,14 +48,6 @@ const groupedTagKeys = computed((): string[][] => {
4348
)
4449
})
4550
46-
function maxActionPriority(actions: Action[]): number {
47-
return Math.max(...actions.map(action => action2priority(action[1])))
48-
}
49-
50-
function action2priority(logAction: ActionType | null): number {
51-
return logAction ? { reject: 2, accept: 0 }[logAction] : 1
52-
}
53-
5451
function actionIcon(key: string): string | undefined {
5552
if (props.src && !props.dst)
5653
return undefined

0 commit comments

Comments
 (0)