Merge pull request #1703 from thecodingmachine/2daysLimit_stupid_front
2 days limit improvements
This commit is contained in:
commit
d24e074fbf
@ -6,12 +6,11 @@
|
|||||||
import type { Unsubscriber } from "svelte/store";
|
import type { Unsubscriber } from "svelte/store";
|
||||||
import { playersStore } from "../../Stores/PlayersStore";
|
import { playersStore } from "../../Stores/PlayersStore";
|
||||||
import { connectionManager } from "../../Connexion/ConnectionManager";
|
import { connectionManager } from "../../Connexion/ConnectionManager";
|
||||||
import { GameConnexionTypes } from "../../Url/UrlManager";
|
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
|
|
||||||
let blockActive = true;
|
let blockActive = true;
|
||||||
let reportActive = !blockActive;
|
let reportActive = !blockActive;
|
||||||
let anonymous: boolean = false;
|
let disableReport: boolean = false;
|
||||||
let userUUID: string | undefined = playersStore.getPlayerById(get(showReportScreenStore).userId)?.userUuid;
|
let userUUID: string | undefined = playersStore.getPlayerById(get(showReportScreenStore).userId)?.userUuid;
|
||||||
let userName = "No name";
|
let userName = "No name";
|
||||||
let unsubscriber: Unsubscriber;
|
let unsubscriber: Unsubscriber;
|
||||||
@ -26,7 +25,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
anonymous = connectionManager.getConnexionType === GameConnexionTypes.anonymous;
|
disableReport = !connectionManager.currentRoom?.canReport ?? true;
|
||||||
});
|
});
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
@ -65,7 +64,7 @@
|
|||||||
<button type="button" class="nes-btn" on:click|preventDefault={close}>X</button>
|
<button type="button" class="nes-btn" on:click|preventDefault={close}>X</button>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
<section class="report-menu-action {anonymous ? 'hidden' : ''}">
|
<section class="report-menu-action {disableReport ? 'hidden' : ''}">
|
||||||
<section class="justify-center">
|
<section class="justify-center">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
@ -154,12 +154,7 @@ class ConnectionManager {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
urlManager.pushRoomIdToUrl(this._currentRoom);
|
urlManager.pushRoomIdToUrl(this._currentRoom);
|
||||||
} else if (
|
} else if (connexionType === GameConnexionTypes.room || connexionType === GameConnexionTypes.empty) {
|
||||||
connexionType === GameConnexionTypes.organization ||
|
|
||||||
connexionType === GameConnexionTypes.anonymous ||
|
|
||||||
connexionType === GameConnexionTypes.limit ||
|
|
||||||
connexionType === GameConnexionTypes.empty
|
|
||||||
) {
|
|
||||||
this.authToken = localUserStore.getAuthToken();
|
this.authToken = localUserStore.getAuthToken();
|
||||||
|
|
||||||
let roomPath: string;
|
let roomPath: string;
|
||||||
@ -241,12 +236,12 @@ class ConnectionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//if limit room active test headband
|
//if limit room active test headband
|
||||||
if (connexionType === GameConnexionTypes.limit) {
|
if (this._currentRoom.expireOn !== undefined) {
|
||||||
warningContainerStore.activateWarningContainer();
|
warningContainerStore.activateWarningContainer();
|
||||||
limitMapStore.set(true);
|
limitMapStore.set(true);
|
||||||
|
|
||||||
//check time of map
|
//check time of map
|
||||||
if (!urlManager.isActiveLimitRoom) {
|
if (new Date() > this._currentRoom.expireOn) {
|
||||||
showLimitRoomModalStore.set(true);
|
showLimitRoomModalStore.set(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,10 @@ export interface RoomRedirect {
|
|||||||
|
|
||||||
export class Room {
|
export class Room {
|
||||||
public readonly id: string;
|
public readonly id: string;
|
||||||
public readonly isPublic: boolean;
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
private readonly isPublic: boolean;
|
||||||
private _authenticationMandatory: boolean = DISABLE_ANONYMOUS;
|
private _authenticationMandatory: boolean = DISABLE_ANONYMOUS;
|
||||||
private _iframeAuthentication?: string = OPID_LOGIN_SCREEN_PROVIDER;
|
private _iframeAuthentication?: string = OPID_LOGIN_SCREEN_PROVIDER;
|
||||||
private _mapUrl: string | undefined;
|
private _mapUrl: string | undefined;
|
||||||
@ -27,6 +30,8 @@ export class Room {
|
|||||||
private readonly _search: URLSearchParams;
|
private readonly _search: URLSearchParams;
|
||||||
private _contactPage: string | undefined;
|
private _contactPage: string | undefined;
|
||||||
private _group: string | null = null;
|
private _group: string | null = null;
|
||||||
|
private _expireOn: Date | undefined;
|
||||||
|
private _canReport: boolean = false;
|
||||||
|
|
||||||
private constructor(private roomUrl: URL) {
|
private constructor(private roomUrl: URL) {
|
||||||
this.id = roomUrl.pathname;
|
this.id = roomUrl.pathname;
|
||||||
@ -121,6 +126,10 @@ export class Room {
|
|||||||
data.authenticationMandatory != null ? data.authenticationMandatory : DISABLE_ANONYMOUS;
|
data.authenticationMandatory != null ? data.authenticationMandatory : DISABLE_ANONYMOUS;
|
||||||
this._iframeAuthentication = data.iframeAuthentication || OPID_LOGIN_SCREEN_PROVIDER;
|
this._iframeAuthentication = data.iframeAuthentication || OPID_LOGIN_SCREEN_PROVIDER;
|
||||||
this._contactPage = data.contactPage || CONTACT_URL;
|
this._contactPage = data.contactPage || CONTACT_URL;
|
||||||
|
if (data.expireOn) {
|
||||||
|
this._expireOn = new Date(data.expireOn);
|
||||||
|
}
|
||||||
|
this._canReport = data.canReport ?? false;
|
||||||
return new MapDetail(data.mapUrl, data.textures);
|
return new MapDetail(data.mapUrl, data.textures);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Data received by the /map endpoint of the Pusher is not in a valid format.");
|
throw new Error("Data received by the /map endpoint of the Pusher is not in a valid format.");
|
||||||
@ -143,6 +152,8 @@ export class Room {
|
|||||||
* Instance name is:
|
* Instance name is:
|
||||||
* - In a public URL: the second part of the URL ( _/[instance]/map.json)
|
* - In a public URL: the second part of the URL ( _/[instance]/map.json)
|
||||||
* - In a private URL: [organizationId/worldId]
|
* - In a private URL: [organizationId/worldId]
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public getInstance(): string {
|
public getInstance(): string {
|
||||||
if (this.instance !== undefined) {
|
if (this.instance !== undefined) {
|
||||||
@ -222,4 +233,12 @@ export class Room {
|
|||||||
get group(): string | null {
|
get group(): string | null {
|
||||||
return this._group;
|
return this._group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get expireOn(): Date | undefined {
|
||||||
|
return this._expireOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
get canReport(): boolean {
|
||||||
|
return this._canReport;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,12 @@ import type { Room } from "../Connexion/Room";
|
|||||||
import { localUserStore } from "../Connexion/LocalUserStore";
|
import { localUserStore } from "../Connexion/LocalUserStore";
|
||||||
|
|
||||||
export enum GameConnexionTypes {
|
export enum GameConnexionTypes {
|
||||||
anonymous = 1,
|
room = 1,
|
||||||
organization,
|
|
||||||
register,
|
register,
|
||||||
empty,
|
empty,
|
||||||
unknown,
|
unknown,
|
||||||
jwt,
|
jwt,
|
||||||
login,
|
login,
|
||||||
limit,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//this class is responsible with analysing and editing the game's url
|
//this class is responsible with analysing and editing the game's url
|
||||||
@ -20,12 +18,8 @@ class UrlManager {
|
|||||||
return GameConnexionTypes.login;
|
return GameConnexionTypes.login;
|
||||||
} else if (url === "/jwt") {
|
} else if (url === "/jwt") {
|
||||||
return GameConnexionTypes.jwt;
|
return GameConnexionTypes.jwt;
|
||||||
} else if (url.includes("*/")) {
|
} else if (url.includes("_/") || url.includes("*/") || url.includes("@/")) {
|
||||||
return GameConnexionTypes.limit;
|
return GameConnexionTypes.room;
|
||||||
} else if (url.includes("_/")) {
|
|
||||||
return GameConnexionTypes.anonymous;
|
|
||||||
} else if (url.includes("@/")) {
|
|
||||||
return GameConnexionTypes.organization;
|
|
||||||
} else if (url.includes("register/")) {
|
} else if (url.includes("register/")) {
|
||||||
return GameConnexionTypes.register;
|
return GameConnexionTypes.register;
|
||||||
} else if (url === "/") {
|
} else if (url === "/") {
|
||||||
@ -58,15 +52,6 @@ class UrlManager {
|
|||||||
pushStartLayerNameToUrl(startLayerName: string): void {
|
pushStartLayerNameToUrl(startLayerName: string): void {
|
||||||
window.location.hash = startLayerName;
|
window.location.hash = startLayerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isActiveLimitRoom(): boolean {
|
|
||||||
const match = /\*\/(\w+)\/(?:\w+)/.exec(window.location.pathname.toString());
|
|
||||||
const timestamp = match ? Number.parseInt(match[1]) : null;
|
|
||||||
if (!timestamp) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return new Date().getTime() - 48 * 60 * 60 * 1000 < timestamp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const urlManager = new UrlManager();
|
export const urlManager = new UrlManager();
|
||||||
|
@ -20,6 +20,10 @@ export const isMapDetailsData = new tg.IsInterface()
|
|||||||
})
|
})
|
||||||
.withOptionalProperties({
|
.withOptionalProperties({
|
||||||
iframeAuthentication: tg.isNullable(tg.isString),
|
iframeAuthentication: tg.isNullable(tg.isString),
|
||||||
|
// The date (in ISO 8601 format) at which the room will expire
|
||||||
|
expireOn: tg.isString,
|
||||||
|
// Whether the "report" feature is enabled or not on this room
|
||||||
|
canReport: tg.isBoolean,
|
||||||
})
|
})
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user