Commit graph

1094 commits

Author SHA1 Message Date
lilia
2243c09fea MessageReceiver is an event target
Rather than asking for a global target, the message receiver implements
the EventTarget interface itself. It does not expose the dispatchEvent
method, however. This ensures that events can only be triggered from
within the internal MessageReceiver class, which means we no longer need
to namespace them.

// FREEBIE
2015-09-18 09:30:12 -07:00
lilia
a925027cd2 Refactor MessageReceiver for storage/server independence
Let the libtextsecure consumer pass in their own server url, username,
password, and signaling key, as with libtextsecure-java.

Also brings reconnect logic up into the MessageReceiver class, which
is the only place it should apply.
2015-09-17 16:52:32 -07:00
lilia
e59a5792d5 Don't hardcode the attachment host 2015-09-17 16:02:22 -07:00
lilia
184e37383c Don't auto-populate the relay field
According to server api docs, relay is optional when it is the same as
our own server.

// FREEBIE
2015-09-17 16:02:22 -07:00
lilia
7d9cf0c167 Pass the signaling key into decryptWebSocketMessage
De-couple this file from dependency on storage.
2015-09-17 16:02:22 -07:00
lilia
c167fc964d Revert "Remove global updateInbox method"
This reverts commit 1c70293bba.

This broke tests by blocking the database deletion during test
setup.
2015-09-17 15:42:13 -07:00
lilia
310f40fcad Contact sync should update existing contacts
// FREEBIE
2015-09-17 14:26:25 -07:00
lilia
7f4ef6e9e7 Remove double-check of unread count
This same condition is already enforced in the markRead method.

// FREEBIE
2015-09-17 13:46:58 -07:00
lilia
1c70293bba Remove global updateInbox method
This operation now needs to be done exactly once, at startup, so we
don't need to expose a global method for it.

// FREEBIE
2015-09-17 13:44:44 -07:00
lilia
6364cda7cb Create requires an object
// FREEBIE
2015-09-17 11:42:59 -07:00
lilia
78d7296f84 Fix tests
// FREEBIE
2015-09-17 11:40:42 -07:00
lilia
b617240338 Stop calling updateInbox all the time
Now that the inbox collection keeps itself in sync, we don't have the
data duplication that was forcing us to reload constantly.

// FREEBIE
2015-09-17 10:57:17 -07:00
lilia
537f0ceef0 Log all http requests at start and end
// FREEBIE
2015-09-17 10:57:17 -07:00
lilia
0017f196ef Move ConversationController to its own file
Encapsulate the global conversation cache collection against accidental
access, avoiding the data-clobbering bug fixed in previous commit.

Also move some one-off program initialization code from panel controller
to background.js

// FREEBIE
2015-09-16 23:43:14 -07:00
lilia
8f28c3af68 Fix disappearing contact info
This errant reference to the global cache of conversations was causing
some contacts to get clobbered.

// FREEBIE
2015-09-16 22:47:42 -07:00
lilia
93a5d01127 Delete old code
We don't have any more 'default' css classes. Default avatar data is
simply provided by a model for rendering in a view.

// FREEBIE
2015-09-16 22:19:04 -07:00
lilia
2bc65c2ab4 Let messages fetch references to senders
The conversation's contactCollection only contains references to the
current membership, and will not provide contact info for people who
have left the group, causing their messages to render without numbers or
avatars.

// FREEBIE
2015-09-16 22:15:47 -07:00
lilia
fd29ac8d2c Promote groups to top of inbox when we update them
// FREEBIE
2015-09-16 18:01:39 -07:00
lilia
73983118dc Render emoji in conversation title // Fixes #359
// FREEBIE
2015-09-16 16:40:11 -07:00
lilia
6f94888659 Use online event listener to reconnect more smrtly
No need to retry if we know we're offline.

// FREEBIE
2015-09-16 15:16:39 -07:00
lilia
37998e261d Log more errors
// FREEBIE
2015-09-16 14:41:20 -07:00
lilia
36ec4300cf Fix broken group avatar preview
Fixes #355

// FREEBIE
2015-09-16 12:29:16 -07:00
lilia
b60d3d0b97 Make debug log handle multiple arguments
Ex: console.log('delivery receipt', phone_number, timestamp)

// FREEBIE
2015-09-16 11:29:01 -07:00
lilia
90e9216e19 Add UI for submitting debug logs
Fixes #343

// FREEBIE
2015-09-16 11:28:37 -07:00
lilia
9809894fd2 Automatically mark the open conversation read
If a conversation view is visible, it will automatically mark the
conversation read.

// FREEBIE
2015-09-15 20:50:00 -07:00
lilia
15a366dbf0 Opening a conversation should focus the window
Previously, this function might open the conversation but not show the
window, if it exists but wasn't on top.

// FREEBIE
2015-09-15 20:41:48 -07:00
lilia
a57451d00b Show notifications if the window is minimized
// FREEBIE
2015-09-15 20:30:45 -07:00
lilia
f74a7b9621 Add code for submitting debug logs
We keep the last 1000 log messages in memory and dump them to an
anonymous public gist if console.post is called.

// FREEBIE
2015-09-15 18:48:50 -07:00
lilia
fa0e2584f4 Fix new threads not appearing at top of inbox
When messages from someone not in your inbox arrived, that thread would
appear at the bottom of the inbox instead of the top.

// FREEBIE
2015-09-15 16:45:52 -07:00
lilia
df99da15c6 Mark relevant convos active/unread on key conflict
// FREEBIE
2015-09-15 14:40:37 -07:00
lilia
15d84199c2 Include ourselves in member list for a new group
Otherwise, the next incoming group update will show "<your number>
joined the group".

