@@ -8,7 +8,6 @@ import { useSelector, useDispatch } from 'react-redux';
88import classNames from 'classnames' ;
99import { Console as ConsoleFeed } from 'console-feed' ;
1010import {
11- CONSOLE_FEED_WITHOUT_ICONS ,
1211 CONSOLE_FEED_LIGHT_STYLES ,
1312 CONSOLE_FEED_DARK_STYLES ,
1413 CONSOLE_FEED_CONTRAST_STYLES
@@ -43,7 +42,7 @@ import { useDidUpdate } from '../hooks/custom-hooks';
4342import useHandleMessageEvent from '../hooks/useHandleMessageEvent' ;
4443import { listen } from '../../../utils/dispatcher' ;
4544
46- const getConsoleFeedStyle = ( theme , times , fontSize ) => {
45+ const getConsoleFeedStyle = ( theme , fontSize ) => {
4746 const style = {
4847 BASE_FONT_FAMILY : 'Inconsolata, monospace'
4948 } ;
@@ -73,15 +72,12 @@ const getConsoleFeedStyle = (theme, times, fontSize) => {
7372 } ;
7473 const CONSOLE_FEED_SIZES = {
7574 TREENODE_LINE_HEIGHT : 1.2 ,
76- BASE_FONT_SIZE : fontSize ,
77- ARROW_FONT_SIZE : fontSize ,
78- LOG_ICON_WIDTH : fontSize ,
79- LOG_ICON_HEIGHT : 1.45 * fontSize
75+ BASE_FONT_SIZE : ` ${ fontSize } px` ,
76+ ARROW_FONT_SIZE : ` ${ fontSize } px` ,
77+ LOG_ICON_WIDTH : ` ${ fontSize } px` ,
78+ LOG_ICON_HEIGHT : ` ${ 1.45 * fontSize } px`
8079 } ;
8180
82- if ( times > 1 ) {
83- Object . assign ( style , CONSOLE_FEED_WITHOUT_ICONS ) ;
84- }
8581 switch ( theme ) {
8682 case 'light' :
8783 return Object . assign (
@@ -114,24 +110,6 @@ const Console = ({ t }) => {
114110 const isExpanded = useSelector ( ( state ) => state . ide . consoleIsExpanded ) ;
115111 const isPlaying = useSelector ( ( state ) => state . ide . isPlaying ) ;
116112 const { theme, fontSize } = useSelector ( ( state ) => state . preferences ) ;
117- const dataCompare = ( data1 , data2 ) => {
118- if ( data1 . length !== data2 . length ) {
119- return false ;
120- }
121- for ( let i = 0 ; i < data1 . length ; i += 1 ) {
122- if ( data1 [ i ] !== data2 [ i ] ) {
123- return false ;
124- }
125- }
126- return true ;
127- } ;
128- for ( let i = 1 ; i < consoleEvents . length ; i += 1 ) {
129- if ( dataCompare ( consoleEvents [ i ] . data , consoleEvents [ i - 1 ] . data ) ) {
130- consoleEvents [ i - 1 ] . times += consoleEvents [ i ] . times ;
131- consoleEvents . splice ( i , 1 ) ;
132- i -= 1 ;
133- }
134- }
135113 const {
136114 collapseConsole,
137115 expandConsole,
@@ -187,30 +165,16 @@ const Console = ({ t }) => {
187165 </ div >
188166 </ header >
189167 < div className = "preview-console__body" >
190- < div ref = { cm } className = "preview-console__messages" >
191- { consoleEvents . map ( ( consoleEvent ) => {
192- const { method, times } = consoleEvent ;
193- return (
194- < div
195- key = { consoleEvent . id }
196- className = { `preview-console__message preview-console__message--${ method } ` }
197- >
198- { times > 1 && (
199- < div
200- className = "preview-console__logged-times"
201- style = { { fontSize, borderRadius : fontSize / 2 } }
202- >
203- { times }
204- </ div >
205- ) }
206- < ConsoleFeed
207- styles = { getConsoleFeedStyle ( theme , times , fontSize ) }
208- logs = { [ consoleEvent ] }
209- key = { `${ consoleEvent . id } -${ theme } -${ fontSize } ` }
210- />
211- </ div >
212- ) ;
213- } ) }
168+ < div
169+ ref = { cm }
170+ className = "preview-console__messages"
171+ style = { { fontSize } }
172+ >
173+ < ConsoleFeed
174+ styles = { getConsoleFeedStyle ( theme , fontSize ) }
175+ logs = { consoleEvents }
176+ key = { `${ theme } -${ fontSize } ` }
177+ />
214178 </ div >
215179 { isExpanded && isPlaying && (
216180 < ConsoleInput
0 commit comments