Open tzarebczan opened 2 years ago
This was the relevant code, didn't check where/how it's invoked:
const validate = async (userId: number) => {
if (!hasRegistration(userId)) return;
window.requestIdleCallback(async () => {
const serverTokens = await Lbryio.call('cfm', 'list');
const fcmToken = await getFcmToken();
if (!fcmToken) return;
const exists = serverTokens.find((item) => item.value === fcmToken);
if (!exists) {
await subscribe(userId, false);
}
});
};
per @toshokanneko , it's called on sign in only
Sometimes a firebase token can get invalidated, and later needs to be re-subscribed to.
Not sure how we track the state of browser notifications, but if we know they should be enabled, and the get call for the token call fails, re-run the call to add it back.
If we don't store anything else to tell that we should have notifications on, we can start storing for new ones in localstorage maybe?