// FREEBIE
2015-09-15 13:58:17 -07:00
lilia
8b27c99f2b Fix exception while creating a conversation
When confirming the creation of a one on one conversation with a new
contact, the first click would do nothing but the second click would
work. Now the first click works.

Fix by only reject new conversation creation if not saved.

// FREEBIE
2015-09-15 13:24:09 -07:00
lilia
4b0c70fb44 Resolve multiple conflicts independently
When resolving multiple conflicts in a conversation, failure to resolve
one should not block any others.

// FREEBIE
2015-09-15 11:12:47 -07:00
lilia
f8745e1e5b Remove inactive models from inbox collection
Fixes auto archive when deleting all messages, and auto unarchive when
sending a new message. Previously, the convo would not reappear in the
inbox after deleting all messages.

// FREEBIE
2015-09-14 17:37:49 -07:00
lilia
80764bf494 Remove unused function
// FREEBIE
2015-09-14 16:56:01 -07:00
lilia
a390e37abc Fixup change:active_at handling when setting null
When a conversation goes from active to not active, it should be removed
the view rather than promoted.

// FREEBIE
2015-09-14 16:29:03 -07:00
lilia
b81d93177a Fix double selected states
Previously, when changing selection from an unread to a read
conversation, the unread conversation would not be deselected.

// FREEBIE
2015-09-14 15:31:29 -07:00
lilia
50add90fd9 Include image previews in notifications
// FREEBIE
2015-09-14 14:02:05 -07:00
lilia
d89e3ccdc4 Don't fetch messages from the background
Only fetch them from a frontend view. If the conversation is not open,
we don't need to load the messages, and if we do load them, they will
render before we've done the initial contact info loading (as
implemented in 74e96ce).

Fixes #344

// FREEBIE
2015-09-14 13:49:20 -07:00
lilia
bd5f43bdb1 Avoid excessive re-rendering of the inbox list
This listener is doing way more work than necessary to update the dom by
removing all the list items and re-creating them. This also causes the
bug where selected state is cleared when new messages arrive, not to
mention binding new event listeners without unbinding the old ones.

Fix by simply promoting an element to the top of the list when it's
active_at value changes, rather than re-rendering the whole list. This
could backfire if the value gets changed to an earlier timestamp but for
now we assume that won't happen.

// FREEBIE
2015-09-14 13:49:20 -07:00
lilia
e80fa187ba Upsize svg identicons
The chrome.notifications api renders iconUrls at full bleed, as opposed
to the Web Notifications api, which adds padding. This was causing our
identicons to look a bit over stretched.

Fixed by rendering them a bit larger and with some padding.

// FREEBIE
2015-09-14 13:49:19 -07:00
lilia
1a30d003f5 Fetch group contacts before fetching new messages
Messages must wait for sender info to arrive before rendering.

// FREEBIE
2015-09-14 13:49:09 -07:00
lilia
edbf2371bf Don't reset inboxWindowId
// FREEBIE
2015-09-14 11:12:08 -07:00
lilia
e8edbe53bc Improve notification behavior
Only allow one notification at a time. Use a basic notification for
normal messages, and image notification for image messages, and a list
notification when there are multiple unread messages.

// FREEBIE
2015-09-14 11:12:08 -07:00
lilia
59313b5177 Let message models manage blob urls for attachments
// FREEBIE
2015-09-13 19:42:49 -07:00
lilia
04c8796bd3 Disable socket level reconnect
This is now handled at a higher level by the message receiver with the
aid of http requests for diagnosing the disconnect.

// FREEBIE
2015-09-10 01:03:19 -07:00
lilia
0ebdf08ceb Render identicons in notifications
Render an svg, then canvas, then data url.

Fixes #325

// FREEBIE
2015-09-10 00:47:54 -07:00
lilia
3bd9108f6e Use isPrivate helper
// FREEBIE
2015-09-09 17:49:17 -07:00
lilia
d6d1a7da55 Don't notify on sync messages
// FREEBIE
2015-09-09 16:53:34 -07:00
lilia
6b483195cb Fix reconnect bugs from previous commit
Forgot to bind the socket event handler, and the then() handler should
come before the catch() handler or else it will execute every time the
catch handler executes.

// FREEBIE
2015-09-09 01:56:14 -07:00
lilia
16de5aa3d3 Improve reconnect logic
Always test connectivity with an http request after a websocket closes,
regardless of what code/error it closed with. If that request succeeds,
automatically reconnect the socket.

// FREEBIE
2015-09-09 01:34:36 -07:00
lilia
756875f235 Refactor inbox collection listeners
Create a new collection type for the inbox which listens to events on
the main conversation cache. Also don't reload conversation info from
the database as often or when unnecessary.

Fixes #345

// FREEBIE
2015-09-08 19:28:33 -07:00
lilia
0509bb0f5d Remove global updateInbox, used scoped version
// FREEBIE
2015-09-08 19:27:38 -07:00
lilia
949cb8d8e3 Use generic Backbone collection for inbox
There's no need to use a custom collection type here since we don't use
any of the ConversationCollection methods. This helps prevent the
introduction of duplicate models for the same chat.

// FREEBIE
2015-09-08 19:27:38 -07:00
lilia
2ab7315c80 Use generic collection for conversation contacts
Let the conversation controller instatiate the models in order to avoid
having duplicate models in memory.

// FREEBIE
2015-09-08 19:27:37 -07:00
lilia
6d4bf4e5d1 Whitespace
// FREEBIE
2015-09-08 19:27:37 -07:00
lilia
8dc098093d On delivery receipts, reload messages only
The delivery receipt handler should only update messages, so rather than
reloading the conversation and its contacts, only reload the messages.

// FREEBIE
2015-09-08 19:27:21 -07:00
lilia
f764445c86 Remove erroneous license file and headers
We only use GPLV3 around here.

// FREEBIE
2015-09-07 14:58:42 -07:00
lilia
1427369bd0 Fix suggestion list template
Convention collision.

// FREEBIE
2015-09-04 18:46:33 -07:00
lilia
98aed2975c Fix conversations opening from the background
From a notification, for example, we were opening the inbox but not the
conversation.

// FREEBIE
2015-09-04 18:34:13 -07:00
lilia
24a18e91b3 Clean up shared compose/group update ui
Makes the groupupdate and recipient input fields stick to the top,
restyles the typeahead as a floating dropdown list of suggestions
rather than a full width component, fixes group avatar thumbnail
rendering.

// FREEBIE
2015-09-04 13:11:21 -07:00
lilia
e402338af7 Make it easier to reference templates
Whisper.Views can now use templateName to reference the id of the
desired template.
2015-09-04 13:09:56 -07:00
lilia
239b87a1fa Fix conversation resize bug
Fix behavior where resizing a message detail screen would result in a
mis-sized conversation view when exiting the message detail.
2015-09-04 13:06:40 -07:00
lilia
7d9490e503 Add contact list view
Used by member list view. Refactored some templates for shared markup.
Fixes strange behavior where members in the list were hoverable and
selectable.

// FREEBIE
2015-09-03 14:31:05 -07:00
lilia
5d9965a60e Make all mustache templates available as partials
// FREEBIE
2015-09-03 13:22:52 -07:00
lilia
3e5946a12b Move worker initialization to background.js
Not sure why I put it in panel controller. Probably an oversight.

// FREEBIE
2015-09-01 16:56:21 -07:00
lilia
43aaf541c1 Compose flow style tweaks 2015-08-31 16:09:05 -07:00
lilia
cc92cdfa29 After destroying messages, remove the conversation view 2015-08-31 16:01:56 -07:00
lilia
50939d1851 Restyle conversation menu button 2015-08-31 13:59:12 -07:00
lilia
89f5f216ed Fix new conversation with no lastMessage 2015-08-27 18:02:39 -07:00
lilia
5b430fa8aa Make sure newly active conversations are added to the inbox 2015-08-27 17:54:07 -07:00
lilia
e8b4bd708e Fix lint warnings 2015-08-27 17:45:23 -07:00
lilia
9e79ecddf8 Fix scroll stickiness while hidden
Fix bug: Open thread A, open thread B, receive message in thread A, open
thread A. Scroll bar has reset to the top.
2015-08-27 16:25:35 -07:00
lilia
e3c56a0c03 Refactor and remove old window mgmt code/globals 2015-08-27 15:23:22 -07:00
lilia
3bc64cbed5 Remove unused function 2015-08-27 15:04:43 -07:00
lilia
21aaf0fab5 Clean up notification and unread indicator behavior 2015-08-27 15:04:43 -07:00
lilia
e0f84d9c8e Clear unread on focus iff convo is open 2015-08-27 15:04:43 -07:00
lilia
baa55c9018 Refactor for less model duplication 2015-08-27 12:38:51 -07:00
lilia
c4eac76032 Fix for new contact button bug 2015-08-26 22:33:00 -07:00
lilia
a5a1dad03c Redelegate events for new contact view
And rename for consistency

// FREEBIE
2015-08-26 17:52:44 -07:00
lilia
17051cef9d Only add loading class from inbox 2015-08-26 17:48:02 -07:00
lilia
fbc73c0369 Add spinner for long-loading message lists 2015-08-26 17:30:20 -07:00
lilia
992dfa5b20 Bug fixes for group create flow
Fallout from layout change.

// FREEBIE
2015-08-26 17:11:01 -07:00
lilia
39d13d5e45 Quiet notifications if the window is open
Draw attention to the window instead.

// FREEBIE
2015-08-26 16:10:44 -07:00
lilia
0b98043c1c Add a worker
Offload all the asm.js code to a second thread. This is usually the
source of intermittent frontend freezes when running single-threaded.
2015-08-26 16:09:58 -07:00
lilia
d07357ce9a Retool various sub-screens to fit two-column layout 2015-08-26 15:15:14 -07:00
lilia
bcec207674 Mark read when opening a conversation 2015-08-26 10:12:05 -07:00
lilia
d6a4e6e496 Restore two column layout
Establishes basic functionality for viewing conversations in two column
mode, including message area and message list resizing, and maintaining
scroll position.

Various subviews need to be retooled but are more or less still
functional, i.e., new message, message detail, key verification, etc...
2015-08-25 17:01:22 -07:00
lilia
00dfcbb462 Change websocket closed message 2015-08-24 09:10:48 -07:00
lilia
c3d3ec125d Wait for contact sync before opening inbox
Use a canned bootstrap progress animation in lieu of better design.

Fix #271 // FREEBIE
2015-08-06 12:35:06 -07:00
lilia
4f1ce4c493 Assume unknown recipients are single-device
Start by requesting keys for only the master device, then handle 410 as
needed. Single-device users are the more common case and this strategy
lets us avoid requesting/expending one of our own device keys when
establishing a session with sibling devices.

// FREEBIE
2015-08-05 16:06:28 -07:00
lilia
82431c3c12 Update compose typeahead after fetching
Fixes #322

