mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-19 10:59:54 +00:00
prevent duplication in available plugins
This commit is contained in:
parent
800c1fa039
commit
1ccd1df6e1
@ -1,4 +1,5 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import { compare as semverCompare } from 'semver'
|
||||||
import { Observable, from, forkJoin, map } from 'rxjs'
|
import { Observable, from, forkJoin, map } from 'rxjs'
|
||||||
import { Injectable, Inject } from '@angular/core'
|
import { Injectable, Inject } from '@angular/core'
|
||||||
import { Logger, LogService, PlatformService, BOOTSTRAP_DATA, BootstrapData, PluginInfo } from 'tabby-core'
|
import { Logger, LogService, PlatformService, BOOTSTRAP_DATA, BootstrapData, PluginInfo } from 'tabby-core'
|
||||||
@ -55,6 +56,17 @@ export class PluginManagerService {
|
|||||||
),
|
),
|
||||||
map(plugins => plugins.filter(x => x.packageName.startsWith(namePrefix))),
|
map(plugins => plugins.filter(x => x.packageName.startsWith(namePrefix))),
|
||||||
map(plugins => plugins.filter(x => !BLACKLIST.includes(x.packageName))),
|
map(plugins => plugins.filter(x => !BLACKLIST.includes(x.packageName))),
|
||||||
|
map(plugins => {
|
||||||
|
const mapping: Record<string, PluginInfo[]> = {}
|
||||||
|
for (const p of plugins) {
|
||||||
|
mapping[p.name] ??= []
|
||||||
|
mapping[p.name].push(p)
|
||||||
|
}
|
||||||
|
return Object.values(mapping).map(list => {
|
||||||
|
list.sort((a, b) => -semverCompare(a.version, b.version))
|
||||||
|
return list[0]
|
||||||
|
})
|
||||||
|
}),
|
||||||
map(plugins => plugins.sort((a, b) => a.name.localeCompare(b.name))),
|
map(plugins => plugins.sort((a, b) => a.name.localeCompare(b.name))),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user