Skip to content

Comments

Syncs board after a period of inactivity#278

Merged
dahlbyk merged 20 commits intomasterfrom
discorick/refreshing_stale_issues
May 3, 2016
Merged

Syncs board after a period of inactivity#278
dahlbyk merged 20 commits intomasterfrom
discorick/refreshing_stale_issues

Conversation

@discorick
Copy link
Member

@discorick discorick commented Apr 20, 2016

Syncs the boards issues after a period of inactivity (currently 1 hour)

  • Implements a clientside BrowserSessionService which currently tracks browser focus and blurs and events on them using Ember.Evented, this is injected into all controllers and components
  • Implements BoardSyncService which currently can sync the boards issues

TODO:

  • Implement an Ember route to force a sync (good for testing)
    • Example: https://huboard.com/huboard/huboard#/sync-issues
  • Test on Firefox
  • Test on IE (on windows 10 huboard is broken :( )
  • Test on Chrome

Implement failure handlers (i.e issue count >= 100) I Don't think this is going to be necessary with highly frequent syncs
If the logged in validation fails, throw unauthorized (maybe a seperate PR)

Should Fix #226 & alleviate huboard/huboard#214

@dahlbyk dahlbyk temporarily deployed to huboard-rails-pr-278 April 20, 2016 18:04 Inactive
config/routes.rb Outdated


namespace :api do
get 'logged_in' => 'api#logged_in'
Copy link
Member

Choose a reason for hiding this comment

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

NIT: _ in a URL are 👎 prefer -

Copy link
Member Author

Choose a reason for hiding this comment

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

Is that a common convention (honest question) ? Easy change to make

Copy link
Member

Choose a reason for hiding this comment

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

yeah, it is for me. It goes back a pretty long ways to HTML webpage dev days - imagine http://www.bob.com/this_is_awesome where the default link underlining is in play

image

vs

image

Copy link
Member

Choose a reason for hiding this comment

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

Also this url is a query, for a pure RESTafarian- 💩 head - should it be ~/session?exist kind of thing? again, this is purely surface stuff.

@dahlbyk dahlbyk temporarily deployed to huboard-rails-pr-278 April 20, 2016 21:50 Inactive
flashMessages: Ember.inject.service(),
syncFlashNotifier: function(){
if(this.get('syncInProgress')){
this.get('flashMessages').add(this.messageData);
Copy link
Member Author

Choose a reason for hiding this comment

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

It occurs to me that this.messageData should be cloned lest we modify the original messageData object later.

@discorick discorick force-pushed the discorick/refreshing_stale_issues branch from de2f10f to 224d420 Compare April 21, 2016 17:45
@dahlbyk dahlbyk temporarily deployed to huboard-rails-pr-278 April 21, 2016 17:45 Inactive
var since = new Date(new Date().getTime() - _self.browserCheckInterval);
this.validateCredentials().success((response)=>{
_self.get('boardSyncing').syncIssues(_self.get('model.board'), {since: since.toISOString()});
}).fail((error)=>{
Copy link
Member

Choose a reason for hiding this comment

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

Rather than separately/explicitly check if the user is logged in here, it seems like we should just handle a 403 when we attempt to fetch latest. More generally, could we use jQuery.ajaxSetup (or a more Ember-y equivalent?) to do something like:

$.ajaxSetup({
  statusCode: {
    403: function() {
      alert( "Access denied! Do you need to [login|grant private access]?" );
    },
    500: function() {
      alert( "Oh noes, something went wrong! Try again?" );
    }
  }
});

(With better UX than alerts, of course.)

Copy link
Member Author

Choose a reason for hiding this comment

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

We already have a global ajax handler picking up failed requests and transition to a "unauthorized" modal. User login may be the wrong criteria, I honestly didn't think that part of it through too much.

I would like to avoid using ajax catch-alls as much as possible, I see this feature as a way to "latch" on focus and fail before any unauthorized tasks are performed to begin with.

Copy link
Member

Choose a reason for hiding this comment

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

I see this feature as a way to "latch" on focus and fail before any unauthorized tasks are performed to begin with.

I'm not sure what that actually gains us, though. Server-side, we're checking logged_in? in either case, we just have to make two requests if we have an explicit login check.

I'm curious what scenarios we have (or might have) in the app that would require different experiences when a 403 or 500 are encountered?

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'm curious what scenarios we have (or might have) in the app that would require different experiences when a 403 or 500 are encountered?

Not entirely clear on the question. A session token can get stale, in which case all actions on the board will cause 403's. We handle this with the unauthorized modal right now, but it would be nice to let users know they need to "relogin" before they attempt to even do something that will fail

Copy link
Member

Choose a reason for hiding this comment

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

Right. My question is: is there any situation in the app where we wouldn't want to handle a 403 with a unified UX to give a chance to restore authorization?

@dahlbyk
Copy link
Member

dahlbyk commented Apr 21, 2016

Grey out board during sync ?

Is there some way to make it read-only?

@discorick
Copy link
Member Author

Grey out board during sync ?

Is there some way to make it read-only?

We have a CSS overlay (like on issue fullscreen) that I think would be a good touch.

@dahlbyk
Copy link
Member

dahlbyk commented Apr 21, 2016

Grey out board during sync ?

Is there some way to make it read-only?

We have a CSS overlay (like on issue fullscreen) that I think would be a good touch.

Well I was thinking read-only but otherwise functional. Let me click on issues to see detail (and edit from there, since we always* hit GitHub for latest), but don't let me rearrange stuff in column view.

* right?

@discorick
Copy link
Member Author

  • right?

Only in partial, see: #90 (I need to rewrite this to take advantage of #276 which should actually let us start keeping issues completely in-sync)

Let me click on issues to see detail (and edit ...

I am nervous about pushing the limits of the Ember run loop here. If you happen to make an edit on an issue that is being synced within the bounds of the same run loop, Ember will throw either a deprecation or possibly worse an exception.

@discorick discorick temporarily deployed to huboard-rails-pr-278 April 21, 2016 20:02 Inactive
@dahlbyk
Copy link
Member

dahlbyk commented Apr 22, 2016

If you happen to make an edit on an issue that is being synced within the bounds of the same run loop, Ember will throw either a deprecation or possibly worse an exception.

Hrm... would we be able to compare last-modified timestamps before actually updating an issue from the sync payload? Strictly speaking, the same condition seems possible from an incoming event while the sync is happening.

I'm content with completely disabling the board while syncing, but I do think it would be preferable for the sync to less intrusive. My 2¢.

@discorick discorick temporarily deployed to huboard-rails-pr-278 April 22, 2016 15:38 Inactive
@discorick discorick temporarily deployed to huboard-rails-pr-278 April 22, 2016 16:47 Inactive
@discorick
Copy link
Member Author

discorick commented Apr 22, 2016

After 30 Seconds of no focus:

issue syncing 30 second throttle

On Error:
issue syncing fail

Bulk Issue Move (makes me happy):
bulk issue move on sync

@discorick discorick temporarily deployed to huboard-rails-pr-278 April 22, 2016 19:45 Inactive
@dahlbyk
Copy link
Member

dahlbyk commented Apr 22, 2016

May just be me, but the sync message is almost too distracting. Once you know there's a sync process, the notification really isn't worth drawing the eye as much as the purple box does. Maybe...

sync-notification

@discorick
Copy link
Member Author

discorick commented Apr 22, 2016

I am not sure, thats an interesting thought... Probably outside the scope of this PR though (its flash message styling)?

EDIT: @cwramsey seems to like the subtle sync message better as well.

@dahlbyk
Copy link
Member

dahlbyk commented Apr 22, 2016

Probably outside the scope of this PR though (its flash message styling)?

Eh, I would rather see the change here if there is agreement that subtler is better.

@drusellers
Copy link
Member

May just be me, but the sync message is almost too distracting. Once you know there's a sync process, the notification really isn't worth drawing the eye as much as the purple box does.

👍

@discorick discorick temporarily deployed to huboard-rails-pr-278 April 23, 2016 00:19 Inactive
@discorick
Copy link
Member Author

@dahlbyk @cwramsey @drusellers what do you think?

subtle issue syncing style

@cwramsey
Copy link

It does look better, but I think just setting the background to transparent and nullifying any border attributes would get it out of the way even more. You could even set the X button to opacity: 0; though maybe not in case the sync somehow takes forever if github is not being very fast.

@dahlbyk dahlbyk temporarily deployed to huboard-rails-pr-278 April 25, 2016 02:05 Inactive
@dahlbyk
Copy link
Member

dahlbyk commented Apr 25, 2016

@discorick did raise a good point that simple transparency won't work when the board has been scrolled (at least until we're able to fix the header):
sync-notification2

I just pushed up a commit to try out using a semi-transparent drop shadow that matches the background:
sync-notification3

But not sure if the shadow is really necessary?

I also noticed that the header has a subtle gradient from F3F3F3 to F9F9F9, which makes the non-transparent background not an exact match. I'm wondering if such a subtle gradient is worth keeping altogether?

@discorick
Copy link
Member Author

I can live with no shadow, the reason I left it is like you mentioned - the gradient on the navbar makes it look funny without any additional definition.

@discorick
Copy link
Member Author

discorick commented Apr 25, 2016

Before we merge this, I have been thinking about thresholds over which a sync would be impractical and a "refresh" recommended toast should be sent. Does 24 hours of no board focus seem reasonable?

@discorick discorick temporarily deployed to huboard-rails-pr-278 April 25, 2016 19:34 Inactive
@discorick discorick changed the title [WIP] Syncs board after a period of inactivity Syncs board after a period of inactivity Apr 25, 2016
@cwramsey
Copy link

@discorick imo, 24 hours seems like a lot. I'd set it at like 2 hours maybe. I don't have any proof as to why that's better, but a lot can happen in that timeframe and if it's not automatically caught up (like if the connection is lost after sleeping your computer or something) a sync would be good then.

@discorick
Copy link
Member Author

@cwramsey the 24 hour interval is for forced refresh, thats the point where we say "sorry you need to hit the refresh button now"

@cwramsey
Copy link

var flash = this.get('flashMessages.queue').find((flash)=>{
return flash.identifier === 'sync-message';
});
Ember.set(flash.progress, 'status', false);
Copy link
Member

Choose a reason for hiding this comment

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

Is there any need to guard against flash being null here?

@dahlbyk dahlbyk merged commit 115ead2 into master May 3, 2016
@dahlbyk dahlbyk deleted the discorick/refreshing_stale_issues branch May 3, 2016 20:38
@dahlbyk dahlbyk mentioned this pull request May 13, 2016
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.

4 participants