Commit graph

1181 commits

Author SHA1 Message Date
lilia
a569e34b33 Refactor new message notification and frontend updates
Create a cleaner seperation between generating notifications
and updating frontend conversation views. The former is now
handled by `conversation.notify` while the latter is achieved
by triggering an event on the conversation model, which will
only be acted on if there are any views listening for it.

Additionally, instead of re-fetching the entire message history,
which is overkill, just add or update the new/modified message.
This will help speed up the newmessage event handler and also
help avoid unnecessary re-rendering when resolving key conflicts.

// FREEBIE
2015-11-07 14:11:13 -08:00
lilia
847fa43520 Save group members when creating groups from non-updates
Follow up to b0da4910. When inferring membership of the sender in an
unknown group, remember to save and return the group members.

Generally, this should only effect standalone clients unless someone
managed to clear their groups db table, since linked clients get group
info synced at registration.

// FREEBIE
2015-11-06 19:09:03 -08:00
lilia
a3d29a92bb Reject messages sent to groups with no members
If you're the last member of the group, it doesn't make sense to send
messages to it. Previously, we would wait forever for a callback,
causing a stuck pending state indicator.

// FREEBIE
2015-11-06 18:51:18 -08:00
lilia
4136e3633c Fix incoming key conflict behaviors
Follow up to ddd2e67eb5
but for incoming messages.

* Conflict state sometimes failed to be removed even though the
  conflict was resolved.
* Messages failed to re-render after a conflict. We want to
  re-render only the error state on outgoing messages, to avoid
  flickering attachments. On incoming messages, we need to call
  render to populate the message text, avatar, etc...

// FREEBIE
2015-11-06 17:50:43 -08:00
lilia
c34f8e330d Clear timestamp timeouts if the window closes
// FREEBIE
2015-11-06 16:47:30 -08:00
lilia
2ce890b845 Update message bubble timestamps as needed
Display format consistent with Android:

* relative time for everything from today
* Day of week + time for within the past 7 days
* Static Month Day time for everything older

Each timestamp will only update as often as needed to stay accurate,
which is once a minute, once an hour, once a week, or never.

// FREEBIE
2015-11-06 15:24:01 -08:00
lilia
ddd2e67eb5 Fix re-rendering when resolving conflicts with media
* Don't open message detail views from message detail views
* When message errors change, re-render the error state, but
  not the message markup and contents.
* Fix renderErrors bug not removing the error class correctly.

// FREEBIE
2015-11-05 20:11:28 -08:00
lilia
9c8933c3d0 Resolve conflicts one at a time
Previously, with a mix of text and media messages in conflict,
asynchronous callbacks aligned so as to fail to remove some of
the conflict objects on messages.

Fix by serializing conflict processing, but making sure to move
on through the message list even if some conflict resolutions fail.

Fixes #370

// FREEBIE
2015-11-05 19:42:55 -08:00
lilia
4c4b875348 Fix displaying contact names as 'Unknown Group'
// FREEBIE
2015-11-05 16:30:36 -08:00
lilia
14cb6b58a2 Create install flow
* Refactor options.js into a view
* Break up install flow into a series of screens
* Remove bootstrap
* Make installer window static size, mostly to facilitate positioning

// FREEBIE
2015-11-05 13:29:26 -08:00
lilia
675be2b569 Don't reconnect if close was called
Fixes a bug during re-registration where we continue to re-open
the socket using old credentials.

// FREEBIE
2015-11-05 13:04:29 -08:00
lilia
f863616785 Remove api TODO comments
// FREEBIE
2015-11-04 13:52:48 -08:00
lilia
80d32103d1 Clear session store when re-registering
When we re-register, our deviceId might change, which makes our sessions
are no longer valid since the recipient will see us as a new device.

Fixes #388
2015-11-04 13:52:47 -08:00
lilia
a52d35bb1b Refactor and fixup key requests
Fix a bad loop scope bug in getKeysForNumber by using forEach.
Refactor the initial process of establishing key material for devices
that do not have open sessions.

// FREEBIE
2015-11-03 16:22:26 -08:00
lilia
6717390e83 Catch cancelation of confirmation dialog
Avoid 'Uncaught (in promise)' error in the console.

// FREEBIE
2015-11-02 17:04:46 -08:00
lilia
c64fe8410e Convo list shows 'Media message' when appropriate
// FREEBIE
2015-11-02 16:50:46 -08:00
lilia
503509fc8f Fix blank lastMessage for non-text messages
For non text messages (ex: media messages and group updates), the
lastMessage field was being populated with empty string, resulting in an
empty message preview in the conversation list. Instead, display 'Media
message' or 'Updated the group', etc...

// FREEBIE
2015-11-02 16:27:42 -08:00
lilia
b18cfd75de Check for device keys in memory before requesting more
// FREEBIE
2015-11-02 14:07:52 -08:00
lilia
2b9d039837 Serialize requests for keys
Fixes #383

// FREEBIE
2015-11-02 14:07:51 -08:00
lilia
4e2723a751 Create notifications if window is not focused
Track focus using focus and blur events.

// FREEBIE
2015-11-02 11:41:27 -08:00
lilia
0f023ac4bf Focus the message field when conversation opens
Fixes #317

// FREEBIE
2015-10-30 11:14:38 -07:00
lilia
287aa49252 After choosing a file, focus the message field
Allow the user to edit the message and/or hit enter to send the image
without having to click.

// FREEBIE
2015-10-30 11:02:58 -07:00
Jani Monoses
cb3b9f0e79 Fix some error messages' wording.
// FREEBIE
2015-10-29 18:29:43 -07:00
lilia
78a2b74297 Restyle attachment previews
Closes #380

// FREEBIE
2015-10-29 18:19:51 -07:00
lilia
fe2b152186 Change target for appending file previews
// FREEBIE
2015-10-29 11:04:21 -07:00
lilia
9011a85b56 Change selector for opening a file input
// FREEBIE
2015-10-29 10:58:28 -07:00
lilia
a644b7a674 Update libaxolotl
// FREEBIE
2015-10-28 16:53:09 -07:00
lilia
c77391b3f2 Sinewave animation for pending requests
Tryin it on for size.

// FREEBIE
2015-10-28 13:57:32 -07:00
lilia
1065502770 Change key conflict error message
Include the contact's number in the message for more helpful debug log
output.

// FREEBIE
2015-10-28 13:46:03 -07:00
lilia
f8fd613669 Update libaxolotl
// FREEBIE
2015-10-27 14:00:41 -07:00
lilia
ac7c95fed0 Validate argument lengths in crypto.js
These functions accept an array buffer and extract an AES and MAC key
from it without verifying it has the appropriate length. Ciphertext
messages are similarly dissected. The slice function does not raise an
error on out of bounds accesses but instead returns an empty or
partially-filled array. Empty or short arrays will be passed through to
the window.crypto.subtle API, where they will raise an error. We should
not rely on the Web Crypto API to validate key lengths or for MAC checks
to fail. Instead, validate the lengths of given parameters before
extracting their components.

// FREEBIE
2015-10-27 13:58:23 -07:00
lilia
cb93ad4cff Avoid opening message-detail twice
Previously, clicking the timestamp on an error bubble would open two
message detail views.

// FREEBIE
2015-10-26 17:00:21 -07:00
lilia
ec6898f1ab Process incoming messages in order
This may increase processing latency a bit, particularly with large
attachments, but will ensure that messages are dispatched in the order
they are received.

It would be nice to enforce ordering on only the dispatch step, so that
we could, for example, decrypt the next websocket message while waiting
for an attachment to download, but that will require a more complicated
refactor. Will stick with the quick fix for now and revisit later.

Fixes #342

// FREEBIE
2015-10-26 14:18:24 -07:00
lilia
9b12d8a978 Reconnect provisioning socket
If the provisioning socket closes, reconnect and generate a new qr code.
Fixes #371

