Skip to content

Commit

Permalink
Set error for bot builder with music of more than 5MB
Browse files Browse the repository at this point in the history
  • Loading branch information
miku448 committed Jan 3, 2024
1 parent 2f9ed87 commit ecf17ab
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
4 changes: 2 additions & 2 deletions apps/bot-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"@babel/register": "^7.21.0",
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@types/node": "^18.14.1",
"@types/react-dom": "^18.0.9",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
"@vitejs/plugin-react": "^3.1.0",
Expand All @@ -50,7 +51,6 @@
"@types/base-64": "^1.0.0",
"@types/polycrc": "^0.1.0",
"@types/prop-types": "^15.7.5",
"@types/react": "^18.0.26",
"@types/uuid": "^9.0.1",
"axios": "^1.2.4",
"base-64": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ const MusicSelector = ({
const reader = new FileReader();
reader.onload = (e) => {
const result = e.target?.result as string;
// if size is more than 5MB, reject
if (result.length > 5 * 1024 * 1024) {
alert("File size is larger than 5MB");
return;
}

onChange(
{
name: file.name,
Expand Down
28 changes: 16 additions & 12 deletions apps/bot-builder/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
{
"compilerOptions": {
"target": "es6",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"moduleResolution": "Node",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"noImplicitAny": false,
"jsx": "react-jsx"
"jsx": "react-jsx",

/* Linting */
"strict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"include": ["src", "vite-env.d.ts"],
"references": [{ "path": "./tsconfig.node.json" }]
}
11 changes: 6 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ecf17ab

Please sign in to comment.