Skip to content

Commit

Permalink
Merge branch 'develop' into icons-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Nov 28, 2023
2 parents 47ca777 + c4231ef commit f05111c
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 51 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"@rm/types": "*",
"@sentry/vite-plugin": "2.2.1",
"@types/dlv": "^1.1.2",
"@types/node": "^18",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.0.9",
"@vitejs/plugin-react": "4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion server/src/models/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Session extends Model {
.select('session_id')
.whereRaw(`json_extract(data, '$.passport.user.id') = ${userId}`)
.andWhere('expires', '>=', ts)
return results.length < config.getSafe('api.maxSessions')
return results.length <= config.getSafe('api.maxSessions')
} catch (e) {
log.error(HELPERS.session, 'Unable to validate session', e)
return false
Expand Down
17 changes: 1 addition & 16 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ import { ApolloProvider } from '@apollo/client'

import useCustomTheme from '@assets/mui/theme'
import { globalStyles } from '@assets/mui/global'
import { useStatic, useStore } from '@hooks/useStore'
import { apolloClient } from '@services/apollo'
import { isLocalStorageEnabled } from '@services/functions/isLocalStorageEnabled'
import { setLoadingText } from '@services/functions/setLoadingText'
import '@services/events'

import ErrorBoundary from './ErrorBoundary'
import ReactRouter from './ReactRouter'
import HolidayEffects from './HolidayEffects'

/**
* @type {Record<string, string>}
*/
Expand Down Expand Up @@ -47,20 +46,6 @@ function SetText() {
return <div />
}

/** @param {KeyboardEvent} event */
function toggleDarkMode(event) {
// This is mostly meant for development purposes
if (event.ctrlKey && event.key === 'd') {
useStore.setState((prev) => ({ darkMode: !prev.darkMode }))
}
}

window.addEventListener('keydown', toggleDarkMode)

window.addEventListener('online', () => useStatic.setState({ online: true }))

window.addEventListener('offline', () => useStatic.setState({ online: false }))

export default function App() {
const theme = useCustomTheme()

Expand Down
2 changes: 0 additions & 2 deletions src/components/Effects.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import useMediaQuery from '@mui/material/useMediaQuery'

import useGenerate from '@hooks/useGenerate'
import useRefresh from '@hooks/useRefresh'
import { useWindowState } from '@hooks/useWindowState'
import { useStatic } from '@hooks/useStore'
import { useParams } from 'react-router-dom'
import { useMap } from 'react-leaflet'
Expand All @@ -16,7 +15,6 @@ export function Effects() {

useRefresh()
useGenerate()
useWindowState()

const isMobile = useMediaQuery((theme) => theme.breakpoints.only('xs'))
const isTablet = useMediaQuery((theme) => theme.breakpoints.only('sm'))
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useRefresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default function useRefresh() {

const { data, stopPolling, startPolling, refetch } = useQuery(getAvailable, {
fetchPolicy: active && online ? 'network-only' : 'cache-only',
pollInterval: 1000 * 60 * 60,
})

useEffect(() => {
Expand Down
31 changes: 0 additions & 31 deletions src/hooks/useWindowState.js

This file was deleted.

38 changes: 38 additions & 0 deletions src/services/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// @ts-check
import { useStatic, useStore } from '@hooks/useStore'

/** @param {KeyboardEvent} event */
function toggleDarkMode(event) {
// This is mostly meant for development purposes
if (event.ctrlKey && event.key === 'd') {
useStore.setState((prev) => ({ darkMode: !prev.darkMode }))
}
}
window.addEventListener('keydown', toggleDarkMode)

let timer

function onFocus() {
if (timer) {
clearTimeout(timer)
}
useStatic.setState({ active: true })
}
window.addEventListener('focus', onFocus)

function onBlur() {
timer = setTimeout(() => {
useStatic.setState({ active: false })
}, 1000 * 60 * useStatic.getState().config.misc.clientTimeoutMinutes)
}
window.addEventListener('blur', onBlur)

function online() {
useStatic.setState({ online: true })
}
window.addEventListener('online', online)

function offline() {
useStatic.setState({ online: false })
}
window.addEventListener('offline', offline)
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,13 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.38.tgz#f8bb07c371ccb1903f3752872c89f44006132947"
integrity sha512-5jY9RhV7c0Z4Jy09G+NIDTsCZ5G0L5n+Z+p+Y7t5VJHM30bgwzSjVtlcBxqAj+6L/swIlvtOSzr8rBk/aNyV2g==

"@types/node@^18":
version "18.18.13"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.18.13.tgz#ae0f76c0bfe79d8fad0f910b78ae3e59b333c6e8"
integrity sha512-vXYZGRrSCreZmq1rEjMRLXJhiy8MrIeVasx+PCVlP414N7CJLHnMf+juVvjdprHyH+XRy3zKZLHeNueOpJCn0g==
dependencies:
undici-types "~5.26.4"

"@types/node@^20.5.1":
version "20.5.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.5.1.tgz#178d58ee7e4834152b0e8b4d30cbfab578b9bb30"
Expand Down Expand Up @@ -6068,6 +6075,11 @@ undefsafe@^2.0.5:
resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c"
integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==

undici-types@~5.26.4:
version "5.26.5"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

undici@^5.13.0:
version "5.26.3"
resolved "https://registry.yarnpkg.com/undici/-/undici-5.26.3.tgz#ab3527b3d5bb25b12f898dfd22165d472dd71b79"
Expand Down

0 comments on commit f05111c

Please sign in to comment.