// FREEBIE
2015-10-23 18:33:07 -07:00
lilia
47befdbf61 Messages bubbles with errors are clickable
For messages with errors, clicking anywhere inside the bubble takes you
to the message detail view.

// FREEBIE
2015-10-23 17:43:51 -07:00
lilia
c79a917bbe Remove unused localStorage adapter
And remove various stray references to localStorage

// FREEBIE
2015-10-23 17:06:21 -07:00
lilia
ff3b23e452 Make sure group updates get emojified
Render group update content prior to processing emoji, so that emoji in
group titles get processed correctly.

Fixes #368

// FREEBIE
2015-10-23 16:04:40 -07:00
lilia
01e85b68ef Handle exceptions when fetching keys for devices
It's rare that we get in a state where we have a device record without a
session, but we should handle errors gracefully in that case. Catch them
and register them, except for identity key errors which are registered
in handleResult.

// FREEBIE

fixup error handling // FREEBIE
2015-10-23 15:53:20 -07:00
lilia
12276e691b Refactor contents of sendMessageProto
This function dynamically declares a bunch of functions which bind to
its input arguments. Instead, use a new prototypal class to define
these functions within the context of a particular message.

// FREEBIE
2015-10-23 15:53:20 -07:00
lilia
a2c7ac0df9 Serialize message sending per-recipient
Add a pendingMessages object to MessageSender. This object holds
one promise per recipient number. We init this promise with
Promise.resolve(), and chain on promises for message sending, replacing
the previous promise with the newly chained promise each time. If the
current promise resolves and finds that it is still the last promise
in the chain, it removes itself.
2015-10-23 15:53:19 -07:00
lilia
9be5efc571 Simplify keepalive resets
Websocket resources should have their keepalive timers reset whenever a
message comes in. This is a nicety that slightly reduces the amount of
traffic we send when actively messaging.

Previously this was handled by MessageReceiver, but it's a bit cleaner
to just have the WebsocketResource add an extra 'message' event handler.

// FREEBIE
2015-10-23 15:44:03 -07:00
lilia
e68b84ad9a Fix saving TypeErrors
// FREEBIE
2015-10-22 10:12:34 -07:00
lilia
e842ade196 Slow your roll, socket status updates
Avoid a 1 sec flash of "Disconnected" if connection is dropped only
momentarily.

// FREEBIE
2015-10-22 10:12:34 -07:00
lilia
2e32c7bbc3 Small refactor of attachment views
Bind the sub-view to some data when we initialize it, rather than
passing it in on render. That means the image view click handler will
only ever open the blob we bound it to, even if its src attr changes for
some reason, which should never happen, but if it does, it's nice to
guard against opening arbitrary urls found in the dom.

// FREEBIE
2015-10-21 10:52:20 -07:00
Odysseas
49585c8c57 Add feature to open image attachments
Images that are attached to messages, either sent or received
can be opened in a new tab by clicking on them.

The previous approach that used Anchors to open the image
attachmets failed in various systems because:
 - Chrome on Windows recognised "blob" as protocol and tried
   to find an app for it
 - Chromium on Ubuntu didn't open a new window to load the URL

The new approach adds a "click" listener to the IMG element and
opens the link using window.open (which seems to be working globaly).

Resolves: #252
2015-10-21 10:26:14 -07:00
lilia
a32780d174 Mark delivered messages as sent
In rare cases, a race between delivery receipts and outgoing message
requests can cause the sent flag to be reversed. Fix by marking messages
sent at the same time they are marked delivered.

// FREEBIE
2015-10-20 18:57:24 -07:00
Deirdre Connolly
861bc416e6 Update attachment size limits to match mobile clients
Per WhisperSystems/TextSecure@8a1428e, bump GIF limit to 5MB, and
audio/video limit to 100MB. Update toast to notify in correct
human-readable units. The only kB size limit is for images, and will
trigger only if after scaling up to 4 times, the rescaled image did not
come in under the size limit without unacceptable quality loss.

