Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add share feature #921

Merged
merged 2 commits into from
Nov 16, 2017
Merged

Add share feature #921

merged 2 commits into from
Nov 16, 2017

Conversation

groovecoder
Copy link
Member

@groovecoder groovecoder commented Oct 26, 2017

image

To spot-check ...

  1. Install this version of XPI
  2. Open 5 container tabs (will bump to 100 for release)
  3. You should see a green "NEW" badge on the browserAction icon.
  4. When you click it, you should see the "achievement panel" with links to rate, share, tweet, and done.

browser.storage.local.set({[key]: countOfContainerTabsOpened});

// When the user opens their _ tab, give them the achievement
if (countOfContainerTabsOpened === 5) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NEED TO BUMP THIS TO 500 BEFORE MERGE!

}
},

async setAchievementDone(achievementName) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to figure out better logic here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the logic. This is ready to review and spot-check now, @jonathanKingston

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So done means "read" essentially? It's a little confusing in name between getting the achievement and marking it done.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Essentially ... I put "Done" on the button because the user has to actually click it to clear the achievement. (Hopefully after they rate/tweet/share) So "Done" means whatever the user chooses to do: just read it, or read + rate, or read + share, etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll probably keep the name; setAchievementRead would imply that the user only has to see the achievement for it to go away.

@groovecoder groovecoder force-pushed the add-share-feature branch 3 times, most recently from 2662f9c to 6287bb1 Compare October 27, 2017 19:16
@TanviHacks
Copy link

Lets make it 100 container tabs when this hits release users.

@TanviHacks
Copy link

Also, how are we counting? Any tab with a usercontextId!=0? There are many entrypoints for opening container tabs, so better to count the tabs than the entrypoints.

@groovecoder
Copy link
Member Author

It's counting any container tab opened by any of the entry points when the user context is not firefox-default or firefox-private.

@@ -120,6 +128,29 @@ const messageHandler = {
});
},

async incrementCountOfContainerTabsOpened() {
const key = "containerTabsOpened";
const count = await browser.storage.local.get(key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use get({[key]: 1}) right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the presence checking below etc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

// Don't count firefox-default, firefox-private, nor our own confirm page loads
if (tab.cookieStoreId !== "firefox-default" &&
tab.cookieStoreId !== "firefox-private" &&
tab.url.indexOf("confirm-page.html") === -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check instead for moz-extension protocol instead perhaps?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@groovecoder groovecoder force-pushed the add-share-feature branch 2 times, most recently from e8f38ab to 6c59ac1 Compare October 31, 2017 16:16
@jonathanKingston
Copy link
Contributor

I left two comments which would be cool if we could fix those to be a little simpler. If you could add a comment explaining when achievements are gathered and "done" too just for future when we forget.

Other than that everything looks fine, I haven't tested at the moment though.

@groovecoder
Copy link
Member Author

Updated. @SoftVision-EmilPasca - it's a tedious task, but could you test this branch that the achievement panel shows in the pop-up after opening 100 container tabs? (Easiest way is probably to assign a site to automatically open in a container, "Remember my decision", and then just open tabs to that site very quickly.)

@SoftVision-EmilPasca
Copy link

@groovecoder I have made a build from add-share-feature branch and tested on Windows 10 x64, Mac 10.12 and Ubuntu 14.04 with the latest Firefox release (56.0.2), the latest Nightly (58.0a1-20171030103605) and latest Beta(57.0b13-20171030163911).

I have tried different scenarios in which I've created 100 container tabs or more using combinations of custom and default containers, hidden container tabs, non-container tabs, using multiple windows, private windows, different sessions or disabling/enabling the add-on and restarting the browser.

During testing I've observed that the "achievement panel" is successfully shown regardless of the scenarios above if a number of 100 container tabs have been reached by the user.
Also the "Rate", "Share" and "Tweet" buttons correctly redirects to the desired pages and the "Done" button correctly closes the "achievement panel" when pressed.

If you think there are any more scenarios which I haven't covered, please let me know.

@groovecoder
Copy link
Member Author

That's great, thanks @SoftVision-EmilPasca !

@groovecoder
Copy link
Member Author

@jonathanKingston can I get an r+ here now?

@jonathanKingston
Copy link
Contributor

Out of interest why are we using shortened urls for the sharing links?
Eg:
https://bit.ly/fb-share-mac-addon

Also these have a mac utm in their source?

  • If we are worried about length of HTML lines we can solve that with vars or something else
  • If we are worried about utm's being exposed when the user hovers over the URL, I would rather be genuine and show it all (I didn't actually test if hovering shows as it normally does)

... more to come end of train ride.

@groovecoder
Copy link
Member Author

Yeah, I'm not super-happy with it. But the utm params didn't seem to work when I put them straight into the url. But I'll try a couple encoding tricks to avoid short urls if at all possible.

@jonathanKingston
Copy link
Contributor

1.

Yeah, I'm not super-happy with it. But the utm params didn't seem to work when I put them straight into the url.

Hmm that is odd, anyway can we change the "mac" part, unless there is an explanation for it?
Perhaps it is the tweet text having spaces, you could pass it through the method we have that uses encodeUriComponent and some other changes (that covers weird edge cases that impact extensions)?

The code is in the assignManager, feel free to take the output and hard code it into the HTML

  encodeURLProperty(url) {
    return encodeURIComponent(url).replace(/[!'()*]/g, (c) => {
      const charCode = c.charCodeAt(0).toString(16);
      return `%${charCode}`;
    });
},

2.
Also we can now do async arrows: async () => { feel free to fix this or ignore (we can file a follow up to fix it all instead).

3.
Can you change tab.url.indexOf("moz-extension") === -1 with !tab.url.startsWith("moz-extension") as it prevents any edge case URLs that contain that in a param for some bizarre reason.

4.
Don't we have the following as a function call anyway?

+      browser.storage.local.set({achievements});
+      browser.browserAction.setBadgeBackgroundColor({color: "rgba(0,217,0,255)"});
+      browser.browserAction.setBadgeText({text: "NEW"});

5.
Are "webextension/img/fb-icon.png" and "webextension/img/twitter-icon.png" open source? Also is there a SVG version instead?

6.
const countOfContainerTabsOpened = count[key] += 1; to me implies you need to increment count too, which from what I can see you don't.

I would use: const countOfContainerTabsOpened = ++count[key];
or just reference count[key]:

count[key] += 1;
browser.storage.local.set({[key]: count[key]});

Other than that we are all good, feel free to merge after these 6.
None are blockers if you want to make them follow ups, although likely 1. utm code can't change after releasing to users.

@groovecoder
Copy link
Member Author

  1. The 'mac' part in this case means "Multi-Account Containers" - not Mac OS.

  2. Let's do a follow-up enhancement for async arrow functions

  3. fixed

  4. There's a badge.displayBrowserActionBadge function, but it would need refactoring to be useful here and in popup.js. Probably another follow-up/fix-up?

  5. Switched to CC-Attrib SVG icons

  6. Updated/fixed.

@TanviHacks
Copy link

What happens if a user clicks "Tweet". Is the tweet content pre-populated for them to share or manually edit?

@groovecoder
Copy link
Member Author

It's pre-populated but the user can change/update the text if they want.

Copy link
Contributor

@jonathanKingston jonathanKingston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :) if you could file those follow ups that would be great. Should be possible to mark them as good first bug too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants