Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: motd index setter #906

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ public/missing-locales
public/images/custom
public/images/uicons
server/src/configs/
packages/types/**/*.d.ts
8 changes: 4 additions & 4 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"check": "node ./lib/scripts/configCheck.js",
"sort": "npx sort-package-json",
"depCheck": "npx depcheck",
"eslint:check": "eslint \"**/*.{js,jsx}\"",
"eslint:fix": "eslint \"**/*.{js,jsx}\" --fix",
"prettier:check": "prettier --check \"**/*.{css,html,js,jsx,yml}\"",
"lint": "eslint \"**/*.{js,jsx}\"",
"lint:fix": "eslint \"**/*.{js,jsx}\" --fix",
"prettier": "prettier --check \"**/*.{css,html,js,jsx,yml}\"",
"prettier:fix": "prettier --write \"**/*.{css,html,js,jsx,yml}\""
},
"dependencies": {
"config": "^3.3.9"
}
}
}
8 changes: 4 additions & 4 deletions packages/locales/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"missing": "node ./lib/missing.js",
"sort": "npx sort-package-json",
"depCheck": "npx depcheck",
"eslint:check": "eslint \"**/*.{js,jsx}\"",
"eslint:fix": "eslint \"**/*.{js,jsx}\" --fix",
"prettier:check": "prettier --check \"**/*.{css,html,js,jsx,yml}\"",
"lint": "eslint \"**/*.{js,jsx}\"",
"lint:fix": "eslint \"**/*.{js,jsx}\" --fix",
"prettier": "prettier --check \"**/*.{css,html,js,jsx,yml}\"",
"prettier:fix": "prettier --write \"**/*.{css,html,js,jsx,yml}\""
},
"dependencies": {
Expand All @@ -20,4 +20,4 @@
"dotenv": "^16.3.1",
"openai": "^4.24.1"
}
}
}
8 changes: 4 additions & 4 deletions packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"scripts": {
"sort": "npx sort-package-json",
"depCheck": "npx depcheck",
"eslint:check": "eslint \"**/*.{js,jsx}\"",
"eslint:fix": "eslint \"**/*.{js,jsx}\" --fix",
"prettier:check": "prettier --check \"**/*.{css,html,js,jsx,yml}\"",
"lint": "eslint \"**/*.{js,jsx}\"",
"lint:fix": "eslint \"**/*.{js,jsx}\" --fix",
"prettier": "prettier --check \"**/*.{css,html,js,jsx,yml}\"",
"prettier:fix": "prettier --write \"**/*.{css,html,js,jsx,yml}\""
},
"dependencies": {
"@rm/config": "*",
"chalk": "^4",
"loglevel": "^1.8.1"
}
}
}
8 changes: 4 additions & 4 deletions packages/masterfile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"generate": "node ./lib",
"sort": "npx sort-package-json",
"depCheck": "npx depcheck",
"eslint:check": "eslint \"**/*.{js,jsx}\"",
"eslint:fix": "eslint \"**/*.{js,jsx}\" --fix",
"prettier:check": "prettier --check \"**/*.{css,html,js,jsx,yml}\"",
"lint": "eslint \"**/*.{js,jsx}\"",
"lint:fix": "eslint \"**/*.{js,jsx}\" --fix",
"prettier": "prettier --check \"**/*.{css,html,js,jsx,yml}\"",
"prettier:fix": "prettier --write \"**/*.{css,html,js,jsx,yml}\""
},
"dependencies": {
"@rm/config": "*",
"@rm/logger": "*",
"@rm/types": "*"
}
}
}
7 changes: 5 additions & 2 deletions packages/types/lib/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import config = require('server/src/configs/default.json')
import example = require('server/src/configs/local.example.json')

import type { Schema } from './server'
import type { DialogProps } from '@mui/material'

type BaseConfig = typeof config
type ExampleConfig = typeof example
Expand Down Expand Up @@ -74,13 +75,14 @@ export interface Config<Client extends boolean = false>
messageOfTheDay: {
settings: {
parentStyle: Record<string, string> // should be CSS properties but performance seems to die
} & BaseConfig['map']['messageOfTheDay']['settings']
} & Omit<BaseConfig['map']['messageOfTheDay']['settings'], 'parentStyle'>
titles: string[]
components: CustomComponent[]
footerButtons: CustomComponent[]
dialogMaxWidth: DialogProps['maxWidth']
} & Omit<
BaseConfig['map']['messageOfTheDay'],
'settings' | 'titles' | 'components' | 'footerButtons'
'settings' | 'titles' | 'components' | 'footerButtons' | 'dialogMaxWidth'
>
donationPage: {
settings: {
Expand Down Expand Up @@ -145,6 +147,7 @@ export interface Webhook {
}

export interface CustomComponent {
type?: string
components?: CustomComponent[]
donorOnly?: boolean
freeloaderOnly?: boolean
Expand Down
9 changes: 5 additions & 4 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
"scripts": {
"sort": "npx sort-package-json",
"depCheck": "npx depcheck",
"eslint:check": "eslint \"**/*.{js,jsx}\"",
"eslint:fix": "eslint \"**/*.{js,jsx}\" --fix",
"prettier:check": "prettier --check \"**/*.{css,html,js,jsx,yml}\"",
"lint": "eslint \"**/*.{js,jsx}\"",
"lint:fix": "eslint \"**/*.{js,jsx}\" --fix",
"prettier": "prettier --check \"**/*.{css,html,js,jsx,yml}\"",
"prettier:fix": "prettier --write \"**/*.{css,html,js,jsx,yml}\""
},
"devDependencies": {
"@apollo/client": "^3.7.15",
"@mui/material": "^5.14.0",
"@sentry/node": "^7.48.0",
"@types/config": "^3.3.0",
"@types/node": "^20.5.1",
Expand All @@ -26,4 +27,4 @@
"passport-discord": "https://github.com/tonestrike/passport-discord.git",
"passport-oauth2": "^1.7.0"
}
}
}
16 changes: 9 additions & 7 deletions src/components/layout/dialogs/Motd.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import DialogWrapper from '../custom/DialogWrapper'
import CustomTile from '../custom/CustomTile'
import { Loading } from '../general/Loading'

const DEFAULT = {
settings: {},
components: [],
titles: [],
footerButtons: [],
}
const DEFAULT =
/** @type {import('@rm/types').Config['map']['messageOfTheDay']} */ ({
settings: {},
components: [],
titles: [],
footerButtons: [],
index: 0,
})

export default function MessageOfTheDay() {
const clientIndex = useStore((s) => s.motdIndex)
Expand All @@ -42,7 +44,7 @@ export default function MessageOfTheDay() {

const handleMotdClose = React.useCallback(() => {
if (motd.settings.permanent === false) {
useStore.setState({ motdIndex: motd.settings.index })
useStore.setState({ motdIndex: motd.index })
}
useLayoutStore.setState({ motd: false })
}, [motd])
Expand Down