-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
160 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,3 @@ export const useProcessPlayerlistEvents = () => { | |
} | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,47 @@ | ||
import { UpdateDataType } from '@shared/otherTypes'; | ||
import { UpdateAvailableEventType } from '@shared/socketioTypes'; | ||
import { atom, useAtom, useSetAtom } from 'jotai'; | ||
|
||
//FIXME: this should probably be somewhere else | ||
type UpdateDataType = false | { | ||
version: string; | ||
isImportant: boolean; | ||
} | ||
|
||
|
||
/** | ||
* Atoms | ||
*/ | ||
const offlineWarningAtom = atom(false); | ||
const txUpdateDataAtom = atom<UpdateDataType>(false); | ||
const fxUpdateDataAtom = atom<UpdateDataType>(false); | ||
const fxUpdateDataAtom = atom<UpdateDataType>(window.txConsts.fxsOutdated); | ||
const txUpdateDataAtom = atom<UpdateDataType>(window.txConsts.txaOutdated); | ||
|
||
|
||
/** | ||
* Hooks | ||
*/ | ||
export default function useWarningBar() { | ||
const [offlineWarning, setOfflineWarning] = useAtom(offlineWarningAtom); | ||
const [txUpdateData, setTxUpdateData] = useAtom(txUpdateDataAtom); | ||
const [fxUpdateData, setFxUpdateData] = useAtom(fxUpdateDataAtom); | ||
const [txUpdateData, setTxUpdateData] = useAtom(txUpdateDataAtom); | ||
|
||
return { | ||
offlineWarning, setOfflineWarning, | ||
txUpdateData, setTxUpdateData, | ||
fxUpdateData, setFxUpdateData, | ||
txUpdateData, setTxUpdateData, | ||
}; | ||
} | ||
|
||
//Marks the socket as offline or online | ||
export const useSetOfflineWarning = () => { | ||
return useSetAtom(offlineWarningAtom); | ||
} | ||
|
||
export const useProcessUpdateAvailableEvent = () => { | ||
const setFxUpdateData = useSetAtom(fxUpdateDataAtom); | ||
const setTxUpdateData = useSetAtom(txUpdateDataAtom); | ||
|
||
return (event: UpdateAvailableEventType) => { | ||
setFxUpdateData(event.fxserver); | ||
setTxUpdateData(event.txadmin); | ||
|
||
//Hacky override to prevent sticky update warnings after updating | ||
//NOTE: after adding the version check on socket handshake, i'm not sure if this is still required | ||
window.txConsts.fxsOutdated = event.fxserver; | ||
window.txConsts.txaOutdated = event.txadmin; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.