Merge branch 'develop' of github.com:thecodingmachine/workadventure into main
This commit is contained in:
commit
b9e8c970f2
@ -22,6 +22,7 @@
|
|||||||
- The chat now tracks incoming and outcoming users in your conversation
|
- The chat now tracks incoming and outcoming users in your conversation
|
||||||
- The chat allows your to see the visit card of users
|
- The chat allows your to see the visit card of users
|
||||||
- You can close the chat window with the escape key
|
- You can close the chat window with the escape key
|
||||||
|
- Added a 'Enable notifications' button in the menu.
|
||||||
|
|
||||||
## Version 1.4.3 - 1.4.4 - 1.4.5
|
## Version 1.4.3 - 1.4.4 - 1.4.5
|
||||||
|
|
||||||
|
3
front/dist/resources/html/gameMenu.html
vendored
3
front/dist/resources/html/gameMenu.html
vendored
@ -48,6 +48,9 @@
|
|||||||
<section>
|
<section>
|
||||||
<button id="toggleFullscreen" class="nes-btn">Toggle fullscreen</button>
|
<button id="toggleFullscreen" class="nes-btn">Toggle fullscreen</button>
|
||||||
</section>
|
</section>
|
||||||
|
<section>
|
||||||
|
<button id="enableNotification">Enable notifications</button>
|
||||||
|
</section>
|
||||||
<section id="adminConsoleSection" hidden>
|
<section id="adminConsoleSection" hidden>
|
||||||
<button id="adminConsoleButton" class="nes-btn">Admin console</button>
|
<button id="adminConsoleButton" class="nes-btn">Admin console</button>
|
||||||
</section>
|
</section>
|
||||||
|
@ -45,8 +45,9 @@
|
|||||||
|
|
||||||
.visitCard {
|
.visitCard {
|
||||||
pointer-events: all;
|
pointer-events: all;
|
||||||
margin-left: auto;
|
position: absolute;
|
||||||
margin-right: auto;
|
left: 50%;
|
||||||
|
transform: translate(-50%, 0);
|
||||||
margin-top: 200px;
|
margin-top: 200px;
|
||||||
max-width: 80vw;
|
max-width: 80vw;
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import { sendMenuClickedEvent } from "../../Api/iframe/Ui/MenuItem";
|
|||||||
import { consoleGlobalMessageManagerVisibleStore } from "../../Stores/ConsoleGlobalMessageManagerStore";
|
import { consoleGlobalMessageManagerVisibleStore } from "../../Stores/ConsoleGlobalMessageManagerStore";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { playersStore } from "../../Stores/PlayersStore";
|
import { playersStore } from "../../Stores/PlayersStore";
|
||||||
|
import { mediaManager } from "../../WebRtc/MediaManager";
|
||||||
|
|
||||||
export const MenuSceneName = "MenuScene";
|
export const MenuSceneName = "MenuScene";
|
||||||
const gameMenuKey = "gameMenu";
|
const gameMenuKey = "gameMenu";
|
||||||
@ -98,6 +99,10 @@ export class MenuScene extends Phaser.Scene {
|
|||||||
this.menuElement.setOrigin(0);
|
this.menuElement.setOrigin(0);
|
||||||
MenuScene.revealMenusAfterInit(this.menuElement, "gameMenu");
|
MenuScene.revealMenusAfterInit(this.menuElement, "gameMenu");
|
||||||
|
|
||||||
|
if (mediaManager.hasNotification()) {
|
||||||
|
HtmlUtils.getElementByIdOrFail("enableNotification").hidden = true;
|
||||||
|
}
|
||||||
|
|
||||||
const middleX = window.innerWidth / 3 - 298;
|
const middleX = window.innerWidth / 3 - 298;
|
||||||
this.gameQualityMenuElement = this.add.dom(middleX, -400).createFromCache(gameSettingsMenuKey);
|
this.gameQualityMenuElement = this.add.dom(middleX, -400).createFromCache(gameSettingsMenuKey);
|
||||||
MenuScene.revealMenusAfterInit(this.gameQualityMenuElement, "gameQuality");
|
MenuScene.revealMenusAfterInit(this.gameQualityMenuElement, "gameQuality");
|
||||||
@ -357,6 +362,9 @@ export class MenuScene extends Phaser.Scene {
|
|||||||
case "toggleFullscreen":
|
case "toggleFullscreen":
|
||||||
this.toggleFullscreen();
|
this.toggleFullscreen();
|
||||||
break;
|
break;
|
||||||
|
case "enableNotification":
|
||||||
|
this.enableNotification();
|
||||||
|
break;
|
||||||
case "adminConsoleButton":
|
case "adminConsoleButton":
|
||||||
if (get(consoleGlobalMessageManagerVisibleStore)) {
|
if (get(consoleGlobalMessageManagerVisibleStore)) {
|
||||||
consoleGlobalMessageManagerVisibleStore.set(false);
|
consoleGlobalMessageManagerVisibleStore.set(false);
|
||||||
@ -419,4 +427,12 @@ export class MenuScene extends Phaser.Scene {
|
|||||||
public isDirty(): boolean {
|
public isDirty(): boolean {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private enableNotification() {
|
||||||
|
mediaManager.requestNotification().then(() => {
|
||||||
|
if (mediaManager.hasNotification()) {
|
||||||
|
HtmlUtils.getElementByIdOrFail("enableNotification").hidden = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { layoutManager } from "./LayoutManager";
|
import { layoutManager } from "./LayoutManager";
|
||||||
import { HtmlUtils } from "./HtmlUtils";
|
import { HtmlUtils } from "./HtmlUtils";
|
||||||
import type { UserInputManager } from "../Phaser/UserInput/UserInputManager";
|
import type { UserInputManager } from "../Phaser/UserInput/UserInputManager";
|
||||||
import { DISABLE_NOTIFICATIONS } from "../Enum/EnvironmentVariable";
|
|
||||||
import { localStreamStore } from "../Stores/MediaStore";
|
import { localStreamStore } from "../Stores/MediaStore";
|
||||||
import { screenSharingLocalStreamStore } from "../Stores/ScreenSharingStore";
|
import { screenSharingLocalStreamStore } from "../Stores/ScreenSharingStore";
|
||||||
import { helpCameraSettingsVisibleStore } from "../Stores/HelpCameraSettingsStore";
|
import { helpCameraSettingsVisibleStore } from "../Stores/HelpCameraSettingsStore";
|
||||||
@ -16,16 +15,11 @@ export class MediaManager {
|
|||||||
startScreenSharingCallBacks: Set<StartScreenSharingCallback> = new Set<StartScreenSharingCallback>();
|
startScreenSharingCallBacks: Set<StartScreenSharingCallback> = new Set<StartScreenSharingCallback>();
|
||||||
stopScreenSharingCallBacks: Set<StopScreenSharingCallback> = new Set<StopScreenSharingCallback>();
|
stopScreenSharingCallBacks: Set<StopScreenSharingCallback> = new Set<StopScreenSharingCallback>();
|
||||||
|
|
||||||
private focused: boolean = true;
|
|
||||||
|
|
||||||
private triggerCloseJistiFrame: Map<String, Function> = new Map<String, Function>();
|
private triggerCloseJistiFrame: Map<String, Function> = new Map<String, Function>();
|
||||||
|
|
||||||
private userInputManager?: UserInputManager;
|
private userInputManager?: UserInputManager;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
//Check of ask notification navigator permission
|
|
||||||
this.getNotification();
|
|
||||||
|
|
||||||
localStreamStore.subscribe((result) => {
|
localStreamStore.subscribe((result) => {
|
||||||
if (result.type === "error") {
|
if (result.type === "error") {
|
||||||
console.error(result.error);
|
console.error(result.error);
|
||||||
@ -181,49 +175,31 @@ export class MediaManager {
|
|||||||
this.userInputManager = userInputManager;
|
this.userInputManager = userInputManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getNotification() {
|
public hasNotification(): boolean {
|
||||||
//Get notification
|
return Notification.permission === "granted";
|
||||||
if (!DISABLE_NOTIFICATIONS && window.Notification && Notification.permission !== "granted") {
|
}
|
||||||
if (this.checkNotificationPromise()) {
|
|
||||||
Notification.requestPermission().catch((err) => {
|
public requestNotification() {
|
||||||
console.error(`Notification permission error`, err);
|
if (window.Notification && Notification.permission !== "granted") {
|
||||||
});
|
return Notification.requestPermission();
|
||||||
} else {
|
} else {
|
||||||
Notification.requestPermission();
|
return Promise.reject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if the browser supports the modern version of the Notification API (which is Promise based) or false
|
|
||||||
* if we are on Safari...
|
|
||||||
*
|
|
||||||
* See https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API
|
|
||||||
*/
|
|
||||||
private checkNotificationPromise(): boolean {
|
|
||||||
try {
|
|
||||||
Notification.requestPermission().then();
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public createNotification(userName: string) {
|
public createNotification(userName: string) {
|
||||||
if (this.focused) {
|
if (document.hasFocus()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (window.Notification && Notification.permission === "granted") {
|
|
||||||
const title = "WorkAdventure";
|
if (this.hasNotification()) {
|
||||||
|
const title = `${userName} wants to discuss with you`;
|
||||||
const options = {
|
const options = {
|
||||||
body: `Hi! ${userName} wants to discuss with you, don't be afraid!`,
|
|
||||||
icon: "/resources/logos/logo-WA-min.png",
|
icon: "/resources/logos/logo-WA-min.png",
|
||||||
image: "/resources/logos/logo-WA-min.png",
|
image: "/resources/logos/logo-WA-min.png",
|
||||||
badge: "/resources/logos/logo-WA-min.png",
|
badge: "/resources/logos/logo-WA-min.png",
|
||||||
};
|
};
|
||||||
new Notification(title, options);
|
new Notification(title, options);
|
||||||
//new Notification(`Hi! ${userName} wants to discuss with you, don't be afraid!`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user