From fa970cba9abebfaccbec7f3df480bde313b9475e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janis=20Daniel=20Da=CC=88hne?= <janis.daehne2@student.uni-halle.de> Date: Mon, 5 Aug 2019 14:39:39 +0200 Subject: [PATCH] - added support link - tweaked 404 chat (timings) --- i18n/en.ts | 4 +- i18n/i18nRoot.ts | 4 +- src/components/404internal/Chat404.tsx | 52 +++++++++++++++++++++----- src/components/404internal/style.styl | 4 +- src/constants.ts | 2 + src/setup.ts | 19 +++++----- 6 files changed, 61 insertions(+), 24 deletions(-) diff --git a/i18n/en.ts b/i18n/en.ts index 0d7097a5..36caca5e 100644 --- a/i18n/en.ts +++ b/i18n/en.ts @@ -51,8 +51,8 @@ export const lang_en: LangObj = { "You might have some unsaved changes. Are you sure you want to logout?" : "You might have some unsaved changes. Are you sure you want to logout?", "No permission" : "No permission", "Click to clear": "Click to clear", - "Could not connect to the server (the server might be offline), probably a server maintenance is the reason" : "Could not connect to the server (the server might be offline), probably a server maintenance is the reason", - "Could not connect to the server (the server might be offline), probably a server maintenance is the reason. You can keep this tab open (e.g. if you have unsaved changes) and try it later again. Every action that requires connecting to the server will do the state check": "Could not connect to the server (the server might be offline), probably a server maintenance is the reason. You can keep this tab open (e.g. if you have unsaved changes) and try it later again. Every action that requires connecting to the server will do the state check", + "Could not connect to the server (the server might be offline), probably a server maintenance is the reason. If the problem persists, contact:" : "Could not connect to the server (the server might be offline), probably a server maintenance is the reason. If the problem persists, contact:", + "Could not connect to the server (the server might be offline), probably a server maintenance is the reason. You can keep this tab open (e.g. if you have unsaved changes) and try it later again. Every action that requires connecting to the server will do the state check. If the problem persists, contact:": "Could not connect to the server (the server might be offline), probably a server maintenance is the reason. You can keep this tab open (e.g. if you have unsaved changes) and try it later again. Every action that requires connecting to the server will do the state check. If the problem persists, contact:", "Shortcut: ctrl+0/cmd+0. Resets the quick-zoom to the zoom in the editor settings. Note that the quick-zoom is not persistent" : "Shortcut: ctrl+0/cmd+0. Resets the quick-zoom to the zoom in the editor settings. Note that the quick-zoom is not persistent", "Shortcut: ctrl++/cmd++" : "Shortcut: ctrl++/cmd++", "Shortcut: ctrl+-/cmd+-" : "Shortcut: ctrl+-/cmd+-", diff --git a/i18n/i18nRoot.ts b/i18n/i18nRoot.ts index 926b10c3..7f2c1831 100644 --- a/i18n/i18nRoot.ts +++ b/i18n/i18nRoot.ts @@ -54,8 +54,8 @@ export interface LangObj { "You might have some unsaved changes. Are you sure you want to logout?": string, "No permission": string "Click to clear": string - "Could not connect to the server (the server might be offline), probably a server maintenance is the reason": string - "Could not connect to the server (the server might be offline), probably a server maintenance is the reason. You can keep this tab open (e.g. if you have unsaved changes) and try it later again. Every action that requires connecting to the server will do the state check": string + "Could not connect to the server (the server might be offline), probably a server maintenance is the reason. If the problem persists, contact:": string + "Could not connect to the server (the server might be offline), probably a server maintenance is the reason. You can keep this tab open (e.g. if you have unsaved changes) and try it later again. Every action that requires connecting to the server will do the state check. If the problem persists, contact:": string "Shortcut: ctrl+0/cmd+0. Resets the quick-zoom to the zoom in the editor settings. Note that the quick-zoom is not persistent": string "Shortcut: ctrl++/cmd++": string "Shortcut: ctrl+-/cmd+-": string diff --git a/src/components/404internal/Chat404.tsx b/src/components/404internal/Chat404.tsx index 3b119cc2..d8073fba 100644 --- a/src/components/404internal/Chat404.tsx +++ b/src/components/404internal/Chat404.tsx @@ -96,6 +96,34 @@ class Chat404 extends React.Component<Props, State> { return Math.floor(Math.random() * (inclusiveMax + 1 - inclusiveMin)) + inclusiveMin; } + // + /** + * ~40 words per minute --> 0.66 words per second, use 0.4 to not wait too long... + * see https://www.ratatype.com/learn/average-typing-speed/ + * @param message + */ + getTypingTimeInMsFromMsg(message: string): number { + + // tslint:disable-next-line + const randomWait = this.rnd(100, 500) + + // tslint:disable-next-line + return message.split(' ').length * 0.4 * 1000 + randomWait + } + + /** + * ~270 words per minute --> 4.5 words per second + * see https://www.ratatype.com/learn/average-typing-speed/ + * @param message + */ + getReadTimeInMsFromMsg(message: string): number { + + // tslint:disable-next-line + const randomWait = this.rnd(500, 800) + // tslint:disable-next-line + return message.split(' ').length / 4 * 1000 + randomWait + } + async displayAllMessages(): Promise<void> { // tslint:disable-next-line @@ -120,7 +148,8 @@ class Chat404 extends React.Component<Props, State> { } as ChatMessage - await wait(this.getRndDelay()) + this.scrollToBottom() + await wait(this.getTypingTimeInMsFromMsg(message.message)) //remove old message and insert new with changed props this.setState((prevState: State) => { @@ -130,7 +159,7 @@ class Chat404 extends React.Component<Props, State> { } as State }) - await wait(this.getRndDelay()) + await wait(this.getReadTimeInMsFromMsg(message.message)) continue } @@ -141,13 +170,21 @@ class Chat404 extends React.Component<Props, State> { } as State }) - await wait(this.getRndDelay()) - + this.scrollToBottom() + await wait(this.getReadTimeInMsFromMsg(message.message)) } } + scrollToBottom(): void { + const scrollables = document.getElementById(chatWrapperId) + + if (scrollables && this.mainDiv) { + scrollables.scrollTo(0, this.mainDiv.scrollHeight) + } + } + render(): JSX.Element { return ( <div className="chat-component"> @@ -156,12 +193,7 @@ class Chat404 extends React.Component<Props, State> { </div> <div className="down-button clickable" onClick={() => { - - const scrollables = document.getElementById(chatWrapperId) - - if (scrollables && this.mainDiv) { - scrollables.scrollTo(0, this.mainDiv.scrollHeight) - } + this.scrollToBottom() }}> <Icon name="chevron down"/> </div> diff --git a/src/components/404internal/style.styl b/src/components/404internal/style.styl index 43067b45..2840f850 100644 --- a/src/components/404internal/style.styl +++ b/src/components/404internal/style.styl @@ -25,8 +25,9 @@ } .watermark { + pointer-events none position absolute - left calc(50% - 500px) + left calc(50% - 525px) //+25 to make it more centered and we need to show the scrollbar... top 100px height 450px font-size 600px @@ -66,6 +67,7 @@ margin-bottom 1em max-width 90% padding 0.3em + box-shadow: 0px 3px 2px -2px #c3c3c3 &.user-entered { padding: 0.3em 7px; diff --git a/src/constants.ts b/src/constants.ts index 8f7053a7..342ad7a9 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -16,6 +16,8 @@ import Logger from './helpers/logger' export const versionString = '2.4.9' +export const supportMail = 'yapex@informatik.uni-halle.de' + /** * the default mode for the editor when we got an invalid mode */ diff --git a/src/setup.ts b/src/setup.ts index f1019b35..463a867f 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -6,6 +6,7 @@ import store from './state/state' import {setUserData} from "./state/actions/settingsSite/userSettingsSiteActions"; import {userDataInitial} from "./state/reducers/settingsSite/settingsSiteReducers"; import { + supportMail, crsfCookieName, getCookie, refreshServerMessageIntervalInS, @@ -219,20 +220,20 @@ export async function setup(): Promise<void> { function setNotOnlineStatusMessage(displayErrorDialog: boolean): void { - globalState.dispatch(setBeforeLoginErrorMessage(getI18n(globalState.getState().i18nState.langId, - "Could not connect to the server (the server might be offline), probably a server maintenance is the reason" - ))) + globalState.dispatch(setBeforeLoginErrorMessage(`${getI18n(globalState.getState().i18nState.langId, + "Could not connect to the server (the server might be offline), probably a server maintenance is the reason. If the problem persists, contact:" + )} ${supportMail}`)) - globalState.dispatch(setLocalServerMessage(getI18n(globalState.getState().i18nState.langId, - "Could not connect to the server (the server might be offline), probably a server maintenance is the reason. You can keep this tab open (e.g. if you have unsaved changes) and try it later again. Every action that requires connecting to the server will do the state check" - ), true)) + globalState.dispatch(setLocalServerMessage(`${getI18n(globalState.getState().i18nState.langId, + "Could not connect to the server (the server might be offline), probably a server maintenance is the reason. You can keep this tab open (e.g. if you have unsaved changes) and try it later again. Every action that requires connecting to the server will do the state check. If the problem persists, contact:" + )} ${supportMail}`, true)) if (displayErrorDialog) { errorDialog(getI18n(globalState.getState().i18nState.langId, "Error"), - getI18n(globalState.getState().i18nState.langId, - "Could not connect to the server (the server might be offline), probably a server maintenance is the reason. You can keep this tab open (e.g. if you have unsaved changes) and try it later again. Every action that requires connecting to the server will do the state check" - ), globalState.getState().i18nState.langId + `${getI18n(globalState.getState().i18nState.langId, + "Could not connect to the server (the server might be offline), probably a server maintenance is the reason. You can keep this tab open (e.g. if you have unsaved changes) and try it later again. Every action that requires connecting to the server will do the state check. If the problem persists, contact:" + )} ${supportMail}`, globalState.getState().i18nState.langId ) } -- GitLab