mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-17 13:07:32 +02:00
* Use new frontend * Remove whitespace * Remove more whitespace * Remove more whitespace * Add requests file * Try loading squeaks in home page * Got basic timeline working * Fix block time display * Show author pubkey in tweet card * Show profile name in tweet card * Show profile image in tweet card * Got tweet page working * Implement part of profile page * Show profile pubkey in pubkey page * Show profile name in profile page * User tweets now show in profile page * Show reply tweets * Load ancestor tweets, but show still not working * Got tweet reply thread working * Add partial implementation of make squeak * Add re-usable component for make squeak * Load signing profiles in middleware * Implement make squeak * Update favicon * Fix issue with updating state of replies on new squeak. * Remove author pubkey from squeak url path * Got reply squeak working * Fix update state with reducer on new reply * Show author profile image in make squeak component * Implement get more tweets in timeline * Fix load more tweets * Show loading state in timeline get mor * Clear timeline tweets on page load * Simplify props in make squeak component * Remove unused props from make squeak component * Fix params for tweet cards in profile page * Got follow and unfollow working * Fix tweets and replies tab in profile page * Got load more tweets working for profile page * Add delay to endpoints * Clear user tweets on profile page load * Remove delay from endpoint * Remove whitespace in explore page * Show signing profiles in explore page * Show contact profiles in explore page * Rename explore page to profiles * Remove trends from profiles page * Remove search tab from profiles page * Fix set follow or unfollow from profiles page * Change text of profile search box * Implement name change in edit profile * Simplify edit and follow buttons * Remove chat button in profile * Simplify user pubkey display in profile * Remove bio and location from profile edit * Remove banner from profile page * Got image change working * Remove log lines * Remove unused state from profile * Remove more state from profile page * Remove content of messages page * Remove unused state from profiles page * Remove unused import from profile page * Rename sats earned and sats spent tabs in profile page * Remove log line * Add create signing profile to profiles page * Remove banner from new profile modal * Add create contact profile to profiles page * Add comment for modal in profile page * Use separate modals in profile page for edit and spending * Add delete profile button to profile pag * Remove use of bookmark * Remove banner from delete profile modal * Implement delete tweet * Fix delete tweet for tweet card. * Add TODO comment * Got update tweet for like and unlike working * Simplify update tweet and delete tweet reducerts * Add comments to tweet component * Add comment to reducers * Remove check for user in tweet card. * Simplify props for tweet card. * Implement missing tweet component partially * Got display for missing tweet mostly working * Fix reducer for delete tweet from ancestors * Fix display of squeak with unknown author * Fix handling of unknown author in make squeak to reply * Got profile page working for missing profile * Implement create profile from missing profile page * Fix close make tweet modal on submit * Remove who to follow from feed * Fix close modal on submit new tweet in tweet card * Add new peers page * Got connected peers showing * Remove search bar from peers page * Show saved peers in peers page * Got save peer working * Remove input attach button from make squeak component * Got basic peer page working * Load peer connection info in peer page * Remove unused functions in peer page * Show correct host and port for peer and peers page * Got connect and disconnect working in peer page * Got connect and disconnect reducer working * Remove unused displays from peer page * Change word in connect button in peer page * Got tor toggle working * Add use tor option to create saved peer modal * Implement delete saved peer * Fix variable names in peers page * Fix issue with save peer * Fix action for save peer * Show block info and block explorer link * Get network in tweet page * Remove log line * Fix color scheme for missing tweet * Add download button to missing squeak * Show locked content in tweet and tweet card * Partial implementation of buy dialog * Got buy squeak working * Reload ancestors in download tweet middleware * Improve display of offer * Show payment summary in sidebar * Implemented beginning of payments page * Show sent payments in payments page * Implement clear sent payments * Fix link to payments in feed * Got received payments working * Fix action for load more received payments * Fix typo in get more received payments * Remove log lines * Add header title for peers page * Remove unused pages from nav * Show alert when payment fails * Use more menu in profile page * Remove icon from more button * Add export private key * Hide export private key for contact profile * Remove log lines * Got import signing profile working * Remove log lines * Improve display of locked content * Fix comment for edit moda * Add download squeaks action to profile page * Remove log lines * Show button for download action in profile page * Include time in payments display * Remove bookmark component * Remove list component * Remove chat component * Remove retweet action * Remove all use of account attributes * Change unit to sats for sell dialog * Fix display of peer page * Remove usage of account state * Try to implement logout * Include prefix in route path * Got redirect on logout working * Got logout working in prod * Remove log lines * Remove suggestions action * Show connection info * Got autoconnect toggle working * Rearrange peer page * Got custom icon working * Use custom icon * Fix path string match in nav * Add modal to show external address in peers page * Remove export button from external address modal * Update frontend build * Fix more menu in profile page * Update frontend build
141 lines
5 KiB
JavaScript
141 lines
5 KiB
JavaScript
// This optional code is used to register a service worker.
|
|
// register() is not called by default.
|
|
|
|
// This lets the app load faster on subsequent visits in production, and gives
|
|
// it offline capabilities. However, it also means that developers (and users)
|
|
// will only see deployed updates on subsequent visits to a page, after all the
|
|
// existing tabs open on the page have been closed, since previously cached
|
|
// resources are updated in the background.
|
|
|
|
// To learn more about the benefits of this model and instructions on how to
|
|
// opt-in, read https://bit.ly/CRA-PWA
|
|
|
|
const isLocalhost = Boolean(
|
|
window.location.hostname === 'localhost' ||
|
|
// [::1] is the IPv6 localhost address.
|
|
window.location.hostname === '[::1]' ||
|
|
// 127.0.0.0/8 are considered localhost for IPv4.
|
|
window.location.hostname.match(
|
|
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
|
|
)
|
|
);
|
|
|
|
export function register(config) {
|
|
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
|
// The URL constructor is available in all browsers that support SW.
|
|
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
|
|
if (publicUrl.origin !== window.location.origin) {
|
|
// Our service worker won't work if PUBLIC_URL is on a different origin
|
|
// from what our page is served on. This might happen if a CDN is used to
|
|
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
|
|
return;
|
|
}
|
|
|
|
window.addEventListener('load', () => {
|
|
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
|
|
|
if (isLocalhost) {
|
|
// This is running on localhost. Let's check if a service worker still exists or not.
|
|
checkValidServiceWorker(swUrl, config);
|
|
|
|
// Add some additional logging to localhost, pointing developers to the
|
|
// service worker/PWA documentation.
|
|
navigator.serviceWorker.ready.then(() => {
|
|
console.log(
|
|
'This web app is being served cache-first by a service ' +
|
|
'worker. To learn more, visit https://bit.ly/CRA-PWA'
|
|
);
|
|
});
|
|
} else {
|
|
// Is not localhost. Just register service worker
|
|
registerValidSW(swUrl, config);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
function registerValidSW(swUrl, config) {
|
|
navigator.serviceWorker
|
|
.register(swUrl)
|
|
.then(registration => {
|
|
registration.onupdatefound = () => {
|
|
const installingWorker = registration.installing;
|
|
if (installingWorker == null) {
|
|
return;
|
|
}
|
|
installingWorker.onstatechange = () => {
|
|
if (installingWorker.state === 'installed') {
|
|
if (navigator.serviceWorker.controller) {
|
|
// At this point, the updated precached content has been fetched,
|
|
// but the previous service worker will still serve the older
|
|
// content until all client tabs are closed.
|
|
console.log(
|
|
'New content is available and will be used when all ' +
|
|
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
|
|
);
|
|
|
|
// Execute callback
|
|
if (config && config.onUpdate) {
|
|
config.onUpdate(registration);
|
|
}
|
|
} else {
|
|
// At this point, everything has been precached.
|
|
// It's the perfect time to display a
|
|
// "Content is cached for offline use." message.
|
|
console.log('Content is cached for offline use.');
|
|
|
|
// Execute callback
|
|
if (config && config.onSuccess) {
|
|
config.onSuccess(registration);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
})
|
|
.catch(error => {
|
|
console.error('Error during service worker registration:', error);
|
|
});
|
|
}
|
|
|
|
function checkValidServiceWorker(swUrl, config) {
|
|
// Check if the service worker can be found. If it can't reload the page.
|
|
fetch(swUrl, {
|
|
headers: { 'Service-Worker': 'script' },
|
|
})
|
|
.then(response => {
|
|
// Ensure service worker exists, and that we really are getting a JS file.
|
|
const contentType = response.headers.get('content-type');
|
|
if (
|
|
response.status === 404 ||
|
|
(contentType != null && contentType.indexOf('javascript') === -1)
|
|
) {
|
|
// No service worker found. Probably a different app. Reload the page.
|
|
navigator.serviceWorker.ready.then(registration => {
|
|
registration.unregister().then(() => {
|
|
window.location.reload();
|
|
});
|
|
});
|
|
} else {
|
|
// Service worker found. Proceed as normal.
|
|
registerValidSW(swUrl, config);
|
|
}
|
|
})
|
|
.catch(() => {
|
|
console.log(
|
|
'No internet connection found. App is running in offline mode.'
|
|
);
|
|
});
|
|
}
|
|
|
|
export function unregister() {
|
|
if ('serviceWorker' in navigator) {
|
|
navigator.serviceWorker.ready
|
|
.then(registration => {
|
|
registration.unregister();
|
|
})
|
|
.catch(error => {
|
|
console.error(error.message);
|
|
});
|
|
}
|
|
}
|