Skip to content

Commit

Permalink
fix: typesafe fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdvlpr committed Oct 16, 2023
1 parent ca6f623 commit b2ff686
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
16 changes: 10 additions & 6 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,16 @@ async function boot() {
if (!details.responseHeaders) details.responseHeaders = {}
details.responseHeaders['x-frame-options'] = ['ALLOWALL']
details.responseHeaders['content-security-policy'] = []
const setCookie = details.responseHeaders['set-cookie']
details.responseHeaders['set-cookie'] = setCookie.map((c) =>
c
.replace('HttpOnly', 'Secure')
.replace('Secure', 'SameSite=None; Secure'),
)
const setCookie = details.responseHeaders['set-cookie'] as
| string[]
| undefined
if (setCookie) {
details.responseHeaders['set-cookie'] = setCookie.map((c) =>
c
.replace('HttpOnly', 'Secure')
.replace('Secure', 'SameSite=None; Secure'),
)
}
resolve({ responseHeaders: details.responseHeaders })
},
)
Expand Down
4 changes: 3 additions & 1 deletion src/components/form/FormDatePicker.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- eslint-disable vue/no-v-html -->
<template>
<span class="text-body-2" v-html="$t(label)" />
<span class="text-body-2" v-html="label" />
<VueDatePicker
v-model="value"
:locale="locale"
Expand All @@ -21,9 +21,11 @@
:week-start="$getWeekStart()"
:enable-time-picker="false"
prevent-min-max-navigation
v-bind="$attrs"
/>
</template>
<script setup lang="ts">
defineOptions({ inheritAttrs: false })
const props = withDefaults(
defineProps<{
modelValue: string | null
Expand Down
10 changes: 5 additions & 5 deletions src/utils/prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ const schema: Schema<PrefStore> = {
},
}

let store: Store<PrefStore>
let store: Store<PrefStore> | undefined

function storeOptions(name = 'prefs'): Store.Options<PrefStore> {
return {
Expand Down Expand Up @@ -611,7 +611,7 @@ export async function getCongPrefs() {
}

export function storePath() {
return store.path ? normalizeSafe(store.path) : undefined
return store?.path ? normalizeSafe(store.path) : undefined
}

export function initStore(name: string) {
Expand All @@ -629,6 +629,7 @@ export function initStore(name: string) {
}

export function setPrefs(key: string, value: any) {
if (!store) return
store.set(key, value)
const prefs = readJsonSync(store.path) as PrefStore
useNuxtApp().$sentry.setContext('prefs', {
Expand All @@ -647,14 +648,13 @@ export function switchCong(path: string) {
}

export function getPrefs<T = unknown>(key: string) {
return store.get(key) as T
return store?.get(key) as T
}

export function getAllPrefs() {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
return store ? (readJsonSync(store.path) as PrefStore) : PREFS
}

export function setAllPrefs(prefs: PrefStore) {
store.set(prefs)
store?.set(prefs)
}

0 comments on commit b2ff686

Please sign in to comment.