Closes #354
2015-10-20 12:29:52 -07:00
lilia
389b9a026d Initial restyle
Added background gradient and restyled conversation elements as floating
panels and cards.

// FREEBIE
2015-10-16 18:14:50 -07:00
lilia
ee393bfa03 Ensure that tokens get updated on initial save
// FREEBIE
2015-10-16 13:01:14 -07:00
lilia
2f8d973366 Restore native window chrome
// FREEBIE
2015-10-16 12:52:10 -07:00
lilia
82ce76265d Remove stray log statement
// FREEBIE
2015-10-16 12:32:06 -07:00
lilia
f70c22f898 Add search field to inbox
Using the search field produces a filtered view of all contacts and
groups containing the input. To make this fast and scalable, add an
index on a 'tokens' array containing words from the conversation name
and different forms of phone number.

Closes #365

// FREEBIE
2015-10-15 13:33:07 -07:00
lilia
81ebc5ffd7 Improve stack traces on HTTPErrors
Save stack even earlier, outside the promise.

// FREEBIE
2015-10-11 12:12:11 -07:00
lilia
c062fe3060 Automatically retry failed http requests
If we failed to reach the server, wait a second and try again up to 3
times.

// FREEBIE
2015-10-10 19:07:00 -07:00
lilia
a93b8cea72 Collapse multiple retry buttons
If you're going to retry one, you might as well retry everyone.

// FREEBIE
2015-10-10 16:59:52 -07:00
lilia
816a206892 Refactor sendMessageToDevices
Split into separate encrypt and transmit functions. Let the encryption
function also handle all wire formatting (ie, jsonification and base64
encoding), which simplifes TextSecureServer.sendMessages, removes a
TODO, and lets us save fewer params to make network errors replayable.

// FREEBIE
2015-10-10 16:36:30 -07:00
lilia
e9bc39bc56 Add parens and line breaks
// FREEBIE
2015-10-10 15:12:06 -07:00
lilia
b1c933ccd4 Don't show myself in the message detail contacts list
// FREEBIE
2015-10-08 06:13:36 -07:00
lilia
87d4f0d5d8 Fix non-disappearing resend button
The resend button should disappear once you've clicked it. This was not
happening because the message detail view held a cached copy of the old
message errors. Fix by re-reading the errors when we re-render.

// FREEBIE
2015-10-05 15:07:55 -07:00
lilia
0ff38e41c2 Let keepalive listen to socket events
Wait until the socket connects before starting the keepalive timer.
Automatically stop the keepalive when the socket is closed.

// FREEBIE
2015-10-05 15:05:24 -07:00
lilia
1345899253 Use reject instead of throw
This ensures that the containing promise is rejected without triggering
the side effects of an uncaught exception, such as causing the debugger
to pause.

// FREEBIE
2015-10-03 23:19:53 -07:00
lilia
a32f3ff1f6 More work on replayable errors
Expose a button that does that retries outgoing messages if possible.

// FREEBIE
2015-10-02 18:31:07 -07:00
lilia
5bf608598c Fix MessageSender prototype
// FREEBIE
2015-10-02 15:02:25 -07:00
lilia
b0da491025 Don't throw on unknown groups
// FREEBIE
2015-10-02 12:54:12 -07:00
lilia
b42626923c Don't double-render key conflict errors
// FREEBIE
2015-10-02 12:35:28 -07:00
lilia
7ec4700431 Handle saving errors when none exist already
// FREEBIE
2015-10-02 12:35:28 -07:00
lilia
4cc7a30107 Remove error class when no more message errors
// FREEBIE
2015-10-02 12:15:25 -07:00
lilia
ae25d62ef2 Fix up post-conflict resolution error processing
// FREEBIE
2015-10-02 12:14:34 -07:00
lilia
d3812869d2 Don't throw errors from background
// FREEBIE
2015-10-02 12:14:10 -07:00
lilia
bbb5b24d6b Fix disappearing conversation bug
Opening two message-detail views in two separate conversations would
disappear one of the conversations. Fixed by better encapsulating the
sub-views of a conversation.

