Skip to content

Commit

Permalink
Show stale data on fetch faiure (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
iAmmar7 authored Mar 1, 2024
1 parent 8d12d47 commit dcc1e57
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions public/full.js
Original file line number Diff line number Diff line change
Expand Up @@ -1062,9 +1062,10 @@ const createAddressListItem = (address) => {
}

function updateAddressUI() {
const addressDiv = document.getElementById('addresses')
const { data: addresses } = window.__addressData
const { data: addresses } = window.__addressData || {}
if (!addresses) return

const addressDiv = document.getElementById('addresses')
const addressUl = addressDiv.querySelector('ul')
addressUl.innerHTML = ''
addresses
Expand All @@ -1085,9 +1086,10 @@ async function fetchAddresses() {
displayName: !searchText.length ? undefined : searchText,
})
window.__addressData = addressData
updateAddressUI()
} catch (error) {
console.error('Unable to fetch addresses', error)
} finally {
updateAddressUI()
}
}

Expand Down Expand Up @@ -1176,9 +1178,10 @@ function createConversationListItem(convo) {
}

function updateHistoryUI() {
const historyDiv = document.getElementById('histories')
const { data: histories } = window.__historyData
const { data: histories } = window.__historyData || {}
if (!histories) return

const historyDiv = document.getElementById('histories')
const historyUl = historyDiv.querySelector('ul')
historyUl.innerHTML = ''
histories
Expand All @@ -1193,10 +1196,11 @@ async function fetchHistories() {
try {
const historyData = await client.conversation.getConversations()
window.__historyData = historyData
updateHistoryUI()
subscribeToNewMessages()
} catch (error) {
console.error('Unable to fetch histories', error)
} finally {
updateHistoryUI()
}
}

Expand Down

0 comments on commit dcc1e57

Please sign in to comment.