1
0
mirror of https://github.com/barthuijgen/factorio-sites.git synced 2024-11-21 18:16:33 +02:00

Merge pull request #374 from barthuijgen/develop

fix: user search, edit blueprint without new string
This commit is contained in:
Bart 2022-11-27 12:07:38 +01:00 committed by GitHub
commit ad7ba8ce21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 22 deletions

View File

@ -41,17 +41,21 @@ export const ImageEditor: React.FC<ImageEditorProps> = ({ string, onError }) =>
// Load editor async, it does not work server side
useEffect(() => {
(async () => {
const FBE = await import("@fbe/editor");
const editor = new FBE.Editor();
const canvas = canvasRef.current;
if (!canvas) return;
await editor.init(canvas, PUBLIC_URL);
canvas.style.width = "100%";
canvas.style.height = "auto";
editor.setRendererSize(canvas.offsetWidth, canvas.offsetHeight);
FbeRef.current = FBE;
editorRef.current = editor;
setEditorLoaded(true);
try {
const FBE = await import("@fbe/editor");
const editor = new FBE.Editor();
const canvas = canvasRef.current;
if (!canvas) return;
await editor.init(canvas, PUBLIC_URL);
canvas.style.width = "100%";
canvas.style.height = "auto";
editor.setRendererSize(canvas.offsetWidth, canvas.offsetHeight);
FbeRef.current = FBE;
editorRef.current = editor;
setEditorLoaded(true);
} catch (error) {
console.log("Failed to init editor", error);
}
})();
const resizeFn = () => {

View File

@ -81,14 +81,14 @@ export const validateUserForm = (auth: AuthContextProps) => (values: UserFormVal
return filterUndefined(errors);
};
export const joinValidations = <T>(...validations: Array<(value: T) => string | undefined>) => (
value: T
): string | undefined => {
for (let i = 0; i < validations.length; i++) {
const error = validations[i](value);
if (error) return error;
}
};
export const joinValidations =
<T>(...validations: Array<(value: T) => string | undefined>) =>
(value: T): string | undefined => {
for (let i = 0; i < validations.length; i++) {
const error = validations[i](value);
if (error) return error;
}
};
export const validateBlueprintString = (value: string) => {
if (value) {
@ -102,7 +102,5 @@ export const validateBlueprintString = (value: string) => {
if (!parsed.blueprint && !parsed.blueprint_book) {
return "Must have a blueprint or blueprint book";
}
} else {
return "Not recognised as a blueprint string";
}
};

View File

@ -130,7 +130,7 @@ export async function searchBlueprintPages({
conditionals.push(sqltag`blueprint_page.tags ${matchSql} array[${join(tags)}::varchar]`);
}
if (user) {
conditionals.push(sqltag`blueprint_page.user_id = ${user}`);
conditionals.push(sqltag`blueprint_page.user_id = ${user}::uuid`);
}
if (absolute_snapping) {
conditionals.push(sqltag`(blueprint.data -> 'absolute_snapping')::boolean = true`);