-
-
Notifications
You must be signed in to change notification settings - Fork 674
Description
As discussed in the comments at the end of #3739, there's some code in the webapp's static/js/hash_util.js
that would be good to move into a shared module, perhaps named narrow_encoding
.
There's one layer of this that should be pretty simple to do, and another that will involve some refactoring:
-
The functions
decodeHashComponent
andencodeHashComponent
are pure, so making them shared should just be a matter of moving some code, with no refactoring needed to their interfaces.They're very small which makes them not so bad to duplicate; but @ray-kraesig recently wrote a thorough set of test cases for the mobile implementation of
decodeHashComponent
, much more than the webapp has, and it'd be good to share those tests. -
The function
parse_narrow
, and the code it calls, encode a fair bit of complexity that would be good to share.This one will require some refactoring: a lot of that function's work gets done by
decode_operand
, and that relies onpeople.slug_to_emails
andstream_data.slug_to_name
, which in turn consult the app's data structures. So to share this code, it'll need to be explicitly passed a way to get that data. Specifically, we'll probably want to have it take a set of getter functions for the data it needs from those data structures.