// FREEBIE
2015-08-05 11:20:18 -07:00
lilia
001a91466b Add group member list // Closes #279 2015-08-04 12:15:37 -07:00
lilia
98a14e9a6a Fix bug in message model
conversation.changedAttributes returns false when there are no changes.
2015-08-03 11:02:54 -07:00
lilia
3e73f8f0ba Resolve conflicts in series
Attempting to resolve outgoing conflicts in parallel triggers multiple
requests for new keys from the server and causes it to return a 500
error.
2015-08-03 11:02:54 -07:00
lilia
f3f084398f Handle identity key errors when retrying decrypt
After setting a new identity key as trusted, we retry decryption on all
pending conflicts for that contact. If their identity changed twice in a
row, we can still get a conflict the second time, and should handle it
appropriately.
2015-07-31 17:28:25 -07:00
lilia
ccfae3c78a Fix bug in identity key conflict edge case
When resolving conflicts, we should not only discard the old key, but
set the new trusted key to the one the user has verified. Previously, we
would end up trusting the first-seen new key, which may not be the one
the user verified.

 // FREEBIE
2015-07-31 17:01:03 -07:00
lilia
d808d255eb Fix bug with 0th contact color
Contact color css class wasn't being rendered because 0 is falsey.

// FREEBIE
2015-07-31 17:01:03 -07:00
lilia
47b58b8994 Use the correct number of contact colors
Bugfix from 2f12275
2015-07-31 11:13:30 -07:00
lilia
4fc4573de4 Don't try to sync after single device registration
There's no other device to sync to. :p
2015-07-31 11:11:23 -07:00
lilia
2f12275cb9 Update contact colors
Make default contact color assignments consistent with
WhisperSystems/Textsecure@99d3a76b
2015-07-31 11:07:42 -07:00
lilia
b3d93ab334 Request group sync when pairing
Whoops, missed a step. Fixes #319. Fixes #276.

// FREEBIE
2015-07-29 19:06:19 -07:00
adambar
d93bacb76e Fix for too eager scrolling to bottom when the scroll isn't actually stick to the bottom before resizing the window 2015-07-29 15:28:08 -07:00
adambar
1498d90b58 Maintain bottom-most scroll position when resizing conversation area, once again.
Related with #278. Redone to include keeping scroll at the bottom when resizing the window, as suggested in #305, and to better fit the current code structure.
2015-07-29 15:28:08 -07:00
lilia
56b6375f97 Use new provisioning socket keepalive path
This new endpoint should always issue a response to a provisioning
socket so if we don't receive one we should assume the connection has
been lost.

Closes #318
2015-07-29 13:37:17 -07:00
lilia
2b563212b4 Change default for keepalive autodisconnect config
By default, automatically disconnect if no response. This is preferable
because we can sometimes lose connectivity without receiving a close
event from the socket, but it's also possible that the endpoint may not
support responses.

// FREEBIE
2015-07-29 11:30:58 -07:00
lilia
fdad87b6a0 Add minimum window dimensions
Fixes #310

// FREEBIE
2015-07-29 11:30:58 -07:00
lilia
1a06cb5cbe Update consumers of WebsocketResources 2015-07-28 14:58:55 -07:00
lilia
1af8bd16b7 Add default response message to websocketresources
// FREEBIE
2015-07-28 14:57:09 -07:00
lilia
637cbcbf99 Make handleRequest optional in WebSocketResources
If no request handler is provided, respond with 404 to any incoming
requests.
2015-07-28 13:48:27 -07:00
lilia
cd363bd84d Integrate keepalives into websocket resources 2015-07-28 13:07:34 -07:00
lilia
7d2b41db11 Add auto-disconnect config to keepalive constructor
Disconnects on no keepalive response by default.

// FREEBIE
2015-07-27 20:17:00 -07:00
lilia
d9fe783488 Accept close code/message via websocket/resources 2015-07-27 19:30:51 -07:00
lilia
8170a7baae WebSocketResource exposes socket.close()
Allows for simplification of the keepalive construct.
2015-07-27 18:51:48 -07:00
lilia
98edd3939b Fix up websocket options handling 2015-07-27 18:50:55 -07:00
lilia
d9d4e281cc Keepalive provisioning socket
Fixes #315

// FREEBIE
2015-07-27 18:16:47 -07:00
lilia
0d0bdbf998 Don't auto-reconnect provisioning socket
// FREEBIE
2015-07-27 18:01:22 -07:00
lilia
15cd348bf2 Remove nonexistant variable 2015-07-27 18:01:21 -07:00
lilia
1f8856fa69 MessageReceiver accepts a server websocket url
// FREEBIE
2015-07-23 16:10:43 -07:00
lilia
fd5b0aeb85 Set lastmessage text on convo's with no timestamp 2015-07-22 15:24:03 -07:00
lilia
17e515f886 Add identity key conflict tests 2015-07-22 12:48:08 -07:00
lilia
c05be725b3 Move makeAttachmentPointer
Clean up unnecessary pre-declaration of `var makeAttachmentPointer`.
2015-07-21 16:00:16 -07:00
lilia
67f25214d3 Refactor outgoing identity key conflict handling
saveKeysToDeviceObject is the detector of outgoing identity key errors.
Catch these key errors closer to the source by pulling the
getKeysForNumber into the context of sendMessageToDevices, which lets
it access registerError and the message protobuf.

Previously identity key errors would be uncaught if all existing
sessions with a recipient were closed/deleted, since we would
preemptively fetch the new identity key. The old error handling only
kicked in after a 409/410 response from the server when posting a
message encrypted for a stale session.

// FREEBIE
2015-07-21 16:00:09 -07:00
lilia
27016e1919 Let textsecure devices throw on identity key change
Restore error format, accidentally removed in 43d6efcd

// FREEBIE
2015-07-21 15:50:11 -07:00
lilia
4e88d4a5cf Add missing semicolons 2015-07-20 16:13:50 -07:00
lilia
c28b5408ab Plumb keys into outgoing conflicts 2015-07-20 16:13:17 -07:00
lilia
0815a96c1d Display the new key for verification after a conflict 2015-07-20 14:27:11 -07:00
lilia
cc303e0802 Update libaxolotl, handle untrusted identitykey
Previously we had no access to the new untrusted identity
for verification purposes.

// FREEBIE
2015-07-20 14:25:02 -07:00
lilia
af48ca9e4b Update libaxolotl, remove one string conversion
Previously we would convert a bytebuffer to a string, pass it to
libaxolotl where it would be parsed back into a bytebuffer.

Ideally we would just pass the bytebuffer, but it turns out that
libaxolotl's bytebyffer class is identical but separate from
libtextsecure's bytebuffer class. ¯\_(ツ)_/¯

So instead we pass the underlying array buffer, which is handled
more or less the same way as a bytebuffer, and most importantly,
does not involve any copying.

// FREEBIE
2015-07-20 14:24:19 -07:00
lilia
1ab5af338a Update libaxolotl, un-revert b790f82849
Accidentally reverted in d3c158f
2015-07-20 12:31:31 -07:00
lilia
7d3d634a2d Move/refactor keepalive logic and add disconnect timer
We now disconnect ourselves if we don't get the server's response to a
keepalive request within 30s. This way we will eventually disconnect if
the network goes away but the socket is not closed.*

* See code.google.com/p/chromium/issues/detail?id=197841 and
https://stackoverflow.com/questions/11755605/chrome-websocket-connection-not-closed-when-browser-closed

We will then try to reconnect once a minute (See 8a10c96);

Keepalives belong at this level anyway, since the format is defined by
both the websocket resource protocol and our specific server url
structure.

// FREEBIE
2015-07-16 15:01:34 -07:00
lilia
8a10c96ab4 Reconnect once a minute if internet is down 2015-07-16 14:56:37 -07:00
lilia
f6b5eec84e Let key verification view use array buffers 2015-07-16 12:14:09 -07:00
lilia
17a3025af2 Mark end session messages sent 2015-07-16 12:14:09 -07:00
lilia
c94c4bc7e0 Remove redundant identity key updates
We were re-saving the key when it did not conflict with the exisiting
value.
2015-07-16 12:14:06 -07:00
lilia
2e272b6894 Turn off idb query logging
++speed
2015-07-16 12:13:45 -07:00
lilia
9dfff879b6 Remove usage of extension.trigger
This trigger function uses chrome's runtime message passing api, which
traverses between different windows in our runtime, but we only trigger
the updateInbox event from the backgroud page, so we don't need to use
that api, which requires some extra cpu/memory overhead.

// FREEBIE
2015-07-16 12:13:45 -07:00
lilia
2ad422afc8 Convert to array buffer 2015-07-16 12:13:43 -07:00
lilia
1f8040998f Fix up array buffer comparison
Well that didn't work. Luckily this comparison is primarily enforced at
the libaxolotl level.

With this and the corresponding change to libaxolotl, remote identity
keys are always going to be stored as array buffers going forward. This
will cause incompatibility with existing keys stored as strings, so
updating to this point requires you to purge your identity key and
session store.
2015-07-16 12:13:11 -07:00
lilia
853b578551 Change default value for active_at
We're overriding the default with null often enough that we should
just change the default.

Consequently, no more phantom blank conversations with oneself should
appear after receiving a group update. They were being added to the
inbox because they were incorrectly initialized with an active_at value.

Fixes #281
2015-07-14 16:44:08 -07:00
lilia
809c9bdb57 Save outgoing group updates 2015-07-14 16:41:25 -07:00
lilia
971079980e Close stale windows on background refresh
All the old event listeners and in-memory objects have perished with the
old background page. Also reopen the inbox if it was already open.

Fixes #289

// FREEBIE
2015-07-14 13:39:37 -07:00
lilia
815b79dc64 Cleanup 'Too many devices' dialog
Closes #263
2015-07-14 13:39:37 -07:00
lilia
a3ae3cab79 Use Promise.reject for simplicity
The following are equivalent, except that the first is longer and
invokes an extra function call.

```
return new Promise(function(resolve, reject) {
  reject(new Error("Unknown Group"));
});

return Promise.reject(new Error("Unknown Group"));
```
2015-07-14 13:39:36 -07:00
lilia
20586e2dcc Namespace events
Naming conflict was firing the error handler twice.

// FREEBIE
2015-07-13 13:03:43 -07:00
lilia
6e74ac9e28 Dispatch all network errors, not just auth errors
Also streamline the onError handler.
2015-07-13 13:03:43 -07:00
lilia
b40a8696b7 DRY up Promise creation in api.js
Since calls to ajax() are always wrapped in promises, we can internalize
that pattern in the ajax function itself.

// FREEBIE
2015-07-13 13:03:42 -07:00
lilia
3711e0a6cd Convert throwHumanError to custom error type
Now with 200% more helpful stack traces.

// FREEBIE
2015-07-13 13:03:41 -07:00
lilia
b44c12807c Mark messages sent after resolving outgoing key conflicts 2015-07-09 11:31:43 -07:00
lilia
82de8148d2 Reload harder
Refreshing the background page does re-open the socket, but the inbox
and other windows don't reattach correctly. Reload the whole runtime to
force close all windows, reload the background, and re open the inbox.
2015-07-08 17:53:47 -07:00
lilia
56341769bd Mark group creation messages as sent 2015-07-08 16:47:29 -07:00
lilia
3e4c571749 Fix initial input focus in compose view
This selector was being run too early, before the target was rendered.
2015-07-08 15:56:08 -07:00
adambar
476eb54db1 Maintain bottom-most scroll position when resizing conversation area.
Closes #278
2015-07-08 13:46:48 -07:00
lilia
1a82a12a30 Use input instead of keyup/change events
In lieu of a click event, the change event was being fired when clicking
out of the search input. The input event seems to be what we actually want.

Fixes #273
2015-07-08 13:06:45 -07:00
lilia
cfc3b8e6a5 Fix phantom outgoing messages
This bug was caused by a race between indexeddb requests and sending
messages. Order of events to repro was roughly:

1. send async idb request for current message list
2. add new message(s)
3. idb request returns with now incomplete message list
4. message collection gets reset to list from 3, removing messages
added in 2, but not removing their phantom views/dom elements. (bug)
5. send another idb request for current message list
6. idb request returns bearing all messages including those from 2.
7. messages from 2 are added and rendered a second time.

The fix was simply to not remove messages in 4, which means we reuse the
original message model object rather than recreating it in 7.

Fixes #243

// FREEBIE
2015-07-08 11:57:16 -07:00
lilia
fa4022a4e3 Invert pending/sent model 2015-07-07 23:03:56 -07:00
lilia
a66195a98f Fix messages stuck in pending state
The unset function, and the series of events/callbacks triggered by its
use, are not as similar to the set/save functions as previously
anticipated, leading to flux in the state of the 'pending' attribute.

Fixes #283

// FREEBIE
2015-07-07 16:15:23 -07:00
lilia
3cbe4f1f46 remove unused argument 2015-07-07 16:03:12 -07:00
lilia
8745424d3a Fix outgoing identity key conflict handling
// FREEBIE
2015-07-06 15:11:35 -07:00
lilia
9f021a9d7f Update notification code to new avatar format 2015-07-06 12:58:24 -07:00
lilia
66ae3689c1 Fix decrypt error handling
This rejection-handler was resolving its promise rather than allowing
the rejection to bubble up.
2015-07-06 12:46:32 -07:00
lilia
f8ae5556d9 Fix standalone registration 2015-07-06 12:45:09 -07:00
lilia
6a98fc8278 Reload contacts when resetting a recipients input
Fixes #272

// FREEBIE
2015-07-06 12:13:49 -07:00
lilia
f5f4c128f9 Fix tests, let templating handle html escaping
Note: as a Chrome app, we're also protected from xss by the content
security policy.

// FREEBIE
2015-07-04 23:08:25 -07:00
adambar
fcc873ffca Trim the message before sending - disable sending whitespace characters only 2015-07-03 21:53:45 +02:00
adambar
c20c59add0 Include Ctrl+Enter as one the shortcuts that insert line break instead of submitting the message 2015-07-03 13:49:01 +02:00
adambar
86f7b7adf5 Allow line breaks in messages. Closes issue #291
Line breaks can now be insterted into message box using Shift+Enter or Alt+Enter. Messages with new lines are properly displayed in the conversation view (but only there, to keep inbox clean). The template was modified to allow HTML, but the message itself is sanitized before new line handling is run.
2015-07-02 23:02:27 +02:00
adambar
52857f09ea Fix for conversation & inbox windows closing callbacks never called.
As discussed in similar issue there: https://github.com/GoogleChrome/chromedeveditor/issues/1023 - it is not possible to add onClosed event listener on an 'abstract' current window property, it needs to be set on the particular window instance instead.

Before that change, the clean up function was never actually called, because the listener was never properly attached. That was probably the reason of existence for "panel isn't actually open ... and so we try again." code that was executed if the previous window wasn't cleaned up properly (so actually every time). This code is no longer needed, I guess, as the windows are now cleaned up properly.
2015-07-01 22:28:06 +02:00
lilia
5242108e15 Fix group update avatar handling
The avatar handler was being added to the list of promises too late,
so we were storing the raw avatar protobuf (Long id, bytes key) rather
than the downloaded/decrypted attachment data.

Fixes #280
2015-06-26 12:23:57 -07:00
lilia
5e6145aa46 Mark conversation read on window focus event
Fixes #282

// FREEBIE
2015-06-26 11:53:00 -07:00
lilia
29360fea5c Fixes #275 default group image 2015-06-26 11:30:54 -07:00
lilia
feb5e5b068 Display gray # instead of colored + for no-name contacts
For consistency with android.
2015-06-25 13:47:46 -07:00
lilia
4c40861728 Fix reinstalls
Delay saving of new account info until we confirm with the server.
Explicitly delete old account info beforehand.

// FREEBIE
2015-06-25 13:24:32 -07:00
lilia
db31835f68 Handle group sync for existing groups
// FREEBIE
2015-06-25 13:24:32 -07:00
lilia
5925c2fe84 Support for group sync
Protocol and handling is all analogous to contact sync: Multiple
GroupDetails structs are packed into a single attachment blob and parsed
on our end. We don't display the synced groups in the conversation list
until a new message is sent to one of them.

// FREEBIE
2015-06-25 13:24:32 -07:00
lilia
3dd8056487 Add error dialog for too many devices 2015-06-25 13:24:31 -07:00
lilia
f126e3b21b Work on auth error handling / reinstall 2015-06-25 13:24:31 -07:00
lilia
ef8a977f38 Sort contacts by name ignoring case 2015-06-25 13:24:31 -07:00
lilia
2f935dfd5e Add contact sync request protocol 2015-06-25 13:24:31 -07:00
lilia
f32ff58953 Add support for device name 2015-06-25 13:24:30 -07:00
lilia
7d568b5092 Fixup auto-expand
* Fix a css bug preventing bottom bar from sticking to the bottom.
* Resize discussion container as a function of the overall window
  height. The previous difference-based method gives the wrong result
  when the window height changes but the bottom-bar height stays the
  same.

