refactor: update to dioc v3 (#4009)
Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
import { nextTick, reactive, ref } from "vue"
|
||||
import { SpotlightSearcherResult } from "../../.."
|
||||
import { TestContainer } from "dioc/testing"
|
||||
import { Container } from "dioc"
|
||||
|
||||
async function flushPromises() {
|
||||
return await new Promise((r) => setTimeout(r))
|
||||
@@ -32,12 +33,15 @@ describe("StaticSpotlightSearcherService", () => {
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: dioc > v3 does not recommend using constructors, move to onServiceInit
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text"],
|
||||
fieldWeights: {},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
}
|
||||
|
||||
@@ -94,12 +98,15 @@ describe("StaticSpotlightSearcherService", () => {
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: dioc > v3 does not recommend using constructors, move to onServiceInit
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text"],
|
||||
fieldWeights: {},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
}
|
||||
|
||||
@@ -159,12 +166,15 @@ describe("StaticSpotlightSearcherService", () => {
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: dioc > v3 does not recommend using constructors, move to onServiceInit
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text"],
|
||||
fieldWeights: {},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
}
|
||||
|
||||
@@ -224,12 +234,15 @@ describe("StaticSpotlightSearcherService", () => {
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: dioc > v3 does not recommend using constructors, move to onServiceInit
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text"],
|
||||
fieldWeights: {},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
}
|
||||
|
||||
@@ -285,12 +298,15 @@ describe("StaticSpotlightSearcherService", () => {
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: dioc > v3 does not recommend using constructors, move to onServiceInit
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text"],
|
||||
fieldWeights: {},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
}
|
||||
|
||||
@@ -354,12 +370,15 @@ describe("StaticSpotlightSearcherService", () => {
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: dioc > v3 does not recommend using constructors, move to onServiceInit
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text", "alternate"],
|
||||
fieldWeights: {},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Service } from "dioc"
|
||||
import { Container, Service } from "dioc"
|
||||
import {
|
||||
type SpotlightSearcher,
|
||||
type SpotlightSearcherResult,
|
||||
@@ -67,8 +67,12 @@ export abstract class StaticSpotlightSearcherService<
|
||||
|
||||
private _documents: Record<string, Doc> = {}
|
||||
|
||||
constructor(private opts: StaticSpotlightSearcherOptions<Doc>) {
|
||||
super()
|
||||
// TODO: This pattern is no longer recommended in dioc > 3, move to something else
|
||||
constructor(
|
||||
c: Container,
|
||||
private opts: StaticSpotlightSearcherOptions<Doc>
|
||||
) {
|
||||
super(c)
|
||||
|
||||
this.minisearch = new MiniSearch({
|
||||
fields: opts.searchFields as string[],
|
||||
|
||||
@@ -50,9 +50,7 @@ export class CollectionsSpotlightSearcherService
|
||||
private readonly spotlight = this.bind(SpotlightService)
|
||||
private readonly workspaceService = this.bind(WorkspaceService)
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
override onServiceInit() {
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import IconEdit from "~icons/lucide/edit"
|
||||
import IconLayers from "~icons/lucide/layers"
|
||||
import IconTrash2 from "~icons/lucide/trash-2"
|
||||
|
||||
import { Service } from "dioc"
|
||||
import { Container, Service } from "dioc"
|
||||
import * as TE from "fp-ts/TaskEither"
|
||||
import { pipe } from "fp-ts/function"
|
||||
import { cloneDeep } from "lodash-es"
|
||||
@@ -164,15 +164,18 @@ export class EnvironmentsSpotlightSearcherService extends StaticSpotlightSearche
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: This pattern is no longer recommended in dioc > 3, move to something else
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text", "alternates"],
|
||||
fieldWeights: {
|
||||
text: 2,
|
||||
alternates: 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
@@ -277,9 +280,7 @@ export class SwitchEnvSpotlightSearcherService
|
||||
private readonly workspaceService = this.bind(WorkspaceService)
|
||||
private teamEnvironmentList: TeamEnvironment[] = []
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
override onServiceInit() {
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import IconBook from "~icons/lucide/book"
|
||||
import IconLifeBuoy from "~icons/lucide/life-buoy"
|
||||
import IconZap from "~icons/lucide/zap"
|
||||
import { platform } from "~/platform"
|
||||
import { Container } from "dioc"
|
||||
|
||||
type Doc = {
|
||||
text: string | string[]
|
||||
@@ -89,15 +90,18 @@ export class GeneralSpotlightSearcherService extends StaticSpotlightSearcherServ
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: This is not recommended as of dioc > 3. Move to onServiceInit instead
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text", "alternates"],
|
||||
fieldWeights: {
|
||||
text: 2,
|
||||
alternates: 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
|
||||
@@ -66,9 +66,7 @@ export class HistorySpotlightSearcherService
|
||||
}
|
||||
)[0]
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
override onServiceInit() {
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,7 @@ export class InterceptorSpotlightSearcherService
|
||||
private readonly spotlight = this.bind(SpotlightService)
|
||||
private interceptorService = this.bind(InterceptorService)
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
override onServiceInit() {
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from "./base/static.searcher"
|
||||
|
||||
import IconShare from "~icons/lucide/share"
|
||||
import { Container } from "dioc"
|
||||
|
||||
type Doc = {
|
||||
text: string
|
||||
@@ -39,15 +40,18 @@ export class MiscellaneousSpotlightSearcherService extends StaticSpotlightSearch
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: Constructors are no longer recommended as of dioc > 3, move to onServiceInit
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text", "alternates"],
|
||||
fieldWeights: {
|
||||
text: 2,
|
||||
alternates: 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from "./base/static.searcher"
|
||||
|
||||
import IconArrowRight from "~icons/lucide/arrow-right"
|
||||
import { Container } from "dioc"
|
||||
|
||||
type Doc = {
|
||||
text: string
|
||||
@@ -61,15 +62,18 @@ export class NavigationSpotlightSearcherService extends StaticSpotlightSearcherS
|
||||
|
||||
private docKeys = Object.keys(this.documents)
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: Constructors are no longer recommended as of dioc > 3, use onServiceInit instead
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text", "alternates"],
|
||||
fieldWeights: {
|
||||
text: 2,
|
||||
alternates: 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import IconRotateCCW from "~icons/lucide/rotate-ccw"
|
||||
import IconSave from "~icons/lucide/save"
|
||||
import { GQLOptionTabs } from "~/components/graphql/RequestOptions.vue"
|
||||
import { RESTTabService } from "~/services/tab/rest"
|
||||
import { Container } from "dioc"
|
||||
|
||||
type Doc = {
|
||||
text: string | string[]
|
||||
@@ -224,15 +225,18 @@ export class RequestSpotlightSearcherService extends StaticSpotlightSearcherServ
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: Constructors are no longer recommended as of dioc > 3, use onServiceInit instead
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text", "alternates"],
|
||||
fieldWeights: {
|
||||
text: 2,
|
||||
alternates: 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
|
||||
import IconDownload from "~icons/lucide/download"
|
||||
import IconCopy from "~icons/lucide/copy"
|
||||
import { Container } from "dioc"
|
||||
|
||||
type Doc = {
|
||||
text: string
|
||||
@@ -56,15 +57,18 @@ export class ResponseSpotlightSearcherService extends StaticSpotlightSearcherSer
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: Constructors are no longer recommended as of dioc > 3, move to onServiceInit
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text", "alternates"],
|
||||
fieldWeights: {
|
||||
text: 2,
|
||||
alternates: 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import IconMonitor from "~icons/lucide/monitor"
|
||||
import IconMoon from "~icons/lucide/moon"
|
||||
import IconSun from "~icons/lucide/sun"
|
||||
import IconCheckCircle from "~icons/lucide/check-circle"
|
||||
import { Container } from "dioc"
|
||||
|
||||
type Doc = {
|
||||
text: string | string[]
|
||||
@@ -100,15 +101,18 @@ export class SettingsSpotlightSearcherService extends StaticSpotlightSearcherSer
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: Constuctors are no longer recommended as of dioc > 3, move to onServiceInit
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text", "alternates"],
|
||||
fieldWeights: {
|
||||
text: 2,
|
||||
alternates: 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import IconXSquare from "~icons/lucide/x-square"
|
||||
import { invokeAction } from "~/helpers/actions"
|
||||
import { RESTTabService } from "~/services/tab/rest"
|
||||
import { GQLTabService } from "~/services/tab/graphql"
|
||||
import { Container } from "dioc"
|
||||
|
||||
type Doc = {
|
||||
text: string | string[]
|
||||
@@ -89,15 +90,18 @@ export class TabSpotlightSearcherService extends StaticSpotlightSearcherService<
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: Constructors are no longer recommended as of dioc > 3, use onServiceInit instead
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text", "alternates"],
|
||||
fieldWeights: {
|
||||
text: 2,
|
||||
alternates: 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
|
||||
@@ -39,9 +39,7 @@ export class TeamsSpotlightSearcherService
|
||||
|
||||
private readonly tabs = this.bind(RESTTabService)
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
override onServiceInit() {
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useStreamStatic } from "~/composables/stream"
|
||||
import IconLogin from "~icons/lucide/log-in"
|
||||
import IconLogOut from "~icons/lucide/log-out"
|
||||
import { activeActions$, invokeAction } from "~/helpers/actions"
|
||||
import { Container } from "dioc"
|
||||
|
||||
type Doc = {
|
||||
text: string
|
||||
@@ -59,15 +60,18 @@ export class UserSpotlightSearcherService extends StaticSpotlightSearcherService
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: Constructors are no longer recommended as of dioc > 3, move to onServiceInit
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text", "alternates"],
|
||||
fieldWeights: {
|
||||
text: 2,
|
||||
alternates: 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit(): void {
|
||||
this.setDocuments(this.documents)
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
StaticSpotlightSearcherService,
|
||||
} from "./base/static.searcher"
|
||||
|
||||
import { Service } from "dioc"
|
||||
import { Container, Service } from "dioc"
|
||||
import * as E from "fp-ts/Either"
|
||||
import MiniSearch from "minisearch"
|
||||
import IconCheckCircle from "~/components/app/spotlight/entry/IconSelected.vue"
|
||||
@@ -102,15 +102,18 @@ export class WorkspaceSpotlightSearcherService extends StaticSpotlightSearcherSe
|
||||
},
|
||||
})
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
// TODO: Constructors are no longer recommended as of dioc > 3, move to onServiceInit
|
||||
constructor(c: Container) {
|
||||
super(c, {
|
||||
searchFields: ["text", "alternates"],
|
||||
fieldWeights: {
|
||||
text: 2,
|
||||
alternates: 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
override onServiceInit() {
|
||||
this.setDocuments(this.documents)
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
@@ -166,9 +169,7 @@ export class SwitchWorkspaceSpotlightSearcherService
|
||||
private readonly spotlight = this.bind(SpotlightService)
|
||||
private readonly workspaceService = this.bind(WorkspaceService)
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
override onServiceInit() {
|
||||
this.spotlight.registerSearcher(this)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user