Merge pull request #1291 from thecodingmachine/chatTweak
FEATURE: chat tweak
This commit is contained in:
commit
d8176c2f8d
@ -30,12 +30,10 @@
|
|||||||
|
|
||||||
|
|
||||||
<aside class="chatWindow" transition:fly="{{ x: -1000, duration: 500 }}">
|
<aside class="chatWindow" transition:fly="{{ x: -1000, duration: 500 }}">
|
||||||
<section class="chatWindowTitle">
|
<i class="close-icon" on:click={closeChat}>×</i>
|
||||||
<h1>Your chat history <span class="float-right" on:click={closeChat}>×</span></h1>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
<section class="messagesList" bind:this={listDom}>
|
<section class="messagesList" bind:this={listDom}>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><p class="system-text">Here is your chat history: </p></li>
|
||||||
{#each $chatMessagesStore as message, i}
|
{#each $chatMessagesStore as message, i}
|
||||||
<li><ChatElement message={message} line={i}></ChatElement></li>
|
<li><ChatElement message={message} line={i}></ChatElement></li>
|
||||||
{/each}
|
{/each}
|
||||||
@ -47,16 +45,24 @@
|
|||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
h1 {
|
i.close-icon {
|
||||||
font-family: Lato;
|
position: absolute;
|
||||||
|
padding: 4px;
|
||||||
span.float-right {
|
right: 12px;
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
line-height: 25px;
|
line-height: 25px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
float: right;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.system-text {
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
padding:6px;
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
max-width: 100%;
|
||||||
|
background: gray;
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
aside.chatWindow {
|
aside.chatWindow {
|
||||||
@ -78,16 +84,8 @@
|
|||||||
border-bottom-right-radius: 16px;
|
border-bottom-right-radius: 16px;
|
||||||
border-top-right-radius: 16px;
|
border-top-right-radius: 16px;
|
||||||
|
|
||||||
h1 {
|
|
||||||
background-color: #5f5f5f;
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chatWindowTitle {
|
|
||||||
flex: 0 100px;
|
|
||||||
}
|
|
||||||
.messagesList {
|
.messagesList {
|
||||||
|
margin-top: 35px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
flex: auto;
|
flex: auto;
|
||||||
|
|
||||||
@ -98,7 +96,7 @@
|
|||||||
}
|
}
|
||||||
.messageForm {
|
.messageForm {
|
||||||
flex: 0 70px;
|
flex: 0 70px;
|
||||||
padding-top: 20px;
|
padding-top: 15px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
input {
|
input {
|
||||||
flex: auto;
|
flex: auto;
|
||||||
background-color: #42464d;
|
background-color: #254560;
|
||||||
color: white;
|
color: white;
|
||||||
border-bottom-left-radius: 4px;
|
border-bottom-left-radius: 4px;
|
||||||
border-top-left-radius: 4px;
|
border-top-left-radius: 4px;
|
||||||
@ -45,11 +45,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
background-color: #42464d;
|
background-color: #254560;
|
||||||
border-bottom-right-radius: 4px;
|
border-bottom-right-radius: 4px;
|
||||||
border-top-right-radius: 4px;
|
border-top-right-radius: 4px;
|
||||||
border: none;
|
border: none;
|
||||||
border-left: solid black 1px;
|
border-left: solid white 1px;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import { consoleGlobalMessageManagerVisibleStore } from "../../Stores/ConsoleGlo
|
|||||||
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";
|
import { mediaManager } from "../../WebRtc/MediaManager";
|
||||||
|
import { chatVisibilityStore } from "../../Stores/ChatStore";
|
||||||
|
|
||||||
export const MenuSceneName = "MenuScene";
|
export const MenuSceneName = "MenuScene";
|
||||||
const gameMenuKey = "gameMenu";
|
const gameMenuKey = "gameMenu";
|
||||||
@ -147,6 +148,9 @@ export class MenuScene extends Phaser.Scene {
|
|||||||
this.menuElement.on("click", this.onMenuClick.bind(this));
|
this.menuElement.on("click", this.onMenuClick.bind(this));
|
||||||
|
|
||||||
worldFullWarningStream.stream.subscribe(() => this.showWorldCapacityWarning());
|
worldFullWarningStream.stream.subscribe(() => this.showWorldCapacityWarning());
|
||||||
|
chatVisibilityStore.subscribe((v) => {
|
||||||
|
this.menuButton.setVisible(!v);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo put this method in a parent menuElement class
|
//todo put this method in a parent menuElement class
|
||||||
|
@ -96,6 +96,7 @@ function createChatMessagesStore() {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
});
|
});
|
||||||
|
chatVisibilityStore.set(true);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ import type { PlayerInterface } from "../Phaser/Game/PlayerInterface";
|
|||||||
import type { RoomConnection } from "../Connexion/RoomConnection";
|
import type { RoomConnection } from "../Connexion/RoomConnection";
|
||||||
import { getRandomColor } from "../WebRtc/ColorGenerator";
|
import { getRandomColor } from "../WebRtc/ColorGenerator";
|
||||||
|
|
||||||
|
let idCount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A store that contains the list of players currently known.
|
* A store that contains the list of players currently known.
|
||||||
*/
|
*/
|
||||||
@ -40,6 +42,27 @@ function createPlayersStore() {
|
|||||||
getPlayerById(userId: number): PlayerInterface | undefined {
|
getPlayerById(userId: number): PlayerInterface | undefined {
|
||||||
return players.get(userId);
|
return players.get(userId);
|
||||||
},
|
},
|
||||||
|
addFacticePlayer(name: string): number {
|
||||||
|
let userId: number | null = null;
|
||||||
|
players.forEach((p) => {
|
||||||
|
if (p.name === name) userId = p.userId;
|
||||||
|
});
|
||||||
|
if (userId) return userId;
|
||||||
|
const newUserId = idCount--;
|
||||||
|
update((users) => {
|
||||||
|
users.set(newUserId, {
|
||||||
|
userId: newUserId,
|
||||||
|
name,
|
||||||
|
characterLayers: [],
|
||||||
|
visitCardUrl: null,
|
||||||
|
companion: null,
|
||||||
|
userUuid: "dummy",
|
||||||
|
color: getRandomColor(),
|
||||||
|
});
|
||||||
|
return users;
|
||||||
|
});
|
||||||
|
return newUserId;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { iframeListener } from "../Api/IframeListener";
|
import { iframeListener } from "../Api/IframeListener";
|
||||||
import { chatMessagesStore, chatVisibilityStore } from "../Stores/ChatStore";
|
import { chatMessagesStore } from "../Stores/ChatStore";
|
||||||
|
import { playersStore } from "../Stores/PlayersStore";
|
||||||
|
|
||||||
export class DiscussionManager {
|
export class DiscussionManager {
|
||||||
constructor() {
|
constructor() {
|
||||||
iframeListener.chatStream.subscribe((chatEvent) => {
|
iframeListener.chatStream.subscribe((chatEvent) => {
|
||||||
chatMessagesStore.addExternalMessage(parseInt(chatEvent.author), chatEvent.message);
|
const userId = playersStore.addFacticePlayer(chatEvent.author);
|
||||||
chatVisibilityStore.set(true);
|
chatMessagesStore.addExternalMessage(userId, chatEvent.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,6 @@ export class VideoPeer extends Peer {
|
|||||||
} else if (message.type === MESSAGE_TYPE_MESSAGE) {
|
} else if (message.type === MESSAGE_TYPE_MESSAGE) {
|
||||||
if (!blackListManager.isBlackListed(this.userUuid)) {
|
if (!blackListManager.isBlackListed(this.userUuid)) {
|
||||||
chatMessagesStore.addExternalMessage(this.userId, message.message);
|
chatMessagesStore.addExternalMessage(this.userId, message.message);
|
||||||
chatVisibilityStore.set(true);
|
|
||||||
}
|
}
|
||||||
} else if (message.type === MESSAGE_TYPE_BLOCKED) {
|
} else if (message.type === MESSAGE_TYPE_BLOCKED) {
|
||||||
//FIXME when A blacklists B, the output stream from A is muted in B's js client. This is insecure since B can manipulate the code to unmute A stream.
|
//FIXME when A blacklists B, the output stream from A is muted in B's js client. This is insecure since B can manipulate the code to unmute A stream.
|
||||||
|
@ -188,7 +188,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="radio" name="test-cowebsite-allowAPI"> Success <input type="radio" name="test-cowebsite-allowAPI"> Failure <input type="radio" name="test-cowebsite-allowAPI" checked> Pending
|
<input type="radio" name="test-cowebsite-allowAPI2"> Success <input type="radio" name="test-cowebsite-allowAPI2"> Failure <input type="radio" name="test-cowebsite-allowAPI2" checked> Pending
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#" class="testLink" data-testmap="Metadata/cowebsiteAllowApi.json" target="_blank">Test cowebsite opened by script is allowed to use IFrame API</a>
|
<a href="#" class="testLink" data-testmap="Metadata/cowebsiteAllowApi.json" target="_blank">Test cowebsite opened by script is allowed to use IFrame API</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user