side bar behaviour

  • there are couple of thing that I've stumble upon doing ext for SB
    First one is some sort of race condition between firing freshly installed extension and chrome.runtime.onInstalled.addListener
    If extension needs to set first default data to localStorage (chrome.storage) it will create error, because there is no time for SB panel to read it (I'm listening onInstalled in bg script)
    I don't have much of experience with browserAction (popup) extensions, maybe this is some common thing and easy to solve. I had to put check up on every start to see if there is something in storage, otherwise ext get bugged

    Second, if user opens two (or more) windows with SB, extension data (whatever that is) is kept in old state. Eg. if I open side bar, do something in my extension, and then I create new window (SB is automatically opened with it), and change extension data somehow, extension in first window side bar is not updated. So when I go back to it, SB extension is showing me old data.
    This could create errors (or worst) if user tries to change old data.
    I can listen for win focus change, and update ext. data, but that creates update in all extension views (in every SB of every window opened) or annoying refreshing on every focusing of window with SB (even if it's just one browser window)
    Is there any better logic for those situations?
    maybe some internal algorithm (in development) that will take care of it ?

  • The behavior here is intended. Not every extension would need such live syncing and for many of them it's even unwelcomed. It's much easier for developers to make an extension that does the syncing on its own then workaround it (assuming that the syncing would be embedded). How to cope with the problem depends on what your extension does and what you want to achieve. In some cases changing an architecture to multi-transactional may be sufficient. However, in most (or even all) cases using message mechanism and background page as an arbiter will do the trick. It's hard to give you precise advice with limited knowledge of your extension functionality however. In the next version we plan to add onFocus/onBlur events (it may be helpful in some cases too) but much more reliable solution still seems to be sending messages to the background page.

  • I'm sorry, I didn't saw this post until now (didn't get notification)
    In latest dev (30) I'm not sure if my problem with windows is still there...maybe something is changed
    Honestly, didn't have much time to test that particular extension (tabs in sidebar) because of work on other ext's.
    I'm starting to work on it again (paused for week or so), and if I stumble on something I'll write it here...

    But the first issue is giving me more headache...race between chrome.runtime.onInstalled and fist firing of ext after installation
    there is no time to set default data
    I used msg in callback chrome.storage.local.set to refresh the extension after the data is set, but I'm not sure how smart is that

  • I see that in latest dev 30.0.1820.0 there is no more auto start SB extension after install 🆙

Log in to reply
 

Looks like your connection to Opera forums was lost, please wait while we try to reconnect.