// FREEBIE
2015-06-24 12:10:53 -07:00
adambar
b80706089c Fix for potential memory leaks 2015-06-23 22:46:27 +02:00
adambar
9c563cf080 Fix for message box auto-sizing behavior on resize; menu z-index fix 2015-06-23 22:46:27 +02:00
adambar
da1abd75bf Remove message textarea resize handle; fix resizing after submit 2015-06-23 22:46:06 +02:00
adambar
07ac0ae9cc 239 Auto-expand message area when typing 2015-06-23 22:45:41 +02:00
lilia
e26b9bfbc7 Default avatar support
Fixes #264

Implement the equivalent of java's String.hashCode on the conversation model.
Change avatar template and attributes. Use css classes for colors.
2015-06-19 11:50:18 -07:00
lilia
8dc4e34aaf Bug and test fixes for contact sync
Closes #135

// FREEBIE
2015-06-18 13:48:32 -07:00
lilia
6a5f923cac Don't set attributes redundantly
By the time we get here, these should have already been set in
background.js.

// FREEBIE
2015-06-17 12:29:40 -07:00
lilia
b0603bc91a Wrap message receiver for minimum api exposure
Initializing a message receiver opens the socket and starts listening
right away rather than requiring a separate call to connect. The only
other publicly accessible method is to query the socket status.

// FREEBIE
2015-06-17 12:29:40 -07:00
lilia
18433419c9 PushMessageContent is now DataMessage 2015-06-17 12:29:40 -07:00
lilia
316838cfe9 Add tests and bug fixes for ContactBuffer 2015-06-17 12:29:40 -07:00
lilia
290283f810 Conversations do not require timestamps
Synced contacts will not include timestamps
2015-06-17 12:29:40 -07:00
lilia
228ffe901d Update json formatting for legacy message requests
Legacy DataMessages are sent using the `body` field, new Content
messages are sent using the `content` field.

// FREEBIE
2015-06-17 12:29:39 -07:00
lilia
a833d62a71 Implement sync protocol changes
Update protobuf definitions and refactor message receive and decrypt
codepath to support new protocol, including various flavors of sync
messages (sent messages, contacts, and groups).

Also cleans up background.js and lets libtextsecure internalize
textsecure.processDecrypted and ensure that it is called before handing
DataMessages off to the application.

The Envelope structure now has a generic content field and a
legacyMessage field for backwards compatibility. We'll send outgoing
messages as legacy messages, and sync messages as "content" while
continuing to support both legacy and non-legacy messages on the receive
side until old clients have a chance to transition.
2015-06-17 12:29:39 -07:00
lilia
757bcd4e50 Reset recipient typeahead after selecting a recipient 2015-06-17 12:29:34 -07:00
lilia
e9e875766f Group update recipient typeahead excludes exisiting members
Fixes #199

// FREEBIE
2015-06-17 12:21:58 -07:00
lilia
694f801676 Stop hiding inbox instead of closing
This behavior was intended to help keep the websocket alive, but keeping
the inbox window around can cause some stale frontend state. Also we now
have a keepalive alarm to check for new messages once a minute.
2015-06-15 17:48:06 -07:00
lilia
72f16b94ff Polish group update ux
* Show the members list as static elements
* Style the search results as a drop down, mirroring android ux

Fixes #248 // FREEBIE
2015-06-09 16:12:21 -07:00
lilia
23db5802cf Support custom placeholder on recipients input 2015-06-09 16:10:07 -07:00
lilia
9795b26bc1 Supress change event on avatarUrl initialization 2015-06-09 12:03:28 -07:00
lilia
ac401c78b3 Fix socket status indicator
It was not correctly reporting the status after a background page reload.
2015-06-09 11:30:45 -07:00
lilia
363c436b33 Handle single-error rejections when sending messages
We can not assume that we will get back an error array.

Closes #258 // FREEBIE
2015-06-05 17:29:31 -07:00
lilia
6e1a41e9cf Update inbox when group avatars change 2015-06-05 11:53:46 -07:00
lilia
583fb98cce Support late-addition of default image to file input
Fixes #256

// FREEBIE
2015-06-05 11:23:03 -07:00
lilia
061d57c95a Fix string vs number comparison
Fix bug in device storage causing duplicate device messages after a 410.
2015-06-04 16:48:34 -07:00
lilia
a9549e2e0f Fix 410 handling
We need to close the existing session with an old registrationId.
2015-06-04 16:48:10 -07:00
lilia
7d08e1132d Fix close session 2015-06-04 14:48:59 -07:00
lilia
f4a206b266 Scale and crop avatars to 256 square thumbnails.
Fixes #213 // FREEBIE
2015-06-04 14:46:16 -07:00
lilia
cdb7fcfbad Pass windows around to let file inputs work 2015-06-04 13:39:52 -07:00
lilia
3d1df790a5 Update the window title when a group title or contact name changes 2015-06-03 17:23:55 -07:00
lilia
d26c13b155 Add openInbox link to conversation menu. Fixes #246 2015-06-02 14:57:22 -07:00
lilia
9d688cb761 List views persist sroll offset by percentage
Fixes #188
2015-05-28 11:50:58 -07:00
lilia
590deef063 Decrease auto-scaling size
For better consistency with Android, autoscale images such that the
largest dimension is 1280. Related: #242
2015-05-27 16:53:04 -07:00
lilia
a66c879426 Update inbox after destroying a conversation
Fixes #247

// FREEBIE
2015-05-27 14:49:50 -07:00
lilia
3e73282a64 Fix key verification screen 2015-05-26 17:08:14 -07:00
lilia
e2eff893d4 Fix 'Delete messages'
Replaces window.confirm with generic promise-based confirmation dialog
functionality available to all views.

