loading...

Discussion

markdown guide
 

Got it working.

I went to here
forem.com/valid_forems.json
Then suddenly it appeared on all my sites

EDIT: This was a red herring the bar appeared after the data was loaded, it just so happened I was on that page when it did.

hacker arms

 

So it took you visiting that endpoint manually before it worked? πŸ€”

 

Did someone ask for an error?

Error handling response: TypeError: Cannot read property 'map' of undefined
    at myOrigins (chrome-extension://cobicbhlbogbkdcmgdhejghphaiofodb/content/content.js:204:19)
    at chrome-extension://cobicbhlbogbkdcmgdhejghphaiofodb/content/content.js:14:5

I think I see it

chrome.storage.sync.get(['subscribedForems', 'allforems'], function (result) {
  const myForems = result.subscribedForems;
  const allForems = result.allforems;
  if (!myForems) {
    chrome.storage.sync.set({ subscribedForems: [] }); // Create empty array if not initialized.
  }
  if (!allForems) {
    chrome.storage.sync.set({ allforems: [] }); // Create empty array if not initialized.
  }
  // myOrigins(null) will break map on line 203
  if (
    myOrigins(myForems).includes(currentOrigin) ||
    validOrigins(allForems).includes(currentOrigin) ||
    currentOrigin === 'https://www.forem.com'
  ) {
    loadForemHTML(result.subscribedForems);
    document.addEventListener('add', handleAdd, false);
    document.addEventListener('remove', handleRemove, false);
    document.addEventListener('reorder', handleReorder, false);
  }

This would remove the error though I've not thought the logic through yet

function myOrigins(myForems) {
  if(!myForems) return;
  return myForems.map(function (f) {
    return f.homePageUrl;
  });
}

Another fix.

chrome.storage.sync.get(['subscribedForems', 'allforems'], function (result) {
  const myForems = result.subscribedForems ? result.subscribedForems : [];
  const allForems = result.allforems ? result.allforems : [];
  if (!result.subscribedForems) {
    chrome.storage.sync.set({ subscribedForems: [] }); // Create empty array if not initialized.
  }
  if (!result.allforems) {
    chrome.storage.sync.set({ allforems: [] }); // Create empty array if not initialized.
  }
  if (
    myOrigins(myForems).includes(currentOrigin) ||
    validOrigins(allForems).includes(currentOrigin) ||
    currentOrigin === 'https://www.forem.com'
  ) {
    loadForemHTML(result.subscribedForems);
    document.addEventListener('add', handleAdd, false);
    document.addEventListener('remove', handleRemove, false);
    document.addEventListener('reorder', handleReorder, false);
  }
 

Yes I went there manually, when I started looking though the code and saw the bars existed in Dev and Forem suddenly.

 

That worked for me too in Chrome.

 

Then suddenly it appeared on all my sites

And is that all your sites like alll your sites or just Forems?

 

Using mac + chrome

I eventually got it to work by uninstalling the old version, reinstalling the source and hard refreshing the pages.

I think I also managed to get it into an unusable state. This is how it may be reproduced:

  • Have no forems in the switcher
  • Go to the extension "home" (forem.com/discover)
  • Now add this "forem" to your sidebar, you can because the plus sign allows it.
  • Reload and you should get this error
Error handling response: TypeError: Cannot read property 'homePageUrl' of null
    at chrome-extension://kbbmmajekblbmamcpkopjkmihmddkpof/content/content.js:207:14
    at Array.map (<anonymous>)
    at myOrigins (chrome-extension://kbbmmajekblbmamcpkopjkmihmddkpof/content/content.js:206:19)
    at chrome-extension://kbbmmajekblbmamcpkopjkmihmddkpof/content/content.js:14:18
 

I tried. Followed instructions to install the extension from a folder. Nothing happens when I load up a forem or when I click on the forem extension. Should a forem load in the extension automatically?

 

It should load automatically, but unsure why it would and wouldn't happen?

 

It seems to work perfectly fine for me!πŸ™Œ

 

I tried a few minutes and it didn't work for me in Chrome. :(

 
 

Nope. I went to forem.com. First, it redirected me to forem.com/discover/ then nothing happened.

 

I re-installed it and Hard Refreshed DEV and now it works on both Chrome and Edge!