@opexa/portal-components 0.0.212 → 0.0.214
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/GameLaunch/GameLaunchTrigger.js +6 -0
- package/dist/utils/constants.d.ts +2 -0
- package/dist/utils/constants.js +2 -0
- package/dist/utils/getGameImageUrl.js +6 -7
- package/dist/utils/isBetween3amAnd3pm.d.ts +1 -0
- package/dist/utils/isBetween3amAnd3pm.js +5 -0
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ import { useCreateGameSessionMutation } from '../../client/hooks/useCreateGameSe
|
|
|
6
6
|
import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
7
7
|
import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
|
|
8
8
|
import { toaster } from '../../client/utils/toaster.js';
|
|
9
|
+
import { isBetween3amAnd3pm } from '../../utils/isBetween3amAnd3pm.js';
|
|
9
10
|
export function GameLaunchTrigger(props) {
|
|
10
11
|
const sessionQuery = useSessionQuery();
|
|
11
12
|
const createGameSessionMutation = useCreateGameSessionMutation();
|
|
@@ -25,6 +26,11 @@ export function GameLaunchTrigger(props) {
|
|
|
25
26
|
: globalStore.gameLaunch.details.status === 'WAITING'
|
|
26
27
|
? 'closed'
|
|
27
28
|
: 'open', ...props, disabled: disabled, onClick: async (e) => {
|
|
29
|
+
const OFFLINE_BEFORE_3_GAMES = ['Marble Race', 'Rainbow Ball'];
|
|
30
|
+
if (OFFLINE_BEFORE_3_GAMES.includes(props.game.name) &&
|
|
31
|
+
!isBetween3amAnd3pm()) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
28
34
|
if (sessionQuery.data?.status === 'unauthenticated') {
|
|
29
35
|
globalStore.signIn.setOpen(true);
|
|
30
36
|
return props.onClick?.(e);
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { STATIC_ENDPOINT } from '../constants/index.js';
|
|
2
|
+
import { MARBLE_GAME_REFENCE, RAINBOW_BALL_REFERENCE } from './constants.js';
|
|
3
|
+
import { isBetween3amAnd3pm } from './isBetween3amAnd3pm.js';
|
|
2
4
|
const VERSION = '1';
|
|
3
5
|
export function getGameImageUrl(args) {
|
|
4
6
|
const id = args.id ?? args.reference;
|
|
5
7
|
const provider = args.provider.toLocaleLowerCase();
|
|
6
8
|
const version = args.version ?? VERSION;
|
|
7
|
-
const now = new Date();
|
|
8
|
-
const hour = now.getHours();
|
|
9
|
-
const isBetween3amAnd3pm = hour >= 15 || hour < 3;
|
|
10
9
|
const marbleGameOffline = `${STATIC_ENDPOINT}/images/${provider}/marble-game-offline.webp?_v=${version}`;
|
|
11
10
|
const marbleGameOnline = `${STATIC_ENDPOINT}/images/${provider}/marble-game.webp?_v=${version}`;
|
|
12
11
|
const rainbowBallOffline = `${STATIC_ENDPOINT}/images/${provider}/rainbow-ball-offline.webp?_v=${version}`;
|
|
13
12
|
const rainbowBallOnline = `${STATIC_ENDPOINT}/images/${provider}/rainbow-ball-online.webp?_v=${version}`;
|
|
14
13
|
switch (id) {
|
|
15
|
-
case
|
|
16
|
-
return isBetween3amAnd3pm ? marbleGameOnline : marbleGameOffline;
|
|
17
|
-
case
|
|
18
|
-
return isBetween3amAnd3pm ? rainbowBallOnline : rainbowBallOffline;
|
|
14
|
+
case MARBLE_GAME_REFENCE:
|
|
15
|
+
return isBetween3amAnd3pm() ? marbleGameOnline : marbleGameOffline;
|
|
16
|
+
case RAINBOW_BALL_REFERENCE:
|
|
17
|
+
return isBetween3amAnd3pm() ? rainbowBallOnline : rainbowBallOffline;
|
|
19
18
|
default:
|
|
20
19
|
return `${STATIC_ENDPOINT}/images/${provider}/thumbnail-${id}.webp?_v=${version}`;
|
|
21
20
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isBetween3amAnd3pm: () => boolean;
|