// FREEBIE
2015-10-02 11:21:11 -07:00
lilia
8f003ea69d Don't throw if sender is not a group member
This could happen if we simply failed to process an earlier group
update correctly.

// FREEBIE
2015-10-02 10:43:34 -07:00
lilia
4a1d0ebdb9 Pass bytebuffer to axolotlInstance
// FREEBIE
2015-10-02 00:03:49 -07:00
lilia
46c9a7fafb Fix tryMessageAgain
// FREEBIE
2015-10-02 00:02:18 -07:00
lilia
08b864b57c Fix standalone registration
// FREEBIE
2015-10-01 22:04:07 -07:00
lilia
9872b59355 Simplify filter predicate
Untangle a double negative to make this line shorter and easier to read.

// FREEBIE
2015-10-01 21:11:41 -07:00
lilia
0fa1069a93 Don't throw on duplicate members in a group update
Fixes #364

// FREEBIE
2015-10-01 21:11:41 -07:00
lilia
1aee065c2c Fix registration
Previously would fail to register keys by using the wrong username.
The username should be <number>.<deviceid> once we've confirmed our
account and received a deviceId from the server.

// FREEBIE
2015-10-01 20:43:30 -07:00
lilia
978b3d1a98 DRY up tryMessageAgain
// FREEBIE
2015-10-01 18:43:20 -07:00
lilia
fbb65d1988 Add replayable network errors
Support for manual message retry.

// FREEBIE
2015-10-01 18:43:20 -07:00
lilia
bc03bdbfc4 Move tryMessageAgain to MessageReceiver
`tryMessageAgain` is the routine called when re-trying a message that
failed to decrypt due to an IncomingIdentityKeyError. This handling
needs to move to MessageReceiver because it depends on
`processDecrypted` to handle incoming message protos, which depends
on a server instance in order to download attachments.

// FREEBIE
2015-10-01 18:43:19 -07:00
lilia
0fc673f25f Refactor sendmessage for prototypality
// FREEBIE
2015-10-01 18:43:18 -07:00
lilia
868695558d Throw on bad server url
// FREEBIE
2015-10-01 18:43:18 -07:00
lilia
c8a1e090d2 Move handleAttachment and processDecrypted
Make these internal methods on MessageReceiver. Todo: refactor
identity key errors to use a given message receiver.

// FREEBIE
2015-10-01 18:43:07 -07:00
lilia
a8f4bac2f7 Let makeAttachmentPointer resolve falsey arguments
Internalizing this pattern to the makeAttachmentPointer function lets us
DRY it up throughout the file.

// FREEBIE
2015-10-01 18:33:50 -07:00
lilia
e626355e0c Let background page instantiate AccountManagers
Remove the need to expose the server url config as a global.

// FREEBIE
2015-10-01 18:33:49 -07:00
lilia
edd76ec65a AccountManager takes a url 2015-10-01 18:33:49 -07:00
lilia
9de23a967b Fix dropping the first websocket message 2015-10-01 18:33:49 -07:00
lilia
3fcd980c23 Add websocket error and close event handlers 2015-10-01 18:33:49 -07:00
lilia
78956ede2f Disable keepalive if we disconnect the socket 2015-10-01 18:33:48 -07:00
lilia
9e9d767a30 Add MessageSender
textsecure.MessageSender takes server url and credentials and returns
a message sending interface configured for that server.

Used a wrapper function to insert a TextSecureServer instance into
sendmessage.js code at runtime. This will result in function duplication
between different MessageSender objects, pending further refactoring to
use prototypal inheritence.

// FREEBIE
2015-10-01 18:33:48 -07:00
lilia
98aa5156b0 Refactor TextSecureServer for storage
Following the pattern from previous commit, let the server class accept
a url and login credentials from the caller. Then integrate into
MessageReceiver and AccountManager.

