Fix some types after refactoring on main branch.

This commit is contained in:
baldo 2022-07-21 18:44:52 +02:00
parent d53e45cd81
commit edc5c20fdb
3 changed files with 11 additions and 10 deletions

View file

@ -202,7 +202,7 @@ function buildNodesFilter(): NodesFilter {
return nodesFilter; return nodesFilter;
} }
let lastSearchTimestamp: UnixTimestampMilliseconds = 0; let lastSearchTimestamp: UnixTimestampMilliseconds = 0 as UnixTimestampMilliseconds;
let searchTimeout: NodeJS.Timeout | undefined = undefined; let searchTimeout: NodeJS.Timeout | undefined = undefined;
let lastSearchTerm = ""; let lastSearchTerm = "";
@ -221,7 +221,8 @@ function doThrottledSearch(): void {
return return
} }
const now: UnixTimestampMilliseconds = Date.now(); // TODO: Share utils.
const now: UnixTimestampMilliseconds = Date.now() as UnixTimestampMilliseconds;
if (now - SEARCH_THROTTLE_DELAY_MS >= lastSearchTimestamp) { if (now - SEARCH_THROTTLE_DELAY_MS >= lastSearchTimestamp) {
lastSearchTimestamp = now; lastSearchTimestamp = now;
doSearch(); doSearch();

View file

@ -1,9 +1,9 @@
import {defineStore} from "pinia"; import {defineStore} from "pinia";
import {type EnhancedNode, isEnhancedNode, type NodesFilter, NodeSortField, SortDirection} from "@/types"; import {type DomainSpecificNodeResponse, isDomainSpecificNodeResponse, type NodesFilter, NodeSortField, SortDirection} from "@/types";
import {internalApi} from "@/utils/Api"; import {internalApi} from "@/utils/Api";
interface NodesStoreState { interface NodesStoreState {
nodes: EnhancedNode[]; nodes: DomainSpecificNodeResponse[];
page: number; page: number;
nodesPerPage: number; nodesPerPage: number;
totalNodes: number; totalNodes: number;
@ -24,7 +24,7 @@ export const useNodesStore = defineStore({
}; };
}, },
getters: { getters: {
getNodes(state: NodesStoreState): EnhancedNode[] { getNodes(state: NodesStoreState): DomainSpecificNodeResponse[] {
return state.nodes; return state.nodes;
}, },
@ -55,9 +55,9 @@ export const useNodesStore = defineStore({
if (searchTerm) { if (searchTerm) {
query.q = searchTerm; query.q = searchTerm;
} }
const result = await internalApi.getPagedList<EnhancedNode, NodeSortField>( const result = await internalApi.getPagedList<DomainSpecificNodeResponse, NodeSortField>(
"nodes", "nodes",
isEnhancedNode, isDomainSpecificNodeResponse,
page, page,
nodesPerPage, nodesPerPage,
sortDirection, sortDirection,

View file

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import {useNodesStore} from "@/stores/nodes"; import {useNodesStore} from "@/stores/nodes";
import {onMounted, ref, watch} from "vue"; import {onMounted, ref, watch} from "vue";
import type {EnhancedNode, MAC, NodesFilter} from "@/types"; import type {DomainSpecificNodeResponse, MAC, NodesFilter} from "@/types";
import {NodeSortField, SortDirection} from "@/types"; import {NodeSortField, SortDirection} from "@/types";
import Pager from "@/components/Pager.vue"; import Pager from "@/components/Pager.vue";
import LoadingContainer from "@/components/LoadingContainer.vue"; import LoadingContainer from "@/components/LoadingContainer.vue";
@ -51,7 +51,7 @@ function redactAllFields(shallRedactFields: boolean): void {
nodesRedactFieldsMap.value = {}; nodesRedactFieldsMap.value = {};
} }
function shallRedactField(node: EnhancedNode, field: NodeRedactField): boolean { function shallRedactField(node: DomainSpecificNodeResponse, field: NodeRedactField): boolean {
const redactFieldsMap = nodesRedactFieldsMap.value[node.mac]; const redactFieldsMap = nodesRedactFieldsMap.value[node.mac];
if (!redactFieldsMap) { if (!redactFieldsMap) {
return redactFieldsByDefault.value; return redactFieldsByDefault.value;
@ -60,7 +60,7 @@ function shallRedactField(node: EnhancedNode, field: NodeRedactField): boolean {
return redactField === undefined ? redactFieldsByDefault.value : redactField; return redactField === undefined ? redactFieldsByDefault.value : redactField;
} }
function setRedactField(node: EnhancedNode, field: NodeRedactField, value: boolean): void { function setRedactField(node: DomainSpecificNodeResponse, field: NodeRedactField, value: boolean): void {
let redactFieldsMap = nodesRedactFieldsMap.value[node.mac]; let redactFieldsMap = nodesRedactFieldsMap.value[node.mac];
if (!redactFieldsMap) { if (!redactFieldsMap) {
redactFieldsMap = {}; redactFieldsMap = {};