blenderskool / untab

🔍 A productivity tool to boost your browser workflow!
https://getuntab.now.sh
MIT License
345 stars 27 forks source link

Complete Firefox support, Changes in Data passing 🎉 #47

Closed blenderskool closed 3 years ago

blenderskool commented 3 years ago

Complete Firefox support

UnTab is a tool to improve browser productivity and since its creation, browser compatibility has always been in mind during its development. UnTab is now fully supported on Firefox alongside Chrome! On the technical side, the codebase has shifted to using webextension-polyfill which not only provides a more modern browser API for the extension development but is also compatible with both Firefox and Chrome. It has simplified some parts of the codebase which were starting to become confusing due to callbacks!

Plugin API improvements

From the release of version 0.1.0, a sendResponse callback was passed as an argument in the handler method of plugins. This function was used to pass back some data to the UnTab interface. This function was mandatory to be called in every plugin and I had mentioned that this behavior would soon be improved.

I'm glad to share that the sendResponse callback method is no longer passed :stuck_out_tongue:. Its functionality can now be achieved by simply returning the data from the handler method :tada:

Example of how this change works: Before: with sendResponse

{
  ...
    async handler({ theme }, sendResponse) {
      await browser.storage.local.set({ theme });
      sendResponse({ theme, autoClose: false });
    }
  ...
}

Now: without sendResponse

{
  ...
    async handler({ theme }) {
      await browser.storage.local.set({ theme });
      return { theme, autoClose: false };
    }
  ...
}

This change makes the Plugin API easier to understand without thinking in terms of callbacks. NOTE: The example shows an async method but the change is also compatible with non-async functions.

Changes in data passing

Communication between the UnTab interface and the background script were done in two ways:

sendMessage was used to exchange data about the selected items from the UnTab interface. While it worked the way it was meant to, it had some quirks with respect to asynchronous handlers and how the response data was being passed. This has now been refactored to use ports for communication.

Loading indicator

UnTab now shows a loading indicator when the search takes more than 500ms. Only in some rare cases, the search takes a long time(which is mostly observed during the initial boot of the browser) which is when the loading indicator is shown.