mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-19 05:45:01 -04:00
[ENG-1367] TypeError: null is not an object (#1698)
strickter types pog
This commit is contained in:
@@ -4,7 +4,10 @@ use crate::{
|
||||
util::db::{maybe_missing, MissingFieldError},
|
||||
};
|
||||
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt::{Display, Formatter},
|
||||
};
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -44,6 +47,9 @@ pub struct JobReport {
|
||||
pub name: String,
|
||||
pub action: Option<String>,
|
||||
pub data: Option<Vec<u8>>,
|
||||
// In Typescript `any | null` is just `any` so we don't get prompted for null checks
|
||||
// TODO(@Oscar): This will be fixed
|
||||
#[specta(type = Option<HashMap<String, serde_json::Value>>)]
|
||||
pub metadata: Option<serde_json::Value>,
|
||||
pub is_background: bool,
|
||||
pub errors_text: Vec<String>,
|
||||
|
||||
@@ -14,7 +14,11 @@ export const useIsLocationIndexing = (locationId: number): boolean => {
|
||||
const isLocationIndexing =
|
||||
jobGroups?.some((group) =>
|
||||
group.jobs.some((job) => {
|
||||
if (job.name === 'indexer' && job.metadata.location.id === locationId && (job.status === 'Running' || job.status === 'Queued')) {
|
||||
if (
|
||||
job.name === 'indexer' &&
|
||||
job.metadata?.location.id === locationId &&
|
||||
(job.status === 'Running' || job.status === 'Queued')
|
||||
) {
|
||||
return job.completed_task_count === 0;
|
||||
}
|
||||
})
|
||||
|
||||
@@ -25,7 +25,7 @@ export const useRedirectToNewLocation = () => {
|
||||
.some(
|
||||
(j) =>
|
||||
j.name === 'indexer' &&
|
||||
j.metadata.location.id === newLocation &&
|
||||
j.metadata?.location.id === newLocation &&
|
||||
(j.completed_task_count > 0 || j.completed_at != null)
|
||||
);
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ export type JobGroup = { id: string; action: string | null; status: JobStatus; c
|
||||
|
||||
export type JobProgressEvent = { id: string; library_id: string; task_count: number; completed_task_count: number; phase: string; message: string; estimated_completion: string }
|
||||
|
||||
export type JobReport = { id: string; name: string; action: string | null; data: number[] | null; metadata: any | null; is_background: boolean; errors_text: string[]; created_at: string | null; started_at: string | null; completed_at: string | null; parent_id: string | null; status: JobStatus; task_count: number; completed_task_count: number; phase: string; message: string; estimated_completion: string }
|
||||
export type JobReport = { id: string; name: string; action: string | null; data: number[] | null; metadata: { [key: string]: any } | null; is_background: boolean; errors_text: string[]; created_at: string | null; started_at: string | null; completed_at: string | null; parent_id: string | null; status: JobStatus; task_count: number; completed_task_count: number; phase: string; message: string; estimated_completion: string }
|
||||
|
||||
export type JobStatus = "Queued" | "Running" | "Completed" | "Canceled" | "Failed" | "Paused" | "CompletedWithErrors"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user