Skip to content

Commit

Permalink
fix lint x2 + may be fix advanced json editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Kostya Bats committed Apr 13, 2024
1 parent 4b8fbad commit 26ad9e9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .run/admin-start-local.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
</envs>
<method v="2" />
</configuration>
</component>
</component>
1 change: 1 addition & 0 deletions src/frontend/admin/src/components/atoms/JsonEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PropTypes from "prop-types";
const CodeEditor = ({ schema, defaultValue, onChange }) => {
function onMount(editor, monaco) {
/* Workaround for https://github.com/suren-atoyan/monaco-react/issues/69#issuecomment-612816117 */
console.log(defaultValue);
const modelUri = "foo://admin/advanced.json";
const model = monaco.editor.createModel(
defaultValue, "json", monaco.Uri.parse(modelUri)
Expand Down
10 changes: 5 additions & 5 deletions src/frontend/common/src/utils.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const createApiPost = (apiUrl) =>
function (path, body = {}, method = "POST") {
function (path, body = {}, method = "POST", sendRaw = false) {
const requestOptions = {
method: method,
headers: { "Content-Type": "application/json" },
body: method === "GET" ? undefined : JSON.stringify(body),
headers: { "Content-Type": sendRaw ? "text/plain" : "application/json" },
body: method === "GET" ? undefined : (sendRaw ? body : JSON.stringify(body)),
};
return fetch(apiUrl + path, requestOptions)
.then(response => response.json())
Expand All @@ -15,11 +15,11 @@ export const createApiPost = (apiUrl) =>
});
};
export const createApiGet = (apiUrl) =>
function (path, body = undefined) {
function (path, body = undefined, rawText = false) {
const requestOptions = {
headers: { "Content-Type": "application/json" },
body: body !== undefined ? JSON.stringify(body) : undefined,
};
return fetch(apiUrl + path, requestOptions)
.then(response => response.json());
.then(response => rawText ? response.text() : response.json());
};
52 changes: 3 additions & 49 deletions src/frontend/overlay/src/components/organisms/tickers/Empty.tsx
Original file line number Diff line number Diff line change
@@ -1,56 +1,10 @@
import React, { useEffect, useState } from "react";
import styled from "styled-components";
import c from "../../../config";
import { SCOREBOARD_TYPES } from "@/consts";
import { useAppSelector } from "@/redux/hooks";
import { ContestantInfo } from "../../molecules/info/ContestantInfo";
import React from "react";

type ScoreboardWrapProps = {
top: string,
nrows: number
}

const ScoreboardWrap = styled.div.attrs<ScoreboardWrapProps>(({ top }) => (
{ style: { top } }
))<ScoreboardWrapProps>`
position: absolute;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(${props => props.nrows}, 1fr);
gap: 2px;
width: 100%;
height: 100%;
transition: top ${c.TICKER_SCOREBOARD_SCROLL_TRANSITION_TIME}ms ease-in-out;
/* align-items: center; */
`;

export const Scoreboard = ({ tickerSettings, state }) => {
const { from, to, periodMs } = tickerSettings;
const [row, setRow] = useState(0);
const rows = useAppSelector((state) => state.scoreboard[SCOREBOARD_TYPES.normal].rows.slice(from-1, to));
const nrows = Math.ceil(rows.length / 4);
useEffect(() => {
if(state !== "entering" && rows.length > 0) {
const interval = setInterval(() => {
if (state !== "exiting") {
setRow((row) => {
return (row + 1) % nrows;
});
}
}, (periodMs - c.TICKER_SCROLL_TRANSITION_TIME) / nrows / c.TICKER_SCOREBOARD_REPEATS + 1);
return () => clearInterval(interval);
}
}, [nrows, periodMs, state, rows.length]);

// This fugliness is needed to scroll the scoreboard
export const Empty = () => {
return (
<></>
);
};

export default Scoreboard;
export default Empty;

0 comments on commit 26ad9e9

Please sign in to comment.