Skip to content

Commit

Permalink
fix: build errors and trusted_workers setting (#64)
Browse files Browse the repository at this point in the history
* chore: fix lint issues

* fix merge conflict

* fix merge conflict

* fix merge conflict

* fix merge conflict
  • Loading branch information
daveschumaker authored Jan 31, 2025
1 parent a1a6c77 commit eab5229
Show file tree
Hide file tree
Showing 44 changed files with 888 additions and 866 deletions.
9 changes: 8 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
"project": "./tsconfig.json"
},
"rules": {
"@typescript-eslint/no-unused-vars": ["warn"]
"@typescript-eslint/no-unused-vars": ["warn"],
"prefer-const": [
"warn",
{
"destructuring": "all",
"ignoreReadBeforeAssign": false
}
]
}
}
6 changes: 6 additions & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/sh

# If in a rebase, skip this hook
if [ -d "$(git rev-parse --git-path rebase-merge)" ] || [ -d "$(git rev-parse --git-path rebase-apply)" ]; then
echo "Rebase in progress — skipping post-commit hook."
exit 0
fi

# If this is a recursive call, exit
if [ -n "$HUSKY_SKIP_BUILDID" ]; then
exit 0
Expand Down
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
cd "$(git rev-parse --show-toplevel)"

npx lint-staged
npx eslint . --ext .ts,.tsx
npm test
86 changes: 43 additions & 43 deletions app/(content)/create/json/_component/JsonInput.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import clsx from 'clsx'
import React, { useCallback, useRef, useEffect, useState } from 'react'
import ReactTextareaAutosize from 'react-textarea-autosize'
import dJSON from 'dirty-json'
import clsx from 'clsx';
import { useCallback, useRef, useEffect, useState } from 'react';
import ReactTextareaAutosize from 'react-textarea-autosize';
import dJSON from 'dirty-json';

interface JsonInputProps {
value: string
onChange: (value: string) => void
onValidate: (isValid: boolean, error: string | null) => void
error: string | null
onBlur?: (value: string) => string
value: string;
onChange: (value: string) => void;
onValidate: (isValid: boolean, error: string | null) => void;
error: string | null;
onBlur?: (value: string) => string;
}

const JsonInput: React.FC<JsonInputProps> = ({
Expand All @@ -18,76 +18,76 @@ const JsonInput: React.FC<JsonInputProps> = ({
error,
onBlur
}) => {
const [lineNumbers, setLineNumbers] = useState<string[]>([])
const textareaRef = useRef<HTMLTextAreaElement>(null)
const lineNumbersRef = useRef<HTMLDivElement>(null)
const [lineNumbers, setLineNumbers] = useState<string[]>([]);
const textareaRef = useRef<HTMLTextAreaElement>(null);
const lineNumbersRef = useRef<HTMLDivElement>(null);

const formatJson = useCallback((json: string): string => {
try {
return JSON.stringify(dJSON.parse(json), null, 2)
return JSON.stringify(dJSON.parse(json), null, 2);
} catch {
return json
return json;
}
}, [])
}, []);

const validateJson = useCallback(
(json: string): void => {
try {
JSON.parse(json)
onValidate(true, null)
JSON.parse(json);
onValidate(true, null);
} catch (e) {
const errorMessage = e instanceof Error ? e.message : 'Invalid JSON'
onValidate(false, errorMessage)
const errorMessage = e instanceof Error ? e.message : 'Invalid JSON';
onValidate(false, errorMessage);
}
},
[onValidate]
)
);

const handleBlur = useCallback(() => {
let formattedJson = formatJson(value)
let formattedJson = formatJson(value);
if (onBlur) {
formattedJson = onBlur(formattedJson)
formattedJson = onBlur(formattedJson);
}
onChange(formattedJson)
validateJson(formattedJson)
}, [value, formatJson, validateJson, onChange, onBlur])
onChange(formattedJson);
validateJson(formattedJson);
}, [value, formatJson, validateJson, onChange, onBlur]);

const handleChange = useCallback(
(e: React.ChangeEvent<HTMLTextAreaElement>) => {
onChange(e.target.value)
onChange(e.target.value);
},
[onChange]
)
);

useEffect(() => {
const updateLineNumbers = () => {
if (textareaRef.current) {
const lineHeight = parseInt(
window.getComputedStyle(textareaRef.current).lineHeight
)
);
const visibleLines = Math.floor(
textareaRef.current.clientHeight / lineHeight
)
const totalLines = value.split('\n').length
);
const totalLines = value.split('\n').length;
const numbers = Array.from(
{ length: Math.min(visibleLines, totalLines) },
(_, i) => `${i + 1}`
)
setLineNumbers(numbers)
);
setLineNumbers(numbers);
}
}
updateLineNumbers()
window.addEventListener('resize', updateLineNumbers)
return () => window.removeEventListener('resize', updateLineNumbers)
}, [value])
};
updateLineNumbers();
window.addEventListener('resize', updateLineNumbers);
return () => window.removeEventListener('resize', updateLineNumbers);
}, [value]);

