status-react/externs.js

612 lines
20 KiB
JavaScript
Raw Normal View History

var TopLevel = {
"abs" : function () {},
"ActionSheetIOS" : function () {},
"add" : function () {},
"addEventListener" : function () {},
"addListener" : function () {},
"addPeer" : function () {},
"addSymKey" : function () {},
"addTier2Support" : function () {},
"Alert" : function () {},
"alert" : function () {},
"all" : function () {},
"Android" : function () {},
"android" : function () {},
"Animated" : function () {},
"append" : function () {},
"appStateChange" : function () {},
"args" : function () {},
"argv" : function () {},
"Array" : function () {},
"array" : function () {},
"AsyncStorage" : function () {},
"at" : function () {},
"back" : function () {},
"BACK" : function () {},
"BackHandler" : function () {},
"balanceOf" : function () {},
"bezier" : function () {},
"BigNumber" : function () {},
"blur" : function () {},
"button" : function () {},
"bytesToHex" : function () {},
"call" : function () {},
"callPrivateRPC" : function () {},
"callRPC" : function () {},
"canImplyAuthentication" : function () {},
"catch" : function () {},
"Chance" : function () {},
"changePin" : function () {},
"Channel" : function () {},
"chaosModeUpdate" : function () {},
"charCodeAt" : function () {},
"checkAddressChecksum" : function () {},
"checkVideoAuthorizationStatus" : function () {},
"author": function() {},
"encryptionId": function() {},
"chat": function() {},
"messageId": function() {},
"clear" : function () {},
"clearCookies" : function () {},
"clearInterval" : function () {},
"clearStorageAPIs" : function () {},
"clearTimeout" : function () {},
"Clipboard" : function () {},
"close" : function () {},
"closeApplication" : function () {},
"code" : function () {},
"concat" : function () {},
"confirmMessagesProcessed" : function () {},
"messages": function() {},
"discovery": function() {},
"negotiated": function() {},
"chatId": function() {},
"confirmMessagesProcessedByID" : function () {},
"connectionChange" : function () {},
"console" : function () {},
"ContactRequest" : function () {},
"ContactRequestConfirmed" : function () {},
"ContactRequestConfirmedHandler" : function () {},
"ContactRequestHandler" : function () {},
"ContactUpdate" : function () {},
"ContactUpdateHandler" : function () {},
"contentOffset" : function () {},
"contentSize" : function () {},
"contract" : function () {},
"createAccount" : function () {},
"createBatch" : function () {},
"createChannel" : function () {},
"cubic" : function () {},
"CURRENCY" : function () {},
"data" : function () {},
"Date" : function () {},
"DateTimeFormat" : function () {},
"DEBUG" : function () {},
"decay" : function () {},
"dedupId": function() {},
"DECIMAL_SEP" : function () {},
"GROUP_SEP" : function () {},
"PERCENT" : function () {},
"ZERO_DIGIT" : function () {},
"PLUS_SIGN" : function () {},
"MINUS_SIGN" : function () {},
"EXP_SYMBOL" : function () {},
"PERMILL" : function () {},
"INFINITY" : function () {},
"NAN" : function () {},
"DECIMAL_PATTERN" : function () {},
"SCIENTIFIC_PATTERN" : function () {},
"PERCENT_PATTERN" : function () {},
"CURRENCY_PATTERN" : function () {},
"DEF_CURRENCY_CODE" : function () {},
"decimals" : function () {},
"decodeURI" : function () {},
"default" : function () {},
"defaultAccount" : function () {},
"defaultSeparator" : function () {},
"delay" : function () {},
"DesktopNotification" : function () {},
"DeviceEventEmitter" : function () {},
"Dimensions" : function () {},
"dispatch" : function () {},
"disableNotifications" : function () {},
"displayNotification" : function () {},
"dividedBy" : function () {},
"DocumentDirectoryPath" : function () {},
"dx" : function () {},
"dy" : function () {},
"ease" : function () {},
"Easing" : function () {},
"enableNotifications" : function () {},
"enableVibration" : function () {},
"encode" : function () {},
"encodeURIComponent" : function () {},
"encryptionKey" : function () {},
"end" : function () {},
"endCoordinates" : function () {},
"entries" : function () {},
"eq" : function () {},
"Error" : function () {},
"error" : function () {},
"ErrorUtils" : function () {},
"estimateGas" : function () {},
"eth" : function () {},
"event" : function () {},
"EventEmmiter" : function () {},
"exec" : function () {},
"execute" : function () {},
"exists" : function () {},
"extPost" : function () {},
"extractGroupMembershipSignatures" : function () {},
"identicon": function() {},
"generateAlias": function() {},
"fallbacks" : function () {},
"fetch" : function () {},
"floor" : function () {},
"focus" : function () {},
"format" : function () {},
"FormData" : function () {},
"from" : function () {},
"fromCharCode" : function () {},
"fromWei" : function () {},
"generateAndLoadKey" : function () {},
"generateMnemonic" : function () {},
"generateSymKeyFromPassword" : function () {},
"get" : function () {},
"getApplicationInfo" : function () {},
"getBalance" : function () {},
"getBlock" : function () {},
"getBlockNumber" : function () {},
"getConnectionInfo" : function () {},
"getDomain" : function () {},
"getGasPrice" : function () {},
"getGenericPassword" : function () {},
"getGlobalHandler" : function () {},
"getInitialNotification" : function () {},
"getInitialURL" : function () {},
"getInternetCredentials" : function () {},
"getItem" : function () {},
"getKeys" : function () {},
"getLayout" : function () {},
"getNetwork" : function () {},
"getNode" : function () {},
"getNodesFromContract" : function () {},
"getPublicKey" : function () {},
"publicKey": function() {},
"alias": function() {},
"getSecurityLevel" : function () {},
"getStateForAction" : function () {},
"getString" : function () {},
"getSymKey" : function () {},
"getSyncing" : function () {},
"getTimezoneOffset" : function () {},
"getToken" : function () {},
"getTransactionReceipt" : function () {},
"getValue" : function () {},
"goog" : function () {},
"greaterThanOrEqualTo" : function () {},
"GroupMembershipUpdate" : function () {},
"GroupMembershipUpdateHandler" : function () {},
"guid" : function () {},
"hashMessage" : function () {},
"hashTransaction" : function () {},
"hashTypedData" : function () {},
"headers" : function () {},
"height" : function () {},
"hexToNumber" : function () {},
"hexToNumberString" : function () {},
"hexToUtf8" : function () {},
"utf8ToHex" : function () {},
"hide" : function () {},
"i18n" : function () {},
"ignoreWarnings" : function () {},
"in" : function () {},
"index" : function () {},
"indexOf" : function () {},
"init" : function () {},
"initKeystore" : function () {},
"injectJavaScript" : function () {},
"installApplet" : function () {},
"installAppletAndInitCard" : function () {},
"Int8Array" : function () {},
"integer" : function () {},
"interpolate" : function () {},
"is24Hour" : function () {},
"isAddress" : function () {},
"isConnected" : function () {},
"isConnectionExpensive" : function () {},
"isDeviceRooted" : function () {},
"isFocused" : function () {},
"isLinux" : function () {},
"isMacOs" : function () {},
"isMatches" : function () {},
"isNaN" : function () {},
"isUnix" : function () {},
"isWin" : function () {},
"isZero" : function () {},
"Item" : function () {},
"item" : function () {},
"JSON" : function () {},
"jsonEvent" : function () {},
"keccak512" : function () {},
"Keyboard" : function () {},
"language" : function () {},
"layout" : function () {},
"layoutMeasurement" : function () {},
"leftPad" : function () {},
"length" : function () {},
"LibraryDirectoryPath" : function () {},
"Linking" : function () {},
"locale" : function () {},
"log" : function () {},
"login" : function () {},
"loginWithKeycard" : function () {},
"logout" : function () {},
"loop" : function () {},
"lt" : function () {},
"mail" : function () {},
"map" : function () {},
"map->GroupMembershipUpdate" : function () {},
"MapEntry" : function () {},
"markTrustedPeer" : function () {},
"MaskedData" : function () {},
"Math" : function () {},
"Message" : function () {},
"message" : function () {},
"MessageHandler" : function () {},
"MessagesSeen" : function () {},
"MessagesSeenHandler" : function () {},
"messaging" : function () {},
"method" : function () {},
"metadata": function() {},
"minus" : function () {},
"plus" : function () {},
"mkdir" : function () {},
"module" : function () {},
"moveFile" : function () {},
"Multihash" : function () {},
"name" : function () {},
"response-to": function() {},
"content_type": function() {},
"message_type": function() {},
"chat_id": function() {},
"clock": function() {},
"nativeEvent" : function () {},
"NativeEventEmitter" : function () {},
"NativeModules" : function () {},
"navigate" : function () {},
"navigation" : function () {},
"NavigationActions" : function () {},
"NavigationEvents" : function () {},
"newKeyPair" : function () {},
"newMessageFilter" : function () {},
"newRawMessageFilter": function() {},
"newSymKey" : function () {},
"nfcIsEnabled" : function () {},
"nfcIsSupported" : function () {},
"Notification" : function () {},
"notification" : function () {},
"notifications" : function () {},
"now" : function () {},
"Number" : function () {},
"NumberFormatSymbols" : function () {},
"NumberFormatSymbols_af" : function () {},
"NumberFormatSymbols_am" : function () {},
"NumberFormatSymbols_ar" : function () {},
"NumberFormatSymbols_ar_DZ" : function () {},
"NumberFormatSymbols_az" : function () {},
"NumberFormatSymbols_be" : function () {},
"NumberFormatSymbols_bg" : function () {},
"NumberFormatSymbols_bn" : function () {},
"NumberFormatSymbols_br" : function () {},
"NumberFormatSymbols_bs" : function () {},
"NumberFormatSymbols_cs" : function () {},
"NumberFormatSymbols_cy" : function () {},
"NumberFormatSymbols_da" : function () {},
"NumberFormatSymbols_de_CH" : function () {},
"NumberFormatSymbols_en" : function () {},
"NumberFormatSymbols_en_AU" : function () {},
"NumberFormatSymbols_en_CA" : function () {},
"NumberFormatSymbols_en_IN" : function () {},
"NumberFormatSymbols_en_SG" : function () {},
"NumberFormatSymbols_es_419" : function () {},
"NumberFormatSymbols_fa" : function () {},
"NumberFormatSymbols_fil" : function () {},
"NumberFormatSymbols_he" : function () {},
"NumberFormatSymbols_hr" : function () {},
"NumberFormatSymbols_hu" : function () {},
"NumberFormatSymbols_hy" : function () {},
"NumberFormatSymbols_id" : function () {},
"NumberFormatSymbols_is" : function () {},
"NumberFormatSymbols_ja" : function () {},
"NumberFormatSymbols_ka" : function () {},
"NumberFormatSymbols_kk" : function () {},
"NumberFormatSymbols_km" : function () {},
"NumberFormatSymbols_ko" : function () {},
"NumberFormatSymbols_ky" : function () {},
"NumberFormatSymbols_ln" : function () {},
"NumberFormatSymbols_lo" : function () {},
"NumberFormatSymbols_mk" : function () {},
"NumberFormatSymbols_mn" : function () {},
"NumberFormatSymbols_mo" : function () {},
"NumberFormatSymbols_ms" : function () {},
"NumberFormatSymbols_my" : function () {},
"NumberFormatSymbols_nb" : function () {},
"NumberFormatSymbols_ne" : function () {},
"NumberFormatSymbols_pl" : function () {},
"NumberFormatSymbols_pt" : function () {},
"NumberFormatSymbols_ro" : function () {},
"NumberFormatSymbols_ru" : function () {},
"NumberFormatSymbols_sh" : function () {},
"NumberFormatSymbols_si" : function () {},
"NumberFormatSymbols_sq" : function () {},
"NumberFormatSymbols_sv" : function () {},
"NumberFormatSymbols_sw" : function () {},
"NumberFormatSymbols_th" : function () {},
"NumberFormatSymbols_tr" : function () {},
"NumberFormatSymbols_uk" : function () {},
"NumberFormatSymbols_ur" : function () {},
"NumberFormatSymbols_uz" : function () {},
"NumberFormatSymbols_vi" : function () {},
"NumberFormatSymbols_zh" : function () {},
"NumberFormatSymbols_zh_HK" : function () {},
"NumberFormatSymbols_zh_TW" : function () {},
"numberToHex" : function () {},
"ok" : function () {},
"onMessage" : function () {},
"onNotification" : function () {},
"onNotificationOpened" : function () {},
"onTokenRefresh" : function () {},
"openAccounts" : function () {},
"openNfcSettings" : function () {},
"openPicker" : function () {},
"openURL" : function () {},
"OS" : function () {},
"out" : function () {},
"p" : function () {},
"pageY" : function () {},
"pair" : function () {},
"PairInstallation" : function () {},
"PairInstallationHandler" : function () {},
"panHandlers" : function () {},
"PanResponder" : function () {},
"parallel" : function () {},
"parse" : function () {},
"parseFloat" : function () {},
"parseInt" : function () {},
"password" : function () {},
"path" : function () {},
"payload" : function () {},
"PermissionsAndroid" : function () {},
"PersistentPriorityMap" : function () {},
"PersonalRequestCommand" : function () {},
"PersonalSendCommand" : function () {},
"Platform" : function () {},
"pow" : function () {},
"Priority" : function () {},
"Category" : function () {},
"High" : function () {},
"Importance" : function () {},
"prepareDirAndUpdateConfig" : function () {},
"Promise" : function () {},
"props" : function () {},
"prototype" : function () {},
"push" : function () {},
"quad" : function () {},
"ReactNative" : function () {},
"readDir" : function () {},
"readFile" : function () {},
"recoverAccount" : function () {},
"reduce" : function () {},
"register" : function () {},
"registerComponent" : function () {},
"registerHeadlessTask" : function () {},
"reject" : function () {},
"reload" : function () {},
"remove" : function () {},
"removeAllListeners" : function () {},
"removeEventListener" : function () {},
"removeKey" : function () {},
"removeKeyWithUnpair" : function () {},
"removeListener" : function () {},
"repeat" : function () {},
"request" : function () {},
"requestMessages" : function () {},
"requestMultiple" : function () {},
"requestPermission" : function () {},
"require" : function () {},
"reset" : function () {},
"resetGenericPassword" : function () {},
"resetInternetCredentials" : function () {},
"resolve" : function () {},
"respond" : function () {},
"rightPad" : function () {},
"round" : function () {},
"routeName" : function () {},
"router" : function () {},
"routes" : function () {},
"saveAccountAndLogin" : function () {},
"saveAccountAndLoginWithKeycard" : function () {},
"schemaVersion" : function () {},
"scrollTo" : function () {},
"scrollToEnd" : function () {},
"scrollToIndex" : function () {},
"section" : function () {},
"selection" : function () {},
"sendDirectMessage" : function () {},
"sendLogs" : function () {},
"sendPairingMessage" : function () {},
"sendPublicMessage" : function () {},
"sendToBridge" : function () {},
"sendTransaction" : function () {},
"sendTransactionWithSignature" : function () {},
"separators" : function () {},
"sequence" : function () {},
"set" : function () {},
"setAutoCancel" : function () {},
"setBackgroundColor" : function () {},
"setBarStyle" : function () {},
"setBlankPreviewFlag" : function () {},
"setCategory" : function () {},
"setChannelId" : function () {},
"setCurrentDapp" : function () {},
"setDockBadgeLabel" : function () {},
"setGenericPassword" : function () {},
"setGlobalHandler" : function () {},
"setGroup" : function () {},
"setHidden" : function () {},
"setInternetCredentials" : function () {},
"setInterval" : function () {},
"setItem" : function () {},
"setNativeProps" : function () {},
"setNetworkActivityIndicatorVisible" : function () {},
"setPriority" : function () {},
"setShowBadge" : function () {},
"setSmallIcon" : function () {},
"setSoftInputMode" : function () {},
"setSound" : function () {},
"setString" : function () {},
"setTimeout" : function () {},
"setTranslucent" : function () {},
"setUsername" : function () {},
"setValue" : function () {},
"sha3" : function () {},
"Share" : function () {},
"share" : function () {},
"shh" : function () {},
"show" : function () {},
"showActionSheetWithOptions" : function () {},
"showPicker" : function () {},
"sign" : function () {},
"signGroupMembership" : function () {},
"signMessage" : function () {},
"signTypedData" : function () {},
"slice" : function () {},
"SplashScreen" : function () {},
"spring" : function () {},
"stack" : function () {},
"StackActions" : function () {},
"start" : function () {},
"startNode" : function () {},
"state" : function () {},
"Status" : function () {},
"status" : function () {},
"statusText" : function () {},
"stop" : function () {},
"stopAnimation" : function () {},
"stopNode" : function () {},
"stopWatching" : function () {},
"stream" : function () {},
"String" : function () {},
"stringify" : function () {},
"subscribe" : function () {},
"substr" : function () {},
"symbol" : function () {},
"SyncInstallation" : function () {},
"SyncInstallationHandler" : function () {},
"t" : function () {},
"takePictureAsync" : function () {},
"Text" : function () {},
"text" : function () {},
"parsedText": function() {},
"parsedMessage": function() {},
"content": function() {},
"TextEncoder" : function () {},
"then" : function () {},
"times" : function () {},
"timestamp" : function () {},
"timing" : function () {},
"title" : function () {},
"toAscii" : function () {},
"toChecksumAddress" : function () {},
"toFixed" : function () {},
"toHex" : function () {},
"toLocaleString" : function () {},
"toNumber" : function () {},
"torchMode" : function () {},
"toString" : function () {},
"totalSupply" : function () {},
"toTwosComplement" : function () {},
"toUtf8" : function () {},
"toWei" : function () {},
"translations" : function () {},
"type": function() {},
"Uint8Array" : function () {},
"unblockPin" : function () {},
"unlink" : function () {},
"unpair" : function () {},
"unpairAndDelete" : function () {},
"updateMailservers" : function () {},
"Uri" : function () {},
"url" : function () {},
"Value" : function () {},
"value" : function () {},
"verify" : function () {},
"verifyPin" : function () {},
"Version" : function () {},
"version" : function () {},
"vibrate" : function () {},
"View" : function () {},
"FlatList" : function () {},
"warn" : function () {},
"WebView" : function () {},
"WebViewBridgeModule" : function () {},
"width" : function () {},
"window" : function () {},
"writeCopyTo" : function () {},
"x" : function () {},
"y" : function () {},
"YellowBox" : function () {},
"UtcDateTime": function () {},
"fromTimestamp": function () {},
"ERAS": function () {},
"ERANAMES": function () {},
"NARROWMONTHS": function () {},
"STANDALONENARROWMONTHS": function () {},
"MONTHS": function () {},
"STANDALONEMONTHS": function () {},
"SHORTMONTHS": function () {},
"STANDALONESHORTMONTHS": function () {},
"WEEKDAYS": function () {},
"STANDALONEWEEKDAYS": function () {},
"SHORTWEEKDAYS": function () {},
"STANDALONESHORTWEEKDAYS": function () {},
"NARROWWEEKDAYS": function () {},
"STANDALONENARROWWEEKDAYS": function () {},
"SHORTQUARTERS": function () {},
"QUARTERS": function () {},
"AMPMS": function () {},
"DATEFORMATS": function () {},
"TIMEFORMATS": function () {},
"DATETIMEFORMATS": function () {},
"FIRSTDAYOFWEEK": function () {},
"WEEKENDRANGE": function () {},
"FIRSTWEEKCUTOFFDAY": function () {},
"decimalPlaces": function () {},
"_android": function () {},
Fix message ordering and improve performance rec. messages This commit does a few things: ==== Ordering of messages ==== Change the ordering of messages from a mixture of timestamp/clock-value to use only clock-value. Datemarks are now not used for sorting anymore, which means that the order of messages is always causally related (not the case before, as we were breaking this property by sorting by datemark), but datemark calculation is unreliable (a reply to a message might have a timestamp < then the message that is replied to). So for timestamp calculation we naively group them ignoring "out-of-order timestamp" messages, although there's much to improve. It fixes an issue whereby the user would change their time and the message will be displayed in the past, although it is still possible to craft a message with a lower clock value and order it in the past (there's no way we can prevent this to some extent, but there are ways to mitigate, but outside the scope of this PR). ==== Performance of receiving messages ==== The app would freeze on pulling messages from a mailserver (100 or so). This is due to the JS Thread being hogged by CPU calculation, coupled with the fact that we always tried to process messages all in one go. This strategy can't scale, and given x is big enough (200,300,1000) the UI will freeze. Instead, each message is now processed separately, and we leave a gap between processing each message for the UI to respond to user input (otherwise the app freezes again). Pulling messages will be longer overall, but the app will be usuable while this happen (albeit it might slow down). Other strategies are possible (calculate off-db and do a big swap, avoiding many re-renders etc), but this is the reccommended strategy by re-frame author (Solving the CPU Hog problem), so sounds like a safe base point. The underlying data structure for holding messages was also changed, we used an immutable Red and Black Tree, same as a sorted map for clojure, but we use a js library as is twice as performing then clojure sorted map. We also don't sort messages again each time we receive them O(nlogn), but we insert them in order O(logn). Other data structures considered but discarded: 1) Plain vector, but performance prepending/insertion in the middle (both O(n)) were not great, as not really suited for these operations. 2) Linked list, appealing as append/prepend is O(1), while insertion is O(n). This is probably acceptable as messages tend to come in order (from the db, so adding N messages is O(n)), or the network (most of them prepends, or close to the head), while mailserver would not follow this path. An implementation of a linked list was built, which performed roughtly the same as a clojure sorted-map (although faster append/prepend), but not worth the complexity of having our own implementation. 3) Clojure sorted-map, probably the most versatile, performance were acceptable, but nowhere near the javascript implementation we decided on 4) Priority map, much slower than a sorted map (twice as slow) 5) Mutable sorted map, js implementation, (bintrees), not explored this very much, but from just a quick benchmark, performance were much worse that clojure immutable sorted map Given that each message is now processed separately, saving the chat / messages is also debounced to avoid spamming status-go with network requests. This is a temporary measure for now until that's done directly in status-go, without having to ping-pong with status-react. Next steps performance wise is to move stuff to status-go, parsing of transit, validation, which is heavy, at which point we can re-consider performance and how to handle messages. Fixes also an issue with the last message in the chat, we were using the last message in the chat list, which might not necessarely be the last message the chat has seen, in case messages were not loaded and a more recent message is the database (say you fetch historical messages for 1-to-1 A, you don't have any messages in 1-to-1 chat B loaded, you receive an historical message for chat B, it sets it as last message). Also use clj beans instead of js->clj for type conversion Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-10-24 14:23:20 +00:00
"next": function() {},
"prev": function() {},
"hasNext": function() {},
"hasPrev": function() {},
Render markdown Fixes: https://github.com/status-im/trailofbits-audit/issues/47 Fixes: https://github.com/status-im/trailofbits-audit/issues/46 Fixes: https://github.com/status-im/trailofbits-audit/issues/44 Fixes: https://github.com/status-im/security-reports/issues/13 Fixes: https://github.com/status-im/security-reports/issues/5 Fixes: https://github.com/status-im/status-react/issues/8995 This commits re-introduce rendering of markdown text and implent a few changes: 1) Parsing of the message content is now in status-go, this includes markdown, line-count, and rtl. Parsing is not nested, as there's some rendering degradation involved as we nest components, unclear exactly if it's react-native or clojure, haven't looked too deeply into it. 2) Emojii type messages are not parsed on the sending side, not the receiving one, using the appropriate content-type 3) Fixes a few issues with chat input rendering, currrently we use `chats/current-chat` subscription which is very heavy and should not be used unless necessary, and means that any change to chat will trigger a re-render, which caused re-rendering of input container on each received message. Also to note that input-container is fairly heavy to render, and it's rendered twice at each keypress on input. The inline markdow supported is: *italic* or _italic_ **bold** or __bold__ `inline code` http://test.com links \#status-tag The block markdown supported is: \# Headers ``` code blocks ``` > Quotereply The styling is very basic at the moment, but can be improved. Adding other markdown (photo,mentions) is straightforward and should come at little performance cost (unless the component to render is heavy, i.e a photo for example). There are some behavioral changes with this commit: 1) Links are only parsed if starting with http:// or https://, meaning that blah.com won't be parsed, nor www.test.com. This behavior is consistent with discord for example and allows faster parsing at little expense to ser experience imo. Fixes a few security issues as well. 2) Content is not anymore capped (regression), that's due to the fact that before we only rendered text and react-native allowed us easily to limit the number of lines, but adding markdown support means that this strategy is not viable anymore. Performance of rendering don't see to be very much impacted by this, I would re-introduce it if necessary, but I'd rather do that in a separate PR. Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-11-07 13:41:37 +00:00
"rtl": function() {},
"lineCount": function() {},
Fix message ordering and improve performance rec. messages This commit does a few things: ==== Ordering of messages ==== Change the ordering of messages from a mixture of timestamp/clock-value to use only clock-value. Datemarks are now not used for sorting anymore, which means that the order of messages is always causally related (not the case before, as we were breaking this property by sorting by datemark), but datemark calculation is unreliable (a reply to a message might have a timestamp < then the message that is replied to). So for timestamp calculation we naively group them ignoring "out-of-order timestamp" messages, although there's much to improve. It fixes an issue whereby the user would change their time and the message will be displayed in the past, although it is still possible to craft a message with a lower clock value and order it in the past (there's no way we can prevent this to some extent, but there are ways to mitigate, but outside the scope of this PR). ==== Performance of receiving messages ==== The app would freeze on pulling messages from a mailserver (100 or so). This is due to the JS Thread being hogged by CPU calculation, coupled with the fact that we always tried to process messages all in one go. This strategy can't scale, and given x is big enough (200,300,1000) the UI will freeze. Instead, each message is now processed separately, and we leave a gap between processing each message for the UI to respond to user input (otherwise the app freezes again). Pulling messages will be longer overall, but the app will be usuable while this happen (albeit it might slow down). Other strategies are possible (calculate off-db and do a big swap, avoiding many re-renders etc), but this is the reccommended strategy by re-frame author (Solving the CPU Hog problem), so sounds like a safe base point. The underlying data structure for holding messages was also changed, we used an immutable Red and Black Tree, same as a sorted map for clojure, but we use a js library as is twice as performing then clojure sorted map. We also don't sort messages again each time we receive them O(nlogn), but we insert them in order O(logn). Other data structures considered but discarded: 1) Plain vector, but performance prepending/insertion in the middle (both O(n)) were not great, as not really suited for these operations. 2) Linked list, appealing as append/prepend is O(1), while insertion is O(n). This is probably acceptable as messages tend to come in order (from the db, so adding N messages is O(n)), or the network (most of them prepends, or close to the head), while mailserver would not follow this path. An implementation of a linked list was built, which performed roughtly the same as a clojure sorted-map (although faster append/prepend), but not worth the complexity of having our own implementation. 3) Clojure sorted-map, probably the most versatile, performance were acceptable, but nowhere near the javascript implementation we decided on 4) Priority map, much slower than a sorted map (twice as slow) 5) Mutable sorted map, js implementation, (bintrees), not explored this very much, but from just a quick benchmark, performance were much worse that clojure immutable sorted map Given that each message is now processed separately, saving the chat / messages is also debounced to avoid spamming status-go with network requests. This is a temporary measure for now until that's done directly in status-go, without having to ping-pong with status-react. Next steps performance wise is to move stuff to status-go, parsing of transit, validation, which is heavy, at which point we can re-consider performance and how to handle messages. Fixes also an issue with the last message in the chat, we were using the last message in the chat list, which might not necessarely be the last message the chat has seen, in case messages were not loaded and a more recent message is the database (say you fetch historical messages for 1-to-1 A, you don't have any messages in 1-to-1 chat B loaded, you receive an historical message for chat B, it sets it as last message). Also use clj beans instead of js->clj for type conversion Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-10-24 14:23:20 +00:00
"key": function() {},
"keys": function() {},
"values": function() {},
"find": function() {},
"insert": function() {},
"update": function() {},
"isSupported" : function () {},
"authenticate" : function () {},
"createAppContainer" : function () {},
"useScreens" : function () {},
"multiAccountGenerateAndDeriveAddresses" : function () {},
"multiAccountStoreDerived" : function () {},
"multiAccountDeriveAddresses" : function () {},
"multiAccountReset" : function () {},
"multiAccountLoadAccount" : function () {},
"multiAccountStoreAccount" : function () {},
"multiAccountImportMnemonic" : function () {}
}