Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement focusing on a group #2554
Conversation
seanh
added some commits
Sep 28, 2015
seanh
added
the
WIP
label
Sep 28, 2015
seanh
self-assigned this
Sep 28, 2015
seanh
reviewed
Sep 28, 2015
| function loadAnnotations(annotations) { | ||
| var loaded = []; | ||
| received = received.concat(annotations); |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
seanh
Sep 28, 2015
Contributor
This assumes that the same annotation never gets passed to loadAnnotations() twice, which may not be true. received may need to become a set, or a dict keyed by annotation id, or something,
seanh
Sep 28, 2015
Contributor
This assumes that the same annotation never gets passed to loadAnnotations() twice, which may not be true. received may need to become a set, or a dict keyed by annotation id, or something,
seanh
reviewed
Sep 28, 2015
| var received = []; | ||
| // The annotations that are currently loaded into the page context. | ||
| var loaded = []; |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
seanh
Sep 28, 2015
Contributor
We could maybe avoid having to keep track of this list here, by just getting it from threading. I sort of feel like it's annotationMapper's job to keep track of this though, and threading is just a dump.
seanh
Sep 28, 2015
Contributor
We could maybe avoid having to keep track of this list here, by just getting it from threading. I sort of feel like it's annotationMapper's job to keep track of this though, and threading is just a dump.
seanh
reviewed
Sep 28, 2015
| loadAnnotationsFromGroup(annotations, groups.focused().id); | ||
| } | ||
| function loadAnnotationsFromGroup(annotations, groupId) { |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
seanh
Sep 28, 2015
Contributor
Loads the given annotations into the page context, but only the ones from the given group. Docstring needed.
seanh
Sep 28, 2015
Contributor
Loads the given annotations into the page context, but only the ones from the given group. Docstring needed.
seanh
reviewed
Sep 28, 2015
| annotations.slice().forEach(function(annotation) { | ||
| loaded.splice(loaded.indexOf(annotation, 1)); | ||
| }); |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
seanh
Sep 28, 2015
Contributor
This crazy dance is because when our $rootScope.$on('groupFocused', ... above calls unloadAnnotations(), the passed annotations array is the loaded array, and you can't modify an array while you iterate over it in JavaScript, so we need to iterate over a copy of it.
seanh
Sep 28, 2015
Contributor
This crazy dance is because when our $rootScope.$on('groupFocused', ... above calls unloadAnnotations(), the passed annotations array is the loaded array, and you can't modify an array while you iterate over it in JavaScript, so we need to iterate over a copy of it.
seanh
reviewed
Sep 28, 2015
| }, | ||
| thread: function(id) { | ||
| return threading.idTable[id]; | ||
| } |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
seanh
Sep 28, 2015
Contributor
Getting a TypeError: Cannot read property 'children' of undefined in the console when switching back and forth between groups, from threading.annotationDeleted()
|
Getting a |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
seanh
Sep 28, 2015
Contributor
Getting a TypeError: Cannot read property 'children' of undefined in the console when switching back and forth between groups, from threading.annotationDeleted()
You have to sign out the sign in then switch back and forth between groups, to get this
You have to sign out the sign in then switch back and forth between groups, to get this |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
seanh
Sep 28, 2015
Contributor
Getting a TypeError: Cannot read property 'children' of undefined in the console when switching back and forth between groups, from threading.annotationDeleted()
You have to sign out the sign in then switch back and forth between groups, to get this
Fixed this, but there's still a problem that the numbers in the bucket bar get all wrong, if you sign out then sign in again then switch between groups multiple times
Fixed this, but there's still a problem that the numbers in the bucket bar get all wrong, if you sign out then sign in again then switch between groups multiple times |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
nickstenning
Sep 30, 2015
Contributor
So I've had a quick look at this and I think we're going to get ourselves into all sorts of confusion if we try and maintain all the state in the client.
For now, there's a much simpler (if marginally less efficient) way to do this. Have a look at this branch. It is by no means perfect, and has some of the same issues as this one (we need to forcibly switch to the public group on logout, for example), but requires substantially fewer changes to the code. The only downside is that we're reloading annotations from the server every time we change focus, but I think we can optimize that later.
|
So I've had a quick look at this and I think we're going to get ourselves into all sorts of confusion if we try and maintain all the state in the client. For now, there's a much simpler (if marginally less efficient) way to do this. Have a look at this branch. It is by no means perfect, and has some of the same issues as this one (we need to forcibly switch to the public group on logout, for example), but requires substantially fewer changes to the code. The only downside is that we're reloading annotations from the server every time we change focus, but I think we can optimize that later. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
nickstenning
Sep 30, 2015
Contributor
I'd be happy to pair on this with you at some point tomorrow, @seanh?
|
I'd be happy to pair on this with you at some point tomorrow, @seanh? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@nickstenning I'm free now, but can also pair tomorrow if you want |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Closing in favour of #2566 |
seanh commentedSep 28, 2015