chore: merge hoppscotch/hoppscotch/staging into hoppscotch/self-hosted/main
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { initializeApp } from "firebase/app"
|
||||
import { platform } from "~/platform"
|
||||
import { initAnalytics } from "./analytics"
|
||||
import { initCollections } from "./collections"
|
||||
import { initHistory } from "./history"
|
||||
import { initSettings } from "./settings"
|
||||
|
||||
@@ -25,7 +24,7 @@ export function initializeFirebase() {
|
||||
|
||||
platform.auth.performAuthInit()
|
||||
initSettings()
|
||||
initCollections()
|
||||
platform.sync.collections.initCollectionsSync()
|
||||
initHistory()
|
||||
platform.sync.environments.initEnvironmentsSync()
|
||||
initAnalytics()
|
||||
|
||||
3
packages/hoppscotch-common/src/platform/collections.ts
Normal file
3
packages/hoppscotch-common/src/platform/collections.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export type CollectionsPlatformDef = {
|
||||
initCollectionsSync: () => void
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
import { AuthPlatformDef } from "./auth"
|
||||
import { UIPlatformDef } from "./ui"
|
||||
import { EnvironmentsPlatformDef } from "./environments"
|
||||
import { CollectionsPlatformDef } from "./collections"
|
||||
|
||||
export type PlatformDef = {
|
||||
ui?: UIPlatformDef
|
||||
auth: AuthPlatformDef
|
||||
sync: {
|
||||
environments: EnvironmentsPlatformDef
|
||||
collections: CollectionsPlatformDef
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
"stream-browserify": "^3.0.0",
|
||||
"util": "^0.12.4",
|
||||
"vue": "^3.2.41",
|
||||
"workbox-window": "^6.5.4"
|
||||
"workbox-window": "^6.5.4",
|
||||
"@hoppscotch/data": "workspace:^0.4.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@intlify/vite-plugin-vue-i18n": "^6.0.1",
|
||||
|
||||
@@ -9,14 +9,22 @@ import {
|
||||
translateToNewRESTCollection,
|
||||
translateToNewGQLCollection,
|
||||
} from "@hoppscotch/data"
|
||||
import { platform } from "~/platform"
|
||||
|
||||
import { def as platformAuth } from "./firebase/auth"
|
||||
|
||||
import {
|
||||
restCollections$,
|
||||
graphqlCollections$,
|
||||
setRESTCollections,
|
||||
setGraphqlCollections,
|
||||
} from "~/newstore/collections"
|
||||
import { getSettingSubject, settingsStore } from "~/newstore/settings"
|
||||
} from "@hoppscotch/common/newstore/collections"
|
||||
|
||||
import {
|
||||
getSettingSubject,
|
||||
settingsStore,
|
||||
} from "@hoppscotch/common/newstore/settings"
|
||||
|
||||
import { CollectionsPlatformDef } from "@hoppscotch/common/platform/collections"
|
||||
|
||||
type CollectionFlags = "collectionsGraphql" | "collections"
|
||||
|
||||
@@ -40,11 +48,8 @@ let loadedRESTCollections = false
|
||||
*/
|
||||
let loadedGraphqlCollections = false
|
||||
|
||||
export async function writeCollections(
|
||||
collection: any[],
|
||||
flag: CollectionFlags
|
||||
) {
|
||||
const currentUser = platform.auth.getCurrentUser()
|
||||
async function writeCollections(collection: any[], flag: CollectionFlags) {
|
||||
const currentUser = platformAuth.getCurrentUser()
|
||||
|
||||
if (currentUser === null)
|
||||
throw new Error("User not logged in to write collections")
|
||||
@@ -68,11 +73,11 @@ export async function writeCollections(
|
||||
}
|
||||
}
|
||||
|
||||
export function initCollections() {
|
||||
const currentUser$ = platform.auth.getCurrentUserStream()
|
||||
function initCollectionsSync() {
|
||||
const currentUser$ = platformAuth.getCurrentUserStream()
|
||||
|
||||
const restCollSub = restCollections$.subscribe((collections) => {
|
||||
const currentUser = platform.auth.getCurrentUser()
|
||||
const currentUser = platformAuth.getCurrentUser()
|
||||
|
||||
if (
|
||||
loadedRESTCollections &&
|
||||
@@ -84,7 +89,7 @@ export function initCollections() {
|
||||
})
|
||||
|
||||
const gqlCollSub = graphqlCollections$.subscribe((collections) => {
|
||||
const currentUser = platform.auth.getCurrentUser()
|
||||
const currentUser = platformAuth.getCurrentUser()
|
||||
|
||||
if (
|
||||
loadedGraphqlCollections &&
|
||||
@@ -177,8 +182,12 @@ export function initCollections() {
|
||||
gqlCollSub.unsubscribe()
|
||||
currentUserSub.unsubscribe()
|
||||
|
||||
initCollections()
|
||||
initCollectionsSync()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export const def: CollectionsPlatformDef = {
|
||||
initCollectionsSync,
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
import { createHoppApp } from "@hoppscotch/common"
|
||||
import { def as authDef } from "./firebase/auth"
|
||||
import { def as envDef } from "./environments"
|
||||
import { def as collectionsDef } from "./collections"
|
||||
|
||||
createHoppApp("#app", {
|
||||
auth: authDef,
|
||||
sync: {
|
||||
environments: envDef,
|
||||
collections: collectionsDef,
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user