Commit graph

852 commits

Author SHA1 Message Date
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
lilia
7afd0a02e8 Convert beforeunload listeners 2015-05-15 11:39:23 -07:00
lilia
002ff45312 Adapt window management to chrome app window api
Appify tabs, windows, browserAction

Port the extension.windows.focus function to new window api and
generalize its error handling in the case where the requested window
does not exist. An error will be passed to the callback.

Port extension.browserAction and rename it to the more generic
extension.onLaunched.

Use of the id option when opening a window ensures that attempting to
open a duplicate window merely focuses the existing window.

Finally, after registration, close the options window and open the
inbox.

Port extension.remove
2015-05-15 11:39:22 -07:00
lilia
ddbaf87741 Load notifications script from background page 2015-05-15 11:39:22 -07:00
lilia
f90f6328dd Don't resolve the background page til storage is ready 2015-05-15 11:39:22 -07:00
lilia
704c6ce779 Signaling key is now an array buffer 2015-05-15 11:39:22 -07:00
lilia
3f37cd21a9 Remove remaining traces of localStorage
Add window.storage to the background page, which loads all data from the
'items' store in indexeddb, caching them in memory for synchronous
access, then override textsecure storage to use that in memory store.
2015-05-15 11:39:19 -07:00
lilia
a3c5b0959f Port textsecure.storage.impl to indexeddb 2015-05-15 11:38:15 -07:00
lilia
d230df5622 Move local identitykey and registrationid to indexeddb 2015-05-15 11:38:14 -07:00
lilia
fe1d78b5fa Load protobufs asynchronously. Fixes #223 2015-05-15 11:38:14 -07:00
lilia
b8c5bc293c App windows cannot be refreshed 2015-05-15 11:38:10 -07:00
lilia
76e170686a Make getBackground async 2015-05-12 15:39:15 -07:00
lilia
7799bef86c Tweak key conflict error messages
Be generic, because sometimes it's not TextSecure, but Signal.
2015-05-07 17:43:30 -07:00
lilia
915612114b Remove general get/put/remove methods from AxolotlStore 2015-05-06 18:14:32 -07:00
lilia
d0e262d7cb AxolotlStore stores groups in indexeddb 2015-05-06 17:49:31 -07:00
lilia
359b4a15a2 Move group storage to axolotl store
Add async get/put/removeGroup to axolotl store and let libtextsecure
use it for group state storage.
2015-05-06 17:49:23 -07:00
lilia
748f32022a Fix up refreshGroup 2015-05-06 13:49:20 -07:00
lilia
f774047935 Make libtextsecure group storage asynchronous 2015-05-06 13:11:12 -07:00
lilia
c26c6fc317 Store sessions by encodedNumber
Storing multiple sessions in a single indexeddb record is prone to
clobbering data due to races between requests to update multiple device
sessions for the same number, since you have to read the current state
of the device->session map and update it. Splitting the records up makes
it so that those updates can be made in parallel. Selecting all the
sessions for a given number can still be done efficiently thanks to
indexeddb range queries.
2015-05-05 17:44:59 -07:00
lilia
37c496f4f0 Close the provisioning socket 2015-05-05 17:44:59 -07:00
lilia
43d6efcd9e Don't save device objects to disk
Generate them from session and identity data. Save/delete pending prekey
data in an in-memory store and attach it to outgoing device objects.
2015-05-05 17:44:59 -07:00
lilia
f18795a253 Add removeSession 2015-05-05 17:44:58 -07:00
lilia
f413f03a6b Add getDeviceIds to axolotlstore
And add tests for getDeviceIds and removeAllSessions
2015-05-05 17:44:58 -07:00
lilia
121671c99f Store identity keys in indexeddb
Let device storage request them from axolotl store rather than storing a
copy.
2015-05-05 17:44:58 -07:00
lilia
7eda48f755 Move Session Storage to indexedDB 2015-05-05 17:44:58 -07:00
lilia
20ebc3f890 Move identity key storage functions to axolotl store 2015-05-05 17:44:58 -07:00
lilia
f38b18ef63 Move Session storage to axolotlstore 2015-05-05 17:44:57 -07:00
lilia
9de1572ba6 Convert all storage.devices methods to be asynchronous 2015-05-05 17:44:57 -07:00
lilia
71715c95bc Async remove identity 2015-05-05 17:44:57 -07:00
lilia
26f1aa4db5 Async putSessionsForDevice 2015-05-05 17:44:57 -07:00
lilia
666f6baaca Async getSessionsForNumber 2015-05-05 17:44:56 -07:00
lilia
9e7d8c0a08 Rename textsecure.api and make it internal-only 2015-05-05 17:44:56 -07:00
lilia
45a61780af Fixup refreshPreKeys and call it whenever a prekey is deleted 2015-05-05 17:44:56 -07:00
lilia
7d0aeac8cb Use a worker to facilitate key generation 2015-05-05 17:44:55 -07:00
lilia
f465bdddbf Add textsecure.AccountManager
This class should be used for account registration and for refreshing
prekeys for your account.
2015-05-05 17:44:55 -07:00
lilia
a960acacc6 Add textsecure.refreshKeys
This helper checks the server for the number of remaining prekeys, then
generates more if there are fewer than 10 remaining.

// FREEBIE
2015-05-05 17:44:55 -07:00
lilia
96eafc7750 Integrate libaxolotl async storage changes
* Session records are now opaque strings, so treat them that way:
  - no more cross checking identity key and session records
  - Move hasOpenSession to axolotl wrapper
  - Remote registration ids must be fetched async'ly via protocol wrapper
* Implement async AxolotlStore using textsecure.storage
* Add some db stores and move prekeys and signed keys to indexeddb
* Add storage tests
* Rename identityKey storage key from libaxolotl25519KeyidentityKey to
  simply identityKey, since it's no longer hardcoded in libaxolotl
* Rework registration and key-generation, keeping logic in libtextsecure
  and rendering in options.js.
* Remove key_worker since workers are handled at the libaxolotl level
  now
2015-05-05 17:44:55 -07:00
lilia
8304aa903a Update libaxololt to a087b9e746e67995f16e077183cc0 2015-05-05 17:44:54 -07:00
lilia
2ff954d2f8 Fix api.js 2015-05-04 15:14:58 -07:00
lilia
cc6a44f35d Fix tests 2015-05-01 12:13:03 -07:00
lilia
da34b8e0f8 Rename textsecure.websocket and make it internal-only 2015-04-30 15:07:35 -07:00
lilia
89c24cd2fa Move throwHumanError to api.js
It is only used there.
2015-04-30 12:26:13 -07:00
lilia
36b1e87214 Add textsecure.MessageReceiver
Encapsulate the websocket resources and socket setup process in a
friendly OO class. The MessageReceiver constructor expects an instance
of EventTarget on which to fire message events asynchronously. The
provider of the EventTarget can then add/remove listeners as desired.
2015-04-29 16:50:20 -07:00
lilia
bf2bf4cfd9 Remove redirect to index from registration.done() 2015-04-29 13:39:41 -07:00
lilia
6f3de68834 Move browserAction call 2015-04-29 12:22:12 -07:00
lilia
37e09da1cc Remove unsued argument from getDeviceObject
Last usage of the `returnIdentityKey` argument was removed in 8b9a16852.
2015-04-20 17:20:58 -07:00
lilia
bdecf5cc44 Generate key_worker.js
Instead of calling importScripts, which is prone to relative path
issues, generate the worker script with everything it needs included.
2015-04-15 15:38:57 -07:00
lilia
7af42a27c5 Fix registerKeys using array indices for key ids
preKeys is an array whose indices may or may not be keyId-based. Since
we have an inline keyId property, use that instead.
2015-04-15 15:23:08 -07:00
lilia
00989962d8 Rename worker script file 2015-04-15 14:42:01 -07:00
lilia
de65f9e6bd Add missing resolve 2015-04-15 12:24:29 -07:00
Patrick Connolly
b5d724ffc3 Replaced frontend getString calls broken in d3c158f.
Closes #224
2015-04-15 11:56:36 -07:00
lilia
90c742d57c More error logging 2015-04-09 14:45:46 -07:00
lilia
25224da12e Fix unsafe eval warning on registration page 2015-04-05 16:42:08 -07:00
lilia
23feeecbcf Wrap libts, don't leak into global namespace 2015-04-05 16:42:08 -07:00
lilia
c51773ab0e More helpful error logging 2015-04-05 16:42:07 -07:00
lilia
319332bb6f Add missing semicolon
:[
2015-03-29 16:37:26 -07:00
lilia
5d4298697c Use view.$ shorthand for scoped jquery searches
Wish I'd noticed that one earlier. http://backbonejs.org/#View-dollar
2015-03-29 16:29:05 -07:00
lilia
13ce354ab8 Registration UX improvements
Add some nice modal dialogs instead of confirmation alerts.
2015-03-26 15:20:17 -07:00
lilia
6d9c7182c4 Let the key worker close itself when done 2015-03-26 15:18:57 -07:00
lilia
d3dbf2328f Set unread count badge when background page is refreshed
Refreshing the background page unsets the badge.
2015-03-26 10:50:25 -07:00
lilia
bfe23d86aa Run key generation in a worker
Ground work for a smoother registration flow. Overall UX still needs
some polish but at least now we can have a progress gif or animation or
whatever. Also adds the phonenumber-confirmation step as a simple alert
box, which will be replaced with a nice dialogue in a later commit.
2015-03-26 10:49:52 -07:00
lilia
196aa28873 Fix NaN badge
lolNaNcat
2015-03-25 13:09:15 -07:00
Matt Corallo
8b9a168524 Store session information separately 2015-03-25 11:56:28 -07:00
Matt Corallo
e33c6fddda Do not rely on deviceObject.sessions anywhere in sendmessage 2015-03-25 11:56:27 -07:00
Matt Corallo
6c0f3ff1f0 Move session-storage logic to storage/devices from axolotl_wrapper 2015-03-25 11:56:27 -07:00
Matt Corallo
169097a409 Remove stale comments in axolotl_wrapper 2015-03-25 11:56:26 -07:00
Matt Corallo
89fefe4323 Create a textsecure.storage.impl to be overriden if desired 2015-03-25 11:56:26 -07:00
Matt Corallo
56bffdcfd3 Prefix libaxolotl-stored objects with "libaxolotl" 2015-03-25 11:56:26 -07:00
Matt Corallo
00cb420d37 Merge (un)encrypted storage layers 2015-03-25 11:56:25 -07:00
Matt Corallo
454b4726bd Replace load/decode/index around our own number with helpers 2015-03-25 11:54:55 -07:00
lilia
3759fe46e9 Account for -1 HTTPError code 2015-03-25 11:46:14 -07:00
lilia
e52224e481 Remove libtextsecure's jquery dependency
Use only the finest, hand-crafted, artisanal XMLHttpRequests.
2015-03-25 10:32:14 -07:00
lilia
a2d88b4fad Don't trigger notifications for sync messages 2015-03-24 18:12:33 -07:00
lilia
923bb8bbc9 Fix crash in message detail view
Fix crash when there's no contact for a group member.
2015-03-24 11:36:42 -07:00
lilia
e8cb4efaa4 Allow key conflict resolution for group updates
Creating a group with a member who's identity key has changed would
previously fail silently. Now, we catch and save the error, allowing the
same conflict resolution process as with regular messages.

Fixes #205
2015-03-24 10:11:39 -07:00
lilia
4bd46f80e7 Allow empty group avatar file input 2015-03-23 19:24:26 -07:00
lilia
ce36c36bd0 Include outgoing control messages in message history
So you know it worked.
2015-03-23 19:24:12 -07:00
lilia
f067bb9954 Remove dead code 2015-03-23 18:41:17 -07:00
lilia
fdb0935d6a Fix resolveConflicts for groups 2015-03-23 18:36:38 -07:00
lilia
6c3ac2de02 Collapse two views into one
We used to have a subview that branched on content/control messages, but
no more.
2015-03-23 18:30:16 -07:00
lilia
caddb8dc09 Smoother group create experience
Previously there was a long pause between confirming the group details
and opening the conversation. Fix by first saving/opening the
conversation, rather than waiting for the initial group update to finish
transmitting.
2015-03-23 17:33:46 -07:00
lilia
74e01c2a95 Re-render control messages if necessary 2015-03-23 16:41:03 -07:00
lilia
48b0e8832d Fix message detail contacts for incoming group message
Previously the From-field displayed all the group contacts.
2015-03-23 16:12:26 -07:00
lilia
bd82591b6c Remove extraneous listener 2015-03-23 16:05:55 -07:00
lilia
a7079206f4 Nicer looking end-session and group control messages 2015-03-23 15:49:31 -07:00
lilia
20baa795ad Fixes #198 Squished avatars
Refactor all avatar views to use a shared partial, then change it to a
background image. Requires allowing unsafe-inline styles in the CSP.
2015-03-23 14:01:18 -07:00
lilia
6509561795 Make badge count accurate
Previously it would reset when refreshing the inbox. Now it tracks
changes to conversation unreadCounts.

Fixes #200
2015-03-23 12:41:52 -07:00
lilia
24768712e0 Focus text input when opening a conversation 2015-03-23 12:19:33 -07:00
lilia
ebc8846fcb Fix bug in panels controller
Previously, we'd create a new model instance even when one already
existed in the inbox.
2015-03-23 12:19:33 -07:00
lilia
9474b16eba In rare cases, a group has no members 2015-03-23 12:19:32 -07:00
lilia
5ffa265559 Revert "Popout inbox"
This reverts commit 31e7d285e3.

This seemed like a nice feature, but the popup bubble isn't very
conducive to nontrivial user inputs, e.g. file inputs.

Fixes #211
2015-03-23 12:19:32 -07:00
lilia
06f4d4456d Fix empty notification on key conflicts 2015-03-20 10:47:58 -07:00
lilia
c526dbda5f Set up production build task
`grunt copy`

Closes #191
2015-03-19 18:34:56 -07:00
lilia
718f1a5e3d Improve notification contents
Include sensible descriptions of non-content messages. For group
messages, display the sender's name and avatar rather than the group's.
2015-03-19 18:34:10 -07:00
lilia
43ec4099c9 Reset the name field on new group form 2015-03-19 13:55:13 -07:00
lilia
11b822eaf3 Allow unknown groups
Save groups even if we've never heard of them. Previously
we would fail to save due to a missing 'type' attribute.
2015-03-19 13:54:03 -07:00
lilia
84237cae6f Fix standalone registration page 2015-03-18 18:14:21 -07:00
lilia
9930937707 Move handlePushMessageContent to message model
And retool message handling flow to helps us avoid instantiating
duplicate message and conversation models.
2015-03-18 16:29:03 -07:00
lilia
897d391817 Improve identity key conflict ux
Clicking on a key conflict message opens the message detail view,
which displays the contact(s) in this conversation. If the message
contains a key conflict with any of these contacts, a button is
displayed which attempts to resolve that conflict and any other
conflicts in the conversation that are related to that contact.
2015-03-18 16:29:02 -07:00
lilia
857eee5003 Divorce identity wipe from tryAgain functions
We'd like to live in a world where we can retry all the pending
conflicts in a conversation as a batch, which means we don't want to
wipe the identity key before processing each message. Thus, remove that
step from these handlers and encapsulate in a method on the conversation
model.
2015-03-18 16:29:02 -07:00
lilia
c642854ddf Extract app-level logic from libtextsecure
Ensure that both tryAgain functions return promises, allowing the
application to take appropriate action in the result of success or
failure. This lets us remove all dependency from libtextsecure on
app-level constructs like message objects/ids and the `extenion.trigger`
function.

Corresponding frontend changes to follow in another commit.
2015-03-18 16:29:02 -07:00
lilia
e88d4d8170 Tweak replayable errors
1. Return the value returned by the registered function, to expose the
underlying promise to the caller.

2. Stop accepting extra arguments to the replay function. The caller
should be able to do what they want with the returned promise instead.

3. Add a timestamp argument to the outgoing case, needed to re-try
sending a message.
2015-03-18 16:29:01 -07:00
lilia
31e7d285e3 Popout inbox
Rather than opening the inbox in its own window, let it appear as a
browser action popup by default, but allow promotion to its own window
if requested.
2015-03-18 16:29:01 -07:00
lilia
cecb438a52 Simplify avatar rendering 2015-03-18 16:29:01 -07:00
lilia
fa3699cdd3 Trigger desktop notifications
Notifications show the conversation name, avatar, and new message text.
Clicking the notification opens the conversation.
2015-03-18 16:29:01 -07:00
Matt Corallo
d3c158f4cf Move libaxolotl out-of-tree 2015-03-17 14:43:23 -07:00
Matt Corallo
e2e06b2d3c Remove axolotl.storage usage from libtextsecure 2015-03-17 13:59:25 -07:00
lilia
b790f82849 Remove libaxolotl dependency on textsecure/errors.js
Let libaxolotl throw a generic error instead of a replayable error, and
add an helper function in libtextsecure's axolotl_wrapper to catch and
convert from the generic error to the replayable one. This allows the
ReplayableError to remain a libtextsecure-level concept only.

Somewhat unrelatedly, but nearby, fix some whitespace and add missing
semicolon.
2015-03-17 13:59:24 -07:00
lilia
676ad04958 Add device storage method to wipe an identity 2015-03-17 13:59:24 -07:00
lilia
f86d6d51e3 Only init emoji map once.
`emoji.init_colons` creates and populates `emoji.map.colons`, a global
map from common names to emoji code points. It's safe to call
repeatedly, but unecessary.
2015-03-16 17:44:49 -07:00
lilia
9e04910124 Recompile curve25519 with emcc 1.29.0
Now with actual malloc/free implementations. Had to drop back to -O1
optimization because the ed25519 signature test broke with -O2. :(

Closes #153

The toolchain install and build process, for reference:
```
wget https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz
tar xvfz emsdk-portable.tar.gz
cd emsdk-portable
./emsdk update
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
cd ../TextSecure-Browser
grunt build
```
2015-03-16 16:07:47 -07:00
lilia
08ccdf8d97 Move most scripts to the background page
Dramatically improve load times for frontend pages.

Closes #133
2015-03-16 11:57:41 -07:00
lilia
651b6341fa Unbind frontend listeners when window closes 2015-03-14 20:46:00 -07:00
lilia
69d5a6a33c Improve group update ui/ux
Promote group update to its own screen. Add typeahead contact selector
from new conversation view. Restyle to match android (more or less).

Closes #186
2015-03-13 17:33:02 -07:00
lilia
d20e23402d Refactor RecipientsInputView from NewConversationView
For reuse on group update screen.
2015-03-13 17:29:28 -07:00
Florian Groh
617b7686f7 Register Input Handling
I had some trouble with the registration..
Quickly checked TextSecure Server API and found the problems:
number has to be valid PSTN. (Including regionCode, precisely what validateNumber() returns)
verificationCode has to be all numbers, no dashes or spaces

Closes #193
2015-03-13 10:33:07 -07:00
lilia
0ac323961b Close the inbox if the background page is refreshed 2015-03-12 11:23:41 -07:00
lilia
36319d6458 Fix crash when sending :invalid_emoji: 2015-03-12 11:03:11 -07:00
lilia
04796e56d1 Fix tests 2015-03-11 20:41:15 -07:00
lilia
f1309b71c1 Don't scale or compress gifs
If a gif is too large, it's too large.

Fixes #196
2015-03-11 20:20:54 -07:00
lilia
8e54aa1401 Plumb contact avatars into conversations 2015-03-11 17:49:01 -07:00
lilia
019a9d1fbc Unread counts
Update unreadCounts per-conversation on incoming messages. Render unread
conversations with font-weigh: bold in the inbox view.

To ensure that the inbox and conversation views remain in sync, the
background page now ensures that the same models objects are used for
both views.
2015-03-11 15:13:36 -07:00
lilia
b9969b14b6 Always reconnect the socket except when there is an error
Turns out we can get ABNORMAL_CODE (1006) for disconnects where (for
instance) we pause the background page too long. However, in these cases
there is no preceeding ErrorEvent. In contrast, when we have bad
authentication credentials, there is an ErrorEvent. Thus, this change
ensures that we only reconnect if there was no Error.
2015-03-11 14:12:25 -07:00
lilia
5becd80fe9 Show an error if a conversation window fails to init
I saw this happen once. Seems to be a race condition.
2015-03-11 14:12:25 -07:00
lilia
0cbad730ce Don't send keepalive if socket has closed
Also shorten the timeout to see if it improves websocket connection
reliability.
2015-03-11 14:12:25 -07:00
lilia
2b073f3365 Reset keepalive timer if we're about to send
No sense in sending more keepalives than necessary.
2015-03-11 11:12:14 -07:00
lilia
ed707db4ba Support :emoji_name: syntax for emoji text input 2015-03-10 18:54:07 -07:00
lilia
01092075ac Add js-emoji as a component 2015-03-10 18:15:31 -07:00
lilia
254131488e Render emoji in conversation and inbox views. 2015-03-10 18:15:31 -07:00
lilia
99d599e008 Add twemoji as a component 2015-03-10 18:15:30 -07:00
lilia
7e5e558ad5 Bump keepalive to 60s 2015-03-10 18:14:12 -07:00
lilia
c73f4d71a7 DRY up scrollable pattern
Switch to using gutter class instead of id since there is potentially
more than one usage on the page.
2015-03-09 16:05:06 -07:00
lilia
a72ea7966d Clean up inbox/compose view rendering and swapping
Templatize the inbox view and use the same pattern for in-window view
switching as is now used with the conversation/message detail views.
This means doing more with markup and less jquery manipulation of
individual subelements of the inbox view.
2015-03-09 16:05:06 -07:00
lilia
fd6e2954f7 Curtail over-zealous websocket reconnects
Closes #173

Previously, in the event of a failed websocket auth, we would attempt to
reconnect once a second ad infinitum. This changeset ensures that we
only reconnect automatically if the socket closed 'normally' as
indicated by the code on the socket's CloseEvent. Otherwise, show a
'Websocket closed' error on the inbox view.

Ideally we would show a more contextual error (ie, 'Unauthorized'), but
unfortunately the actual server response code is not available to our
code. It can be observed in the console output from the background page,
but programmatically, we only receive the WebSocket CloseEvent codes
listed here:
https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes

The websocket error message is displayed by a normally-hidden but ever
present socket status element. Clicking this element will immediately
refresh the background page, which will try again to open the websocket
connection.
2015-03-09 16:04:26 -07:00
lilia
1321a90667 Rename Whisper.View#attributes
Avoid colliding with Backbone.View attributes, which is a list of attrs
to set on the html element for a view.
2015-03-06 17:05:36 -08:00
lilia
dc1b09f59d Auto-link urls in message bodies
And watch out for xss.

Closes #187
2015-03-06 17:01:04 -08:00
lilia
8ee282b1aa Restyle registration page
When first intalling, users will no longer be presented with the option
to register as a standalone client.

For developer convenience, the standalone form can still be found at
chrome-extension://.../register.html

Closes #159
2015-03-06 15:27:49 -08:00
lilia
01d5881a71 Remove unneeded if-gaurd 2015-03-05 17:48:07 -08:00
lilia
b65190e101 Break a long line 2015-03-05 16:30:59 -08:00
lilia
99787753a8 Stop re-rendering attachments on delivery receipt
Only re-render a message if the body changed. Re-render only the
delivery receipt checkmark if the delivered property changes.

Fix a bug where attachments flash in and out of existance when a
delivery receipt arrives.
2015-03-05 16:14:51 -08:00
lilia
dfe7813e7f Fix multiple from address in message detail 2015-03-05 15:54:23 -08:00
lilia
2ee34343a8 Use consistent boiler plate throughout js files 2015-03-05 15:45:35 -08:00
lilia
f89cf890df Clean up older views, mostly whitespace 2015-03-05 15:39:44 -08:00
lilia
44a31f3ed9 Remove unneeded function 2015-03-05 15:36:48 -08:00
lilia
1bb480f6ea DRY up a common view pattern
Define a Whisper.View base class that automatically parses and renders
templates and attributes defined by the subclass. This saves us a good
number of lines of code as well as some marginal memory overhead, since
we are no longer saving per-instance copies of template strings.
2015-03-05 15:36:35 -08:00
lilia
7c9ad975bb Unravel image processing recursion and fix bugs
Although I find the previous implementation more elegant, it results in
a deeper nesting of Promises than necessary, which can make debugging
more complicated. The canvas scaling and compression apis are actually
synchronous, so the callback structure isn't really recessary here.
Converting to a loop also makes this process easier to understand at
a glance.

Fixed some bugs along the way:
* accidentally scaling small images up to 1920px
* jpeg compressing gifs and other formats even if unnecessary
2015-03-04 18:43:38 -08:00
lilia
0da04632f2 Scale large images even if they are small
Previously we would not scale large resolution images with small file
sizes, but in fact, both resolution and file size constraints should be
enforced.
2015-03-04 16:07:02 -08:00
lilia
567a48e82b Adjust widths of bubbles and chat window
With these changes, message bubbles in the default-sized chat popup are
just wide enough to display the full complement of html5 media player
controls.
2015-03-04 15:59:28 -08:00
lilia
8bc77fa02b Automatically compress and scale large images
Do nothing to other file types. Continue to block files that are too
large even after scaling and compression.
2015-03-04 13:59:30 -08:00
lilia
37d20b986b Add canvas.toBlob polyfill 2015-03-03 18:44:18 -08:00
lilia
68d68e9009 Add blueimp lib for html5's canvas-based image scaling 2015-03-03 17:50:11 -08:00
lilia
258a872ce3 Trigger update events after attachments load
Mostly so we can ensure we're scrolled to the bottom when the
conversation is loaded.
2015-03-03 13:23:55 -08:00
lilia
f9ca13a86f DRY up audio and video views 2015-03-03 13:05:39 -08:00
lilia
df06499a19 Use blob urls to display attachments
Converting attachment data to base64-encoded data uris takes O(n) and
there's no need! URL.createObjectURL returns a magic link that can be
set as the `src` attribute to `img`, `video`, and `audio` tags to load
blob data directly without copying.

https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
2015-03-03 13:05:24 -08:00
lilia
4cefd17ac6 Remove unused view 2015-03-03 10:55:04 -08:00
lilia
9d94bce92a After clearing messages, leave conversation open
Fixes #178
2015-03-03 10:39:10 -08:00
lilia
0778854cc4 Attachments should be in spans, not divs 2015-03-02 18:37:20 -08:00
lilia
1311f7c9ae Fix attachment previews for audio/video files 2015-03-02 18:27:14 -08:00
lilia
6fe262ceed Lazy init file input's FileReader 2015-03-02 18:01:59 -08:00
lilia
db7dee9a8a Fixup file size warning
Add contentType-specific limits, switch to lazy-init iff we encounter an
oversized file, and restyle as a toast, factoring out a generic
ToastView along the way.
2015-03-02 17:50:03 -08:00
lilia
ddc0ed1b9a Add audio and video players
Basic implementation using html5 audio/video tags and data URIs.
2015-03-02 15:49:14 -08:00
lilia
aa659877be Fix broken file input view 2015-03-02 15:35:04 -08:00
lilia
dcc1588219 Add key verification screen
Accessible from the menu on private conversations.
2015-02-26 22:26:46 -08:00
lilia
c08c29bd4a Render group members in the message detail view
This requires that we fetch contact info when opening a conversation
so that's available for rendering contact names and avatars.
2015-02-26 13:35:04 -08:00
Matt Corallo
2277b41639 Remove non-existant device messages 2015-02-26 12:13:56 -08:00
Matt Corallo
5abf3073d5 Check END_SESSION messages in processDecrypted 2015-02-26 12:11:05 -08:00
Matt Corallo
29192edcb8 Ignore END_SESSION on messages with a sync context 2015-02-26 12:11:04 -08:00
Matt Corallo
9c3f8a1868 Dont send group-update right before we quit the group
Fixes #166
2015-02-25 15:59:49 -08:00
lilia
fd30dc6f1a Add message detail view 2015-02-23 14:03:35 -08:00
lilia
368cd2f79a Refactor back button style
Make it easier to reuse these styles.
2015-02-23 12:52:15 -08:00
Matt Corallo
f2853d00e6 Merge pull request #167 from WhisperSystems/sync
Sync outgoing individual and group messages
2015-02-20 12:39:26 -08:00
lilia
f860cb4492 Return end session messages to the frontend
So we can save them in the message history, and because the caller
expects a promise.
2015-02-20 10:30:43 -08:00
lilia
55c46d1bb6 Close conversation menu when clicking outside it 2015-02-19 11:55:31 -08:00
lilia
e853c21c98 Remove unused code
There is no .settings-btn or .go-back in this view.
2015-02-19 11:00:29 -08:00
lilia
ec43a0b633 jshint all the things
Small style fixes here and there. Removed one unused file.
2015-02-19 00:22:23 -08:00
lilia
09704444e9 Fix missing delivery receipt checkmarks
The delivered class should be updated on each render to ensure it is
up to date.
2015-02-18 23:57:19 -08:00
lilia
06e8e0dca7 Remove an extension.trigger
No need to trigger an extension-wide event now that all our models live
in the background page. We can just update them more or less directly.
2015-02-18 23:56:13 -08:00
lilia
626b63ee7c Fix some jshints 2015-02-18 23:41:45 -08:00
lilia
3292177a96 Remove resize logic in favor of pure css 2015-02-18 23:09:34 -08:00
lilia
07e44ccf21 Revisit resize and scroll logic once more
Wait a little longer on initial scroll down. Previous timeout sometimes
triggered before all text is finished rendering.

Remove redundant resize calls.
2015-02-18 16:54:43 -08:00
lilia
1bdb42b67e Fix bug loading conversation upsidedown
Sometimes a conversation's messages would be reverse-ordered on first
load, correcting themselves after a refresh. This is an artifact of the
order we load messages from the database. To fix, load them in the
opposite order.

The alternative solution would be to reset the collection every time we
fetch new messages, but this would create an entirely new set of model
objects each time, which seems unnecessary.
2015-02-18 15:40:34 -08:00
lilia
296dae544d Open conversation on receiving a message w/ errors 2015-02-18 12:17:46 -08:00
lilia
955ef60292 Fix list_view-related error in background page
Background page conversations were trying to trigger events on the inbox
list view which had been destroyed, resulting in a background page
console error of "can't read innerHeight of null".

Avoid this by removing listeners when the inbox window is closed.
2015-02-18 11:26:18 -08:00
lilia
1c589f2fad Fix list_view.js and message_view.js whitespace 2015-02-18 00:11:35 -08:00
lilia
61581bae7f Fix inbox comparator 2015-02-18 00:11:35 -08:00
lilia
4716754209 Refactor content message class names 2015-02-18 00:11:35 -08:00
lilia
40351fcc54 Sync outgoing messages
When sending an constrct a copy of the PushMessageContent protobuf, add
a SyncMessageContext, and send it to ourselves. Do this for all kinds of
group messages, and individual text/media messages, but not closeSession
messages as the latter are device-specific.

Do not sync messages if we are the primary device, which should only be
supported in development. Normal web clients must be paired with a
android or ios master device, and even in dev, a primary/standalone web
client does not support linking additional devices.
2015-02-17 14:10:42 -08:00
lilia
94c94eb7c9 Refactor message view
The message view has three flavors so far, a normal text+attachments
message, a group update, and an end session message. This changeset
extracts the normal message rendering into its own subview, and adds
some convenience functions to the message model in order to simplify
some of that flavoring logic.
2015-02-17 12:07:46 -08:00
lilia
85bec04010 Render leave-group messages correctly 2015-02-16 12:47:36 -08:00
lilia
367421d40a Style end session messages
Also add a missing call to render()
2015-02-13 16:21:39 -08:00
lilia
f00a8f1e81 Render end session messages correctly 2015-02-13 14:25:16 -08:00
lilia
488f25635d Wire up end session and leave group
Closes #136
Closes #137
2015-02-13 14:25:16 -08:00
lilia
85b4643e9b Fixes #161
The first message sent to a new contact was throwing 'Unknown Group'.
This was because we didn't wait for the initial save to sync the `type`
attribute to indexedDB. Instead, don't trigger the conversation to open
until it has finished saving.
2015-02-13 12:57:19 -08:00
Matt Corallo
b45c09470f Merge pull request #155 from WhisperSystems/closeSession
Fix textsecure.closeSession
2015-02-13 10:44:06 -08:00
Matt Corallo
04b1ab23a4 Merge pull request #154 from WhisperSystems/fixolotl
Fix provisioning flow
2015-02-13 10:43:35 -08:00
lilia
0e8a5806a8 Fix textsecure.closeSession
sendIndividualProto requires a timestamp.
2015-02-12 22:12:48 -08:00
lilia
96af6b56ef Handle incoming sync messages
Assign them to the correct conversation and mark them outgoing with the
correct timestamp.

Closes #150
2015-02-12 18:17:08 -08:00
lilia
65c70a9117 Fix provisioning flow
Fix undefined axolotl.protobufs.ProvisionMessage, referenced in
libaxolotl/protocol.js
2015-02-12 16:41:04 -08:00
Matt Corallo
148410a826 Move jquery dep from libaxolotl to libaxolotl tests 2015-02-12 15:12:02 -08:00
Matt Corallo
44a094c324 Re-run concat 2015-02-12 15:12:01 -08:00
Matt Corallo
f1f5914879 Re-run concat 2015-02-12 15:12:00 -08:00
Matt Corallo
cb6cb4ff89 Re-add jquery as it is needed for our test runners 2015-02-12 15:11:59 -08:00
Matt Corallo
8398a52c20 Re-run concat 2015-02-12 15:11:58 -08:00
Matt Corallo
bb32a51d66 s/textsecure.protocol/axolotl.protocol/ 2015-02-12 15:11:58 -08:00
Matt Corallo
403ae4376d Move attachment/websocket [en|de]cryption to libtextsecure 2015-02-12 15:11:58 -08:00
Matt Corallo
184b1ec89c Move protocol protobufs to libaxolotl/, handling DeviceControl 2015-02-12 15:11:58 -08:00
lilia
05a5b7e76c Fixes #152
Android client was crashing any time the base64-encoded public key
included a '+' due to lack of url encoding.
2015-02-12 15:09:52 -08:00
lilia
a104ee9ca6 Remove unused variables 2015-02-12 14:19:37 -08:00
lilia
44f9ea5d49 Fix identity key error rendering 2015-02-12 13:36:19 -08:00
lilia
9fe99adf0c Get scrolling right on conversation load 2015-02-12 13:21:18 -08:00
lilia
f5c7be7d35 Add some resizes 2015-02-12 13:21:18 -08:00
lilia
5a302271b3 Remove unneeded listeners 2015-02-12 13:21:18 -08:00
lilia
0463e385e8 Remove uneeded render
This is an artifact of a time when conversation elements would pop in
and out of the dom at a moment's notice, and thus needed to rebind their
event listeners regularly.
2015-02-12 13:21:18 -08:00
lilia
5e064db28f Render the message list view. 2015-02-12 13:21:17 -08:00
lilia
5ad5464dd1 Fetch messages in the background 2015-02-12 13:21:17 -08:00
lilia
52b3114970 Simplify list view resizing 2015-02-12 13:21:17 -08:00
lilia
3279dddcc3 Consolidate window logic in panel controller
Previously the conversation window would query the background page
for a model id and then fetch the conversation. Instead, we can fetch
the conversation before opening the window, which simplifies the front
end scripts and avoids creating multiple copies of the same model.
2015-02-12 13:21:17 -08:00
lilia
44b1e5c88e Move inbox collection to the background page
No more waiting, no more messy fetch logic. Background page
bootstraps the inbox and keeps it up to date.
2015-02-12 13:21:17 -08:00
lilia
a5bc261365 Clear selected files after each sent message 2015-02-12 13:21:17 -08:00
lilia
2de682ef7b Don't create a group without a name 2015-02-12 13:21:17 -08:00
lilia
d5c85dfbd8 Resize inbox listview after it finishes loading
Ensures that scrollbars are properly setup on load.
2015-02-12 13:21:17 -08:00
lilia
4422582ab7 Fixup opening existing private conversations 2015-02-12 13:21:17 -08:00
lilia
200981e022 Avoid adding empty-string numbers to recipients 2015-02-12 13:21:17 -08:00
lilia
3a099657e6 Untangle select vs open events 2015-02-12 13:21:17 -08:00
lilia
b27826cba5 Conversations must have an id before saving 2015-02-12 13:21:16 -08:00
lilia
a7a44e9b99 Swap in unminified typeahead code
For your debugging and auditing convenience.
2015-02-12 13:21:16 -08:00
lilia
9087918500 Don't add new convos to inbox until a message is sent 2015-02-12 13:21:16 -08:00
lilia
af49ad9b90 Dry up new contact init and handling 2015-02-12 13:21:16 -08:00
lilia
63d232dedb Draw attention to invalid numbers 2015-02-12 13:21:16 -08:00
lilia
746e6530b9 WIP pill view for selected recipients 2015-02-12 13:21:16 -08:00
lilia
c84ccfc735 Wrap model phonenumber validation in try/catch 2015-02-12 13:21:15 -08:00
lilia
eae072e72d Remove unneeded var, add todo 2015-02-12 13:21:15 -08:00
lilia
fc3a600e72 Validate conversation type 2015-02-12 13:21:15 -08:00
lilia
5e3ed1658b Show phone numbers in contact selector 2015-02-12 13:21:15 -08:00
lilia
9e245e67e0 Fix double-opening exsisting conversations from typeahead 2015-02-12 13:21:15 -08:00
lilia
b2345a5ec8 Remove unused variable 2015-02-12 13:21:15 -08:00
lilia
ce4ce164af Stop clobbering conversation attributes
Unless the background page fetches the latest details of a conversation
before updating it, it may clobber or nullify some attributes e.g., the
contact's name.
2015-02-12 13:21:15 -08:00
lilia
aca3db97da New messages auto-update the inbox & conversation
When a new message arrives, if its conversation is not already opened,
the background page opens it. If it is alrady open the window is
focused. Finally, the 'message' event is triggered, resulting in
   1. the inbox refetches conversations
   2. all conversations fetch new messages

TODO: only send this event to the target window
2015-02-11 17:38:03 -08:00
lilia
db5e7fd6b6 Fix list view scrolling
Resize handlers are ugly. But not as ugly as scroll handlers. :p
Normalized some whitespace along the way.
2015-02-11 17:38:03 -08:00
lilia
0f29cf2043 Put spaces between joined members in group updates 2015-02-11 17:38:01 -08:00
lilia
d435ff003b Improve typeahead contact selector experience
Store and match on various phone number formats. Still not perfect, as
occasionally all the models are returned for a non-matching query.
2015-02-11 17:38:01 -08:00
lilia
acc2c6f536 Sort contact selector by title 2015-02-11 17:38:01 -08:00
lilia
51dd287b60 Break up a long line 2015-02-11 17:38:01 -08:00