const syncScroll = () => {
if (textareaRef.current && lineNumbersRef.current) {
lineNumbersRef.current.scrollTop = textareaRef.current.scrollTop
lineNumbersRef.current.scrollTop = textareaRef.current.scrollTop;
}
}
};

const errorLineNumber = error?.match(/line (\d+)/)?.[1] ?? null
const errorLineNumber = error?.match(/line (\d+)/)?.[1] ?? null;

return (
<div className="col">
Expand Down Expand Up @@ -138,7 +138,7 @@ const JsonInput: React.FC<JsonInputProps> = ({
</div>
)}
</div>
)
}
);
};

export default JsonInput
export default JsonInput;
47 changes: 23 additions & 24 deletions app/(content)/faq/_component/FAQ_Kudos.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use client'
import Link from 'next/link'
import React from 'react'
'use client';
import Link from 'next/link';
// import { IconLink } from '@tabler/icons-react'
import Linker from '@/app/_components/Linker'
import Linker from '@/app/_components/Linker';

// const showToast = () => {
// showSuccessToast({ message: 'FAQ URL copied!' })
Expand All @@ -13,16 +12,16 @@ const MonoFont = ({ children }: { children: React.ReactNode }) => {
<div className="mt-2 font-mono py-[4px] px-[4px] bg-[#878787] text-sm">
{children}
</div>
)
}
);
};

const Question = ({ children }: { children: React.ReactNode }) => {
return (
<div className="flex flex-row justify-start items-start gap-[8px] mb-[8px] text-[20px] font-[700]">
{children}
</div>
)
}
);
};

export const FaqKudos = () => {
return (
Expand Down Expand Up @@ -87,8 +86,8 @@ export const FaqKudos = () => {
</p>
</div>
</div>
)
}
);
};

export const FaqSyntax = () => {
return (
Expand Down Expand Up @@ -139,8 +138,8 @@ export const FaqSyntax = () => {
</p>
</div>
</div>
)
}
);
};

export const FaqEstimatedTime = () => {
return (
Expand All @@ -167,8 +166,8 @@ export const FaqEstimatedTime = () => {
if a valid registered user creates an image request.
</div>
</div>
)
}
);
};

export const FaqApiKey = () => {
return (
Expand Down Expand Up @@ -210,8 +209,8 @@ export const FaqApiKey = () => {
</p>
</div>
</div>
)
}
);
};

export const FaqRunWorker = () => {
return (
Expand Down Expand Up @@ -272,8 +271,8 @@ export const FaqRunWorker = () => {
</p>
</div>
</div>
)
}
);
};

export const FaqMissingRequests = () => {
return (
Expand All @@ -298,8 +297,8 @@ export const FaqMissingRequests = () => {
older than 20 minutes, it may disappear.
</div>
</div>
)
}
);
};

export const FaqBlackImage = () => {
return (
Expand Down Expand Up @@ -328,8 +327,8 @@ export const FaqBlackImage = () => {
.
</div>
</div>
)
}
);
};

export const FaqStorageExceeded = () => {
return (
Expand Down Expand Up @@ -400,5 +399,5 @@ export const FaqStorageExceeded = () => {
</p>
</div>
</div>
)
}
);
};
5 changes: 1 addition & 4 deletions app/(content)/user/messages/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use client';

import PageTitle from '@/app/_components/PageTitle';
import { AppConstants } from '@/app/_data-models/AppConstants';
import { AppSettings } from '@/app/_data-models/AppSettings';
import { getReadMessagesIdsFromDexie } from '@/app/_db/appSettings';
import { UserStore } from '@/app/_stores/UserStore';
import { HordeUser } from '@/app/_types/HordeTypes';
import { useEffect, useState } from 'react';
import { useStore } from 'statery';

Expand All @@ -21,8 +19,7 @@ import { useStore } from 'statery';
// }

export default function UserMessagesPage() {
const { hordeMessages, userDetails = {} as HordeUser } = useStore(UserStore);
const { worker_count } = userDetails;
const { hordeMessages } = useStore(UserStore);
const [loading, setLoading] = useState(true);
const [readMessages, setReadMessages] = useState<string[]>([]);

Expand Down
Loading

0 comments on commit eab5229

Please sign in to comment.