Skip to content

Commit

Permalink
Fix frontend memory leak (#4864)
Browse files Browse the repository at this point in the history
  • Loading branch information
zackkrida authored Sep 5, 2024
1 parent c517c26 commit a5d966d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
26 changes: 12 additions & 14 deletions frontend/src/stores/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,19 @@ export interface UiState {

export const breakpoints = Object.keys(ALL_SCREEN_SIZES)

export const defaultUiState: UiState = {
instructionsSnackbarState: "not_shown",
innerFilterVisible: false,
isFilterDismissed: false,
isDesktopLayout: false,
breakpoint: "sm",
dismissedBanners: [],
shouldBlurSensitive: true,
revealedSensitiveResults: [],
headerHeight: 80,
colorMode: "system",
}

export const useUiStore = defineStore("ui", {
state: (): UiState => ({ ...defaultUiState }),
state: (): UiState => ({
instructionsSnackbarState: "not_shown",
innerFilterVisible: false,
isFilterDismissed: false,
isDesktopLayout: false,
breakpoint: "sm",
dismissedBanners: [],
shouldBlurSensitive: true,
revealedSensitiveResults: [],
headerHeight: 80,
colorMode: "system",
}),

getters: {
cookieState(state): OpenverseCookieState["ui"] {
Expand Down
16 changes: 14 additions & 2 deletions frontend/test/unit/specs/stores/ui-store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { vi, describe, beforeEach, it, expect, test } from "vitest"

import { setActivePinia, createPinia } from "~~/test/unit/test-utils/pinia"

import { defaultUiState, UiState, useUiStore } from "~/stores/ui"
import { UiState, useUiStore } from "~/stores/ui"
import { BannerId } from "~/types/banners"

vi.mock("~/types/cookies", async () => {
Expand All @@ -19,7 +19,19 @@ vi.mock("~/types/cookies", async () => {
}
})

const initialState = defaultUiState
// Should mirror the "state" property of useUiStore
const initialState: UiState = {
instructionsSnackbarState: "not_shown",
innerFilterVisible: false,
isFilterDismissed: false,
isDesktopLayout: false,
breakpoint: "sm",
dismissedBanners: [],
shouldBlurSensitive: true,
revealedSensitiveResults: [],
headerHeight: 80,
colorMode: "system",
}

const VISIBLE_AND_DISMISSED = {
innerFilterVisible: true,
Expand Down
2 changes: 1 addition & 1 deletion utilities/load_testing/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# K6 #
######

FROM docker.io/grafana/k6:v0.51.0 AS k6
FROM docker.io/grafana/k6:0.51.0 AS k6

###############
# Observation #
Expand Down

0 comments on commit a5d966d

Please sign in to comment.