// FREEBIE
2015-10-01 18:33:48 -07:00
lilia
09bd6c7824 Lint
// FREEBIE
2015-10-01 18:33:33 -07:00
lilia
19423bf909 Abstract message error handling
// FREEBIE
2015-10-01 18:21:20 -07:00
lilia
e1c9e28b4c Add comment
// FREEBIE
2015-10-01 10:55:04 -07:00
lilia
569d0655fa Fix test failure
// FREEBIE
2015-09-30 19:32:25 -07:00
lilia
1c306df61f Workaround for #363 Multiple open sessions bug
This doesn't solve the problem in the general case, but should at least
unbreak registration.

// FREEBIE
2015-09-30 18:47:42 -07:00
lilia
876e11c19b Fix sync messages not getting displayed on arrival
// FREEBIE
2015-09-30 17:52:13 -07:00
lilia
7d6adc4879 Save outgoing error codes when messages fail
// FREEBIE
2015-09-30 17:13:59 -07:00
lilia
a802322d44 Display a default message for incoming message errors
An exception to the previous commit, for incoming messages we should not
show a mysterious empty bubble. Instead there is some generic
non-technical error message.

// FREEBIE
2015-09-30 15:24:34 -07:00
lilia
929c16090b Move error messages to message detail view
Change how message errors are rendered. Errors associated with a number
will be shown under that number in the detail view rather than piling up
in the message bubble.

// FREEBIE
2015-09-30 14:27:18 -07:00
lilia
9a63703340 Close the socket/keepalive when going offline
// FREEBIE
2015-09-30 14:22:07 -07:00
lilia
c1b9f3235f Save all errors
But clean up objects created by the Error constructor, as they contain
non-serializable properties, like functions.

// FREEBIE
2015-09-30 14:22:07 -07:00
lilia
37ff3cf5a8 Change http logging
Printing method + url again makes it easier to match requests to
responses when scanning logs.

// FREEBIE
2015-09-30 14:21:52 -07:00
lilia
0f8aff12c5 Refactor contact rendering in message detail view
DRY

// FREEBIE
2015-09-30 14:21:52 -07:00
lilia
b8536679b3 Stop keepalive when socket closes
// FREEBIE
2015-09-30 14:21:10 -07:00
lilia
04c5f83485 Un-nest libtextsecure errors
Fix inconsistency in error format, where we sometimes get an unexpected
Error object and sometimes get a wrapper object containing an Error.

Also start saving network errors.

// FREEBIE
2015-09-30 12:44:11 -07:00
lilia
1879e73c76 Allow one more retry if we get a 409
Handle cases where we get a 409 (missing/extra devices), handle it, then
get a 410 (stale devices by registration id).

// FREEBIE
2015-09-28 14:10:50 -07:00
lilia
8453424ebd Fix stuck pending messages state
Refactor outgoing message error handling to use the same success and
error handlers. This creates a somewhat strange pattern, where we call
send and pass in the promise that resolves when sending is complete, but
there's enough variety in the libtextsecure syntax for different message
sending routines that it belongs at the conversation level and only the
post-processing stuff is really shared by all messages.

// FREEBIE
2015-09-28 13:33:26 -07:00
lilia
f9ce27f2c8 Refactor index.js
There is no in-window navigation in the chrome app environment, so nix
the first if-clause here. Also make it programmatically reloadable and
fix indentation.

// FREEBIE
2015-09-25 17:57:23 -07:00
lilia
2bdd0106e7 Add comments
// FREEBIE
2015-09-25 11:10:25 -07:00
lilia
eb1cfe9b70 Move notification listeners to background
Otherwise they will be re-registered by the frontend page.

// FREEBIE
2015-09-25 11:10:14 -07:00
lilia
3bf9e36ead Move function declarations out of storage.onready 2015-09-24 10:39:56 -07:00
lilia
c8e51563a0 Refactor initial sync codepath to application layer
To reduce dependence on the message sending module, AccountManager
should send no sync requests itself.
2015-09-24 10:38:58 -07:00
lilia
6123c419d0 Remove refreshGroup
1. This is nonstandard behavior, not supported by any other clients. It
   may help sometimes but will also cause bugs (see 2)

