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

View File

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

View File

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