mirror of
https://github.com/logos-blockchain/lez-explorer-ui.git
synced 2026-05-01 15:53:08 +00:00
fix: fix some minor bugs
This commit is contained in:
parent
5b1d74f237
commit
b7bce31cdc
@ -122,23 +122,32 @@ void ExplorerWidget::navigateTo(const NavTarget& target, bool addToHistory)
|
|||||||
} else if constexpr (std::is_same_v<T, NavBlock>) {
|
} else if constexpr (std::is_same_v<T, NavBlock>) {
|
||||||
auto block = m_indexer->getBlockById(t.blockId);
|
auto block = m_indexer->getBlockById(t.blockId);
|
||||||
if (block) {
|
if (block) {
|
||||||
auto* page = new BlockPage(*block);
|
auto* page = new BlockPage(*block, this);
|
||||||
connectPageSignals(page);
|
connectPageSignals(page);
|
||||||
showPage(page);
|
showPage(page);
|
||||||
|
} else {
|
||||||
|
qWarning("Block #%llu not found", static_cast<unsigned long long>(t.blockId));
|
||||||
|
showPage(m_mainPage);
|
||||||
}
|
}
|
||||||
} else if constexpr (std::is_same_v<T, NavTransaction>) {
|
} else if constexpr (std::is_same_v<T, NavTransaction>) {
|
||||||
auto tx = m_indexer->getTransaction(t.hash);
|
auto tx = m_indexer->getTransaction(t.hash);
|
||||||
if (tx) {
|
if (tx) {
|
||||||
auto* page = new TransactionPage(*tx);
|
auto* page = new TransactionPage(*tx, this);
|
||||||
connectPageSignals(page);
|
connectPageSignals(page);
|
||||||
showPage(page);
|
showPage(page);
|
||||||
|
} else {
|
||||||
|
qWarning("Transaction %s not found", qPrintable(t.hash));
|
||||||
|
showPage(m_mainPage);
|
||||||
}
|
}
|
||||||
} else if constexpr (std::is_same_v<T, NavAccount>) {
|
} else if constexpr (std::is_same_v<T, NavAccount>) {
|
||||||
auto account = m_indexer->getAccount(t.accountId);
|
auto account = m_indexer->getAccount(t.accountId);
|
||||||
if (account) {
|
if (account) {
|
||||||
auto* page = new AccountPage(*account, m_indexer.get());
|
auto* page = new AccountPage(*account, m_indexer.get(), this);
|
||||||
connectPageSignals(page);
|
connectPageSignals(page);
|
||||||
showPage(page);
|
showPage(page);
|
||||||
|
} else {
|
||||||
|
qWarning("Account %s not found", qPrintable(t.accountId));
|
||||||
|
showPage(m_mainPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, target);
|
}, target);
|
||||||
|
|||||||
@ -217,7 +217,7 @@ void MainPage::refresh()
|
|||||||
|
|
||||||
if (m_recentBlocksWidget) {
|
if (m_recentBlocksWidget) {
|
||||||
m_contentLayout->removeWidget(m_recentBlocksWidget);
|
m_contentLayout->removeWidget(m_recentBlocksWidget);
|
||||||
delete m_recentBlocksWidget;
|
m_recentBlocksWidget->deleteLater();
|
||||||
m_recentBlocksWidget = nullptr;
|
m_recentBlocksWidget = nullptr;
|
||||||
m_blocksLayout = nullptr;
|
m_blocksLayout = nullptr;
|
||||||
m_loadMoreBtn = nullptr;
|
m_loadMoreBtn = nullptr;
|
||||||
@ -322,8 +322,14 @@ void MainPage::onNewBlock(const Block& block)
|
|||||||
m_healthLabel->setText(QString("Chain height: %1").arg(block.blockId));
|
m_healthLabel->setText(QString("Chain height: %1").arg(block.blockId));
|
||||||
|
|
||||||
// Append to layout then move to top (index 0)
|
// Append to layout then move to top (index 0)
|
||||||
|
int countBefore = m_blocksLayout->count();
|
||||||
addBlockRow(m_blocksLayout, block);
|
addBlockRow(m_blocksLayout, block);
|
||||||
auto* newRow = m_blocksLayout->itemAt(m_blocksLayout->count() - 1)->widget();
|
if (m_blocksLayout->count() <= countBefore) return;
|
||||||
|
|
||||||
|
QLayoutItem* item = m_blocksLayout->itemAt(m_blocksLayout->count() - 1);
|
||||||
|
if (!item || !item->widget()) return;
|
||||||
|
|
||||||
|
QWidget* newRow = item->widget();
|
||||||
m_blocksLayout->removeWidget(newRow);
|
m_blocksLayout->removeWidget(newRow);
|
||||||
m_blocksLayout->insertWidget(0, newRow);
|
m_blocksLayout->insertWidget(0, newRow);
|
||||||
}
|
}
|
||||||
@ -332,7 +338,7 @@ void MainPage::clearSearchResults()
|
|||||||
{
|
{
|
||||||
if (m_searchResultsWidget) {
|
if (m_searchResultsWidget) {
|
||||||
m_contentLayout->removeWidget(m_searchResultsWidget);
|
m_contentLayout->removeWidget(m_searchResultsWidget);
|
||||||
delete m_searchResultsWidget;
|
m_searchResultsWidget->deleteLater();
|
||||||
m_searchResultsWidget = nullptr;
|
m_searchResultsWidget = nullptr;
|
||||||
}
|
}
|
||||||
if (m_recentBlocksWidget) {
|
if (m_recentBlocksWidget) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user