Skip to content

Commit 0f5adf3

Browse files
authored
chore: minor cleanups (#1286)
1 parent f132bb7 commit 0f5adf3

File tree

7 files changed

+12
-13
lines changed

7 files changed

+12
-13
lines changed

app/composables/npm/useSearch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function useSearch(
3838
} | null>(null)
3939

4040
const isLoadingMore = shallowRef(false)
41-
const isRateLimited = ref(false)
41+
const isRateLimited = shallowRef(false)
4242

4343
const suggestions = shallowRef<SearchSuggestion[]>([])
4444
const suggestionsLoading = shallowRef(false)

app/composables/useActiveTocItem.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ import type { Ref } from 'vue'
1010
* @public
1111
*/
1212
export function useActiveTocItem(toc: Ref<TocItem[]>) {
13-
const activeId = ref<string | null>(null)
13+
const activeId = shallowRef<string | null>(null)
1414

1515
// Only run observer logic on client
1616
if (import.meta.server) {
17-
// eslint-disable-next-line @typescript-eslint/no-empty-function
1817
return { activeId }
1918
}
2019

app/composables/useCanGoBack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export function useCanGoBack() {
2-
const canGoBack = ref(false)
2+
const canGoBack = shallowRef(false)
33

44
const router = useRouter()
55

app/composables/useCharts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,11 @@ export function useCharts() {
312312
)
313313

314314
const endDateOnly = toDateOnly(downloadEvolutionOptions.endDate)
315-
const end = endDateOnly ? new Date(`${endDateOnly}T00:00:00.000Z`) : yesterday
315+
const end = endDateOnly ? parseIsoDateOnly(endDateOnly) : yesterday
316316

317317
const startDateOnly = toDateOnly(downloadEvolutionOptions.startDate)
318318
if (startDateOnly) {
319-
const start = new Date(`${startDateOnly}T00:00:00.000Z`)
319+
const start = parseIsoDateOnly(startDateOnly)
320320
return { start, end }
321321
}
322322

app/composables/useFileTreeState.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
export function useFileTreeState(baseUrl: string) {
2-
const stateKey = computed(() => `npmx-file-tree${baseUrl}`)
3-
4-
const expanded = useState<Set<string>>(stateKey.value, () => new Set<string>())
2+
const expanded = useState<Set<string>>(`npmx-file-tree${baseUrl}`, () => new Set<string>())
53

64
function toggleDir(path: string) {
75
if (expanded.value.has(path)) {

app/composables/usePreferencesProvider.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { defu } from 'defu'
2+
13
/**
24
* Abstraction for preferences storage
35
* Currently uses localStorage, designed for future user prefs API
@@ -58,17 +60,17 @@ function createLocalStorageProvider<T>(key: string): StorageProvider<T> {
5860
* Abstracts the storage mechanism to allow future migration to API-based storage
5961
*
6062
*/
61-
export function usePreferencesProvider<T>(defaultValue: T) {
63+
export function usePreferencesProvider<T extends object>(defaultValue: T) {
6264
const provider = createLocalStorageProvider<T>(STORAGE_KEY)
63-
const data = ref<T>(defaultValue) as Ref<T>
65+
const data = ref<T>(defaultValue)
6466
const isHydrated = shallowRef(false)
6567

6668
// Load from storage on client
6769
onMounted(() => {
6870
const stored = provider.get()
6971
if (stored) {
7072
// Merge stored values with defaults to handle schema evolution
71-
data.value = { ...defaultValue, ...stored }
73+
data.value = defu(stored, defaultValue)
7274
}
7375
isHydrated.value = true
7476
})

app/pages/package/[[org]]/[name].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ const isLoadingLikeData = computed(
453453
() => likeStatus.value !== 'error' && likeStatus.value !== 'success',
454454
)
455455
456-
const isLikeActionPending = ref(false)
456+
const isLikeActionPending = shallowRef(false)
457457
458458
const likeAction = async () => {
459459
if (user.value?.handle == null) {

0 commit comments

Comments
 (0)