fix: environments being cringe :)

This commit is contained in:
Andrew Bastin
2021-08-21 10:38:35 +05:30
parent 77d876d443
commit c00c8f249e
3 changed files with 26 additions and 18 deletions

View File

@@ -124,8 +124,10 @@ export default defineComponent({
processHighlights() {
if (!this.highlightEnabled) {
this.htmlOutput = this.internalValue
this.$emit("input", this.internalValue)
this.$emit("change", this.internalValue)
if (this.intervalTree !== this.value) {
this.$emit("input", this.internalValue)
this.$emit("change", this.internalValue)
}
return
}
@@ -223,8 +225,10 @@ export default defineComponent({
this.renderTippy()
})
this.$emit("input", this.internalValue)
this.$emit("change", this.internalValue)
if (this.internalValue !== this.value) {
this.$emit("input", this.internalValue)
this.$emit("change", this.internalValue)
}
},
renderTippy() {
const tippable = document.querySelectorAll("[v-tippy]")

View File

@@ -141,17 +141,14 @@ export function initEnvironments() {
.doc(user.uid)
.collection("globalEnv")
.onSnapshot((globalsRef) => {
const variables: any[] = []
globalsRef.forEach((doc) => {
const variable = doc.data()
variable.id = doc.id
variables.push(variable)
})
if (globalsRef.docs.length === 0) {
loadedGlobals = true
return
}
const doc = globalsRef.docs[0].data()
loadedGlobals = false
setGlobalEnvVariables(variables)
setGlobalEnvVariables(doc.variables)
loadedGlobals = true
})
}

View File

@@ -1,5 +1,6 @@
import { isEqual } from "lodash"
import { combineLatest } from "rxjs"
import { map, pluck } from "rxjs/operators"
import { distinctUntilChanged, map, pluck } from "rxjs/operators"
import DispatchingStore, {
defineDispatchers,
} from "~/newstore/DispatchingStore"
@@ -232,13 +233,18 @@ export const environmentsStore = new DispatchingStore(
)
export const environments$ = environmentsStore.subject$.pipe(
pluck("environments")
pluck("environments"),
distinctUntilChanged()
)
export const globalEnv$ = environmentsStore.subject$.pipe(pluck("globals"))
export const globalEnv$ = environmentsStore.subject$.pipe(
pluck("globals"),
distinctUntilChanged()
)
export const selectedEnvIndex$ = environmentsStore.subject$.pipe(
pluck("currentEnvironmentIndex")
pluck("currentEnvironmentIndex"),
distinctUntilChanged()
)
export const currentEnvironment$ = combineLatest([
@@ -279,7 +285,8 @@ export const aggregateEnvs$ = combineLatest([
)
return results
})
}),
distinctUntilChanged(isEqual)
)
export function getCurrentEnvironment(): Environment {