// FREEBIE
2015-05-26 16:56:05 -07:00
lilia
8a17953468 Display sent_at timestamps instead of received_at 2015-05-26 13:31:17 -07:00
lilia
3e39271220 Render messages light blue until finished sending // Fixes #219 2015-05-26 13:30:51 -07:00
lilia
405e67c758 Merge inbox and panel controllers
These collections should always be operating with the same model
instances, so let the inbox reset it self from the same in-memory
cache of conversation models used by the conversation windows.
2015-05-26 13:28:43 -07:00
lilia
53a9ab4834 Fix bugs with handling large image attachments
* Avoid infinite loop scaling too-big images
* Don't crash if no file is selected
* Fix file size toast

Fixes #242

// FREEBIE
2015-05-25 10:43:35 -07:00
lilia
585c82aee8 Fix the build 2015-05-24 16:29:11 -07:00
lilia
3eafefe18e Don't display notifications for open windows.
Just update and draw attention to them.

Fixes #238

// FREEBIE
2015-05-24 16:20:55 -07:00
lilia
d8f17f9631 Fixes #240
Delete files attached via chrome.fileSystem

// FREEBIE
2015-05-24 16:03:13 -07:00
lilia
9882190bde Wake up once a minute to check for messages
If all the application windows are closed (and not merely hidden), the
background page will go inactive and there's nothing we can do to stop
it. However, we can ask chrome to trigger an alarm once per minute,
which will spin up the background page and check for new messages.

This will effectively keep us alive as long as chrome has open windows
or is running in the background, subject to chrome settings'
Advanced -> System -> Continue running background apps
2015-05-22 17:26:56 -07:00
lilia
fa3e1ee94f Window ids should be strings
A warning is issued when a non-string window id was passed to
extension.windows.focus.
2015-05-22 17:23:18 -07:00
lilia
7bf1d41184 Render conversation titles 2015-05-22 16:54:59 -07:00
lilia
bc4d31cf72 Fix for inbox sometimes not reappearing
Apparently focusing an app window does not implicitly unhide it.

// FREEBIE
2015-05-22 12:36:14 -07:00
lilia
d0a529351c Fix sending messages with no attachments 2015-05-21 19:01:37 -07:00
lilia
a5e80e8a5a Really close conversation windows
Only the inbox should hide when closed.
2015-05-21 18:20:19 -07:00
lilia
5d3a2a4cc8 Fix file inputs
As a chrome app we are obligated to use the fileSystem api, and must do
so via the window in which we want to open the dialog.
2015-05-21 18:19:10 -07:00
lilia
39d11d8eb3 Apply custom chrome to conversation windows 2015-05-21 14:35:44 -07:00
lilia
95f8e3921c Keep inbox window open, but allow it to be hidden
As a chrome packaged app, we have to keep at least one window open in
order to maintain our websocket connection in the background page.

This change replaces the system window frame with custom buttons in the
inbox header, such that the 'close' button merely hides the window
rather than unloading it.

Fixes #237
FREEBIE
2015-05-21 13:08:43 -07:00
lilia
b83ce7a015 Delay conversation creation til post-decrypt 2015-05-20 17:22:03 -07:00
lilia
12eb553a3f Draw attention to windows on new messages 2015-05-20 17:22:03 -07:00
lilia
0b31823989 Wait for storage on launch 2015-05-20 14:24:44 -07:00
lilia
08878b3dc8 Update inbox after sending a message
Also change the event name to reflect how its being used, and stop
passing the message object around since it is not being used.

// FREEBIE
2015-05-20 13:04:16 -07:00
lilia
e9d7864f75 Set conversation type when creating from sync message
When a conversation is created as the result of a sync message, and it
is not a group, we need to set its type to private.

// FREEBIE
2015-05-20 12:58:48 -07:00
lilia
7e8b1319a5 Ignore sync contexts on messages not from ourselves
But process the rest of the message normally.
2015-05-20 12:42:13 -07:00
lilia
fdd2eb0d3e Make conversation windows taller 2015-05-20 11:49:53 -07:00
lilia
1b83932a29 Update open conversations on sync messages 2015-05-19 13:34:51 -07:00
lilia
090cc84452 Do not include destination on group sync messages 2015-05-18 14:40:27 -07:00
lilia
1ed0ef5bc3 Process group updates before sync delivery receipts
Because we need to know the group members to find early-arrival
receipts.
2015-05-18 14:23:09 -07:00
lilia
654373d743 Fix null conversationId on group sync messages 2015-05-18 14:08:19 -07:00
lilia
65a6068003 Fix for out-of-order message/receipt arrival
In a multi device world, it's possible to receive a receipt for a sync
message before the sync message actually arrives. In this case we need
to keep the receipt around and the process it when the message shows up.
2015-05-18 13:48:48 -07:00
lilia
c4fa2cb935 Fix sync message timestamps 2015-05-18 12:48:52 -07:00
lilia
d1bcafad65 Update libaxolotl 2015-05-15 16:30:22 -07:00
lilia
16e9f03d8f Check for registration when launched 2015-05-15 14:02:26 -07:00
lilia
f6a326577d Crash fixes for chromium
My current version of chromium inexplicably exposes a crippled version
of chrome.browserAction even though we are now a packaged app and should
not have that functionality exposed to us anymore. This results in some
errors to the tune of "property 'foo' of undefined".

It also doesn't support the innerBounds property for window creation,
only the older (deprecated) bounds property.
2015-05-15 12:54:31 -07:00
lilia
029c9754f0 Fix tests 2015-05-15 11:39:23 -07:00
lilia
5a7ab54ee6 Fix registration page
Also make it accessible by providing a mode argument to the install
function. Previously developers could just edit the url but we no longer
have the address bar as an app window, so now they must close the
default installer and run the following from the background page
console: `extension.install('standalone')`.

In the production build, this should result in an error since it is not
supported / the register page is not included there.
2015-05-15 11:39:23 -07:00