2. iOS doesn't handle group updates with missing fields. all fields must
   be populated, and libtextsecure doesn't have any knowledge of the group
   name or avatar, so these updates will clobber group state on iOS.

// FREEBIE
2015-09-23 16:45:09 -07:00
lilia
94e1c2d123 Remove check for .humanError property
This property is no longer used by any of our errors.

// FREEBIE
2015-09-23 16:45:09 -07:00
lilia
6547538458 Use foreach instead of a loop
This syntax makes plain that the function is not used anywhere else,
and increases linearity/readability.

// FREEBIE
2015-09-23 16:45:08 -07:00
lilia
acaf7b8de2 Refactor relay consistency check
Check the device list for relay consitency and throw an exception before
attempting to encrypt to any of the mismatched devices.

// FREEBIE
2015-09-23 16:45:08 -07:00
lilia
bafc61600c Refactor sendMessageToDevices
Leverage map and Promise.all for more concise and linear code flow.
2015-09-23 16:45:07 -07:00
lilia
9ff95c7e61 DRY up group update sending
// FREEBIE
2015-09-23 16:45:07 -07:00
lilia
f00d118c93 More logging
// FREEBIE
2015-09-23 16:30:30 -07:00
lilia
f6b35ffbfc Log error stack traces
// FREEBIE
2015-09-23 16:30:30 -07:00
lilia
213dbdefd2 Reorder functions
// FREEBIE
2015-09-23 16:30:30 -07:00
lilia
62c90e3925 Don't save/log websocket error
It's a generic error Event and doesn't actually contain anything useful.

// FREEBIE
2015-09-23 16:30:30 -07:00
lilia
289b82d1dc Expose messageReceiver.close
// FREEBIE
2015-09-23 16:30:29 -07:00
lilia
1d370857fc Remove unused callback arguments
Unused since d0fd3e94 afaict.

// FREEBIE
2015-09-23 16:07:21 -07:00
lilia
2204ef863d Fix event name
We successfully retry after a websocket connection closes, but this typo
prevented us from retrying if the websocket simply never opened.

// FREEBIE
2015-09-23 16:07:20 -07:00
lilia
d1191c509c Log outgoing errors individually
// FREEBIE
2015-09-21 11:48:57 -07:00
lilia
ada3d999e0 Log outgoing errors
// FREEBIE
2015-09-21 11:02:33 -07:00
lilia
ce49d14d85 Fix leave group bug
This one's been around since forever, but only manifests when someone
leaves the group and comes back. In that case we fail to reinit their
numberRegistrationId object, which causes a npe when we try to send
send them group messages.

Affected parties must ask their fickle friends to leave/join again.

// FREEBIE
2015-09-21 11:00:12 -07:00
lilia
4a482243d0 Simplify event arguments
// FREEBIE
2015-09-21 10:32:35 -07:00
lilia
c8a76ab38e Fix websocket event handler name
// FREEBIE
2015-09-21 10:32:35 -07:00
lilia
21667d9181 Log when we start waiting for an online event
// FREEBIE
2015-09-21 10:32:35 -07:00
lilia
823f570955 Add more websocket debug logging
// FREEBIE
2015-09-21 10:32:34 -07:00
lilia
f70e844cef Include url in http response logging
Otherwise it's impossible to tell which is which, especially when
sending group messages.

// FREEBIE
2015-09-21 10:32:34 -07:00
lilia
d8803ee31f Mark leave group messages as sent
// FREEBIE
2015-09-21 10:32:33 -07:00
lilia
b1d3829651 Update minimal window dimensions
Some day we'll probably lower these minimums but first we'd need a more
responsive design.

Fixes #310

// FREEBIE
2015-09-18 13:13:31 -07:00
lilia
960754ef04 Restyle compose button
Move it to a tool bar at the top of the conversation list. This is also
where a search bar will live someday.

Fixes #357

// FREEBIE
2015-09-18 13:08:52 -07:00
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