Get initial messages from get_updates_longpoll

(imported from commit 2bb9c51409735abe23bad758338b13121aea4c99)
This commit is contained in:
Keegan McAllister 2012-09-26 13:44:21 -04:00
parent ee75f7ae8d
commit 12e458df80
3 changed files with 5 additions and 11 deletions

View File

@ -33,7 +33,6 @@
{% endif %} {% endif %}
<script type="text/javascript"> <script type="text/javascript">
var zephyr_array = {{ zephyr_array }};
var initial_pointer = {{ user_profile.pointer }}; var initial_pointer = {{ user_profile.pointer }};
var email = "{{ user_profile.user.email }}"; var email = "{{ user_profile.user.email }}";
var class_list = {{ classes }}; var class_list = {{ classes }};

View File

@ -22,6 +22,7 @@ function register_huddle_onclick(zephyr_row, sender) {
}); });
} }
var zephyr_array = [];
var zephyr_dict = {}; var zephyr_dict = {};
var status_classes = 'alert-error alert-success alert-info'; var status_classes = 'alert-error alert-success alert-info';
@ -759,12 +760,6 @@ function add_messages(zephyrs) {
add_to_table(zephyrs, 'zhome', function () { return true; }); add_to_table(zephyrs, 'zhome', function () { return true; });
} }
$(function () {
add_messages(zephyr_array);
select_and_show_by_id(initial_pointer);
get_updates_longpoll();
});
function clear_compose_box() { function clear_compose_box() {
$("#zephyr_compose").find('input[type=text], textarea').val(''); $("#zephyr_compose").find('input[type=text], textarea').val('');
} }
@ -787,6 +782,8 @@ function get_updates_longpoll() {
add_messages(data.zephyrs); add_messages(data.zephyrs);
$.each(data.zephyrs, function () { $.each(data.zephyrs, function () {
zephyr_array.push(this); zephyr_array.push(this);
if (this.id === initial_pointer)
select_and_show_by_id(initial_pointer);
}); });
} }
setTimeout(get_updates_longpoll, 0); setTimeout(get_updates_longpoll, 0);
@ -817,6 +814,7 @@ function get_updates_longpoll() {
} }
$(function () { $(function () {
get_updates_longpoll();
update_autocomplete(); update_autocomplete();
$('.button-slide').click(function () { $('.button-slide').click(function () {
show_compose('class', $("#class")); show_compose('class', $("#class"));

View File

@ -96,8 +96,6 @@ def home(request):
user_profile.pointer = min([zephyr.id for zephyr in zephyrs]) user_profile.pointer = min([zephyr.id for zephyr in zephyrs])
user_profile.save() user_profile.save()
zephyr_json = simplejson.dumps([zephyr.to_dict() for zephyr in zephyrs])
# Populate personals autocomplete list based on everyone in your # Populate personals autocomplete list based on everyone in your
# realm. Later we might want a 2-layer autocomplete, where we # realm. Later we might want a 2-layer autocomplete, where we
# consider specially some sort of "buddy list" who e.g. you've # consider specially some sort of "buddy list" who e.g. you've
@ -118,8 +116,7 @@ def home(request):
instances = list(set(zephyr.instance for zephyr in class_zephyrs)) instances = list(set(zephyr.instance for zephyr in class_zephyrs))
return render_to_response('zephyr/index.html', return render_to_response('zephyr/index.html',
{'zephyr_array' : zephyr_json, {'user_profile': user_profile,
'user_profile': user_profile,
'email_hash' : hashlib.md5(settings.HASH_SALT + user_profile.user.email).hexdigest(), 'email_hash' : hashlib.md5(settings.HASH_SALT + user_profile.user.email).hexdigest(),
'people' : simplejson.dumps(people), 'people' : simplejson.dumps(people),
'classes' : simplejson.dumps(classes), 'classes' : simplejson.dumps(classes),