status-desktop/ui/imports/shared/stores/RootStore.qml

239 lines
9.5 KiB
QML
Raw Normal View History

pragma Singleton
import QtQuick 2.12
QtObject {
id: root
// property var utilsModelInst: !!utilsModel ? utilsModel : null
// property var chatsModelInst: !!chatsModel ?chatsModel : null
// property var walletModelInst: !!walletModel ? walletModel : null
// property var profileModelInst: !!profileModel ? profileModel : null
property var profileSectionModuleInst: profileSectionModule
property var privacyModule: profileSectionModuleInst.privacyModule
property var userProfileInst: !!userProfile ? userProfile : null
property var walletSectionInst: !!walletSection ? walletSection : null
property var appSettingsInst: !!appSettings ? appSettings : null
property var accountSensitiveSettings: !!localAccountSensitiveSettings ? localAccountSensitiveSettings : null
property real volume: !!appSettingsInst ? appSettingsInst.volume * 0.01 : 0.5
property bool isWalletEnabled: !!accountSensitiveSettings ? accountSensitiveSettings.isWalletEnabled : false
property bool notificationSoundsEnabled: !!appSettingsInst ? appSettingsInst.notificationSoundsEnabled : true
property bool neverAskAboutUnfurlingAgain: !!accountSensitiveSettings ? accountSensitiveSettings.neverAskAboutUnfurlingAgain : false
property bool isGifWidgetEnabled: !!accountSensitiveSettings ? accountSensitiveSettings.isGifWidgetEnabled : false
property bool isTenorWarningAccepted: !!accountSensitiveSettings ? accountSensitiveSettings.isTenorWarningAccepted : false
property bool displayChatImages: !!accountSensitiveSettings ? accountSensitiveSettings.displayChatImages : false
// property string signingPhrase: !!walletModelInst ? walletModelInst.utilsView.signingPhrase : ""
// property string gasPrice: !!walletModelInst ? walletModelInst.gasView.gasPrice : "0"
// property string gasEthValue: !!walletModelInst ? walletModelInst.gasView.getGasEthValue : "0"
property CurrenciesStore currencyStore: CurrenciesStore {}
property string currentCurrency: walletSection.currentCurrency
// property string defaultCurrency: !!walletModelInst ? walletModelInst.balanceView.defaultCurrency : "0"
// property string fiatValue: !!walletModelInst ? walletModelInst.balanceView.getFiatValue : "0"
// property string cryptoValue: !!walletModelInst ? walletModelInst.balanceView.getCryptoValue : "0"
property var history: typeof walletSectionTransactions !== "undefined" ? walletSectionTransactions
: null
property var historyTransactions: walletSectionTransactions.model
property bool isNonArchivalNode: history ? history.isNonArchivalNode
: false
property bool tokensLoading: walletSection.tokensLoading
property var currentAccount: walletSectionCurrent
property var marketValueStore: TokenMarketValuesStore{}
function getNetworkColor(chainId) {
return networksModule.all.getChainColor(chainId)
}
function getNetworkIcon(chainId) {
return networksModule.all.getIconUrl(chainId)
}
function getNetworkShortName(chainId) {
return networksModule.all.getNetworkShortName(chainId)
}
function getNetworkIconUrl(symbol) {
return networksModule.all.getNetworkIconUrl(symbol)
}
function getNetworkName(symbol) {
return networksModule.all.getNetworkName(symbol)
}
function hex2Dec(value) {
return globalUtils.hex2Dec(value)
}
readonly property var formationChars: (["*", "`", "~"])
function getSelectedTextWithFormationChars(messageInputField) {
let i = 1
let text = ""
while (true) {
if (messageInputField.selectionStart - i < 0 && messageInputField.selectionEnd + i > messageInputField.length) {
break
}
text = messageInputField.getText(messageInputField.selectionStart - i, messageInputField.selectionEnd + i)
if (!formationChars.includes(text.charAt(0)) ||
!formationChars.includes(text.charAt(text.length - 1))) {
break
}
i++
}
return text
}
function setNeverAskAboutUnfurlingAgain(value) {
localAccountSensitiveSettings.neverAskAboutUnfurlingAgain = value;
}
function enableWallet() {
localAccountSensitiveSettings.isWalletEnabled = true;
}
function setIsTenorWarningAccepted(value) {
localAccountSensitiveSettings.isTenorWarningAccepted = value;
}
function copyToClipboard(text) {
globalUtils.copyToClipboard(text)
}
2022-01-13 08:58:42 +00:00
property var chatSectionChatContentInputAreaInst: typeof chatSectionChatContentInputArea !== "undefined" ? chatSectionChatContentInputArea
: null
property var gifColumnA: chatSectionChatContentInputAreaInst ? chatSectionChatContentInputArea.gifColumnA
: null
property var gifColumnB: chatSectionChatContentInputAreaInst ? chatSectionChatContentInputArea.gifColumnB
: null
property var gifColumnC: chatSectionChatContentInputAreaInst ? chatSectionChatContentInputArea.gifColumnC
: null
2022-01-13 08:58:42 +00:00
function searchGifs(query) {
if (chatSectionChatContentInputAreaInst)
chatSectionChatContentInputAreaInst.searchGifs(query)
2022-01-13 08:58:42 +00:00
}
function getTrendingsGifs() {
if (chatSectionChatContentInputAreaInst)
chatSectionChatContentInputAreaInst.getTrendingsGifs()
2022-01-13 08:58:42 +00:00
}
function updateWhitelistedUnfurlingSites(hostname, whitelisted) {
// no way to send update notification for individual array entries
let settings = localAccountSensitiveSettings.whitelistedUnfurlingSites
if (!settings)
settings = {}
if (settings[hostname] === whitelisted)
return
settings[hostname] = whitelisted
localAccountSensitiveSettings.whitelistedUnfurlingSites = settings
if(hostname === "media.tenor.com" && whitelisted === false)
RootStore.setIsTenorWarningAccepted(false)
}
2022-01-13 08:58:42 +00:00
function getRecentsGifs() {
if (chatSectionChatContentInputAreaInst)
chatSectionChatContentInputAreaInst.getRecentsGifs()
2022-01-13 08:58:42 +00:00
}
function getFavoritesGifs() {
return chatSectionChatContentInputAreaInst ? chatSectionChatContentInputAreaInst.getFavoritesGifs()
: null
2022-01-13 08:58:42 +00:00
}
function isFavorite(id) {
return chatSectionChatContentInputAreaInst ? chatSectionChatContentInputAreaInst.isFavorite(id)
: null
2022-01-13 08:58:42 +00:00
}
function toggleFavoriteGif(id, reload) {
if (chatSectionChatContentInputAreaInst)
chatSectionChatContentInputAreaInst.toggleFavoriteGif(id, reload)
2022-01-13 08:58:42 +00:00
}
function addToRecentsGif(id) {
if (chatSectionChatContentInputAreaInst)
chatSectionChatContentInputAreaInst.addToRecentsGif(id)
2022-01-13 08:58:42 +00:00
}
function getPasswordStrengthScore(password) {
return root.privacyModule.getPasswordStrengthScore(password);
}
function isFetchingHistory(address) {
return history.isFetchingHistory(address)
}
function loadTransactionsForAccount(address, pageSize) {
history.loadTransactionsForAccount(address, historyTransactions.getLastTxBlockNumber(), pageSize, true)
}
function hex2Eth(value) {
return globalUtils.hex2Eth(value)
}
function hex2Gwei(value) {
return globalUtils.hex2Gwei(value)
}
function findTokenSymbolByAddress(address) {
return walletSectionAllTokens.findTokenSymbolByAddress(address)
}
function getNameForSavedWalletAddress(address) {
return walletSectionSavedAddresses.getNameByAddress(address)
}
function createOrUpdateSavedAddress(name, address, favourite) {
return walletSectionSavedAddresses.createOrUpdateSavedAddress(name, address, favourite)
}
function deleteSavedAddress(address) {
return walletSectionSavedAddresses.deleteSavedAddress(address)
}
function getLatestBlockNumber() {
return walletSectionTransactions.getLastTxBlockNumber()
}
function getCurrencyAmount(amount, symbol) {
return currencyStore.getCurrencyAmount(amount, symbol)
}
function getFiatValue(balance, cryptoSymbol, fiatSymbol) {
return currencyStore.getFiatValue(balance, cryptoSymbol, fiatSymbol)
}
function getCryptoValue(balance, cryptoSymbol, fiatSymbol) {
return currencyStore.getCryptoValue(balance, cryptoSymbol, fiatSymbol)
}
function getGasEthValue(gweiValue, gasLimit) {
return currencyStore.getGasEthValue(gweiValue, gasLimit)
}
function formatCurrencyAmount(currencyAmount) {
return currencyStore.formatCurrencyAmount(currencyAmount)
}
function getHistoricalDataForToken(symbol, currency) {
walletSectionAllTokens.getHistoricalDataForToken(symbol,currency)
}
property bool marketHistoryIsLoading: walletSectionAllTokens.marketHistoryIsLoading
// TODO: range until we optimize to cache the data and abuse the requests
function fetchHistoricalBalanceForTokenAsJson(address, symbol, timeIntervalEnum) {
walletSectionAllTokens.fetchHistoricalBalanceForTokenAsJson(address, symbol, timeIntervalEnum)
}
property bool balanceHistoryIsLoading: walletSectionAllTokens.balanceHistoryIsLoading
}