*** some.js 2021-12-23
--- some.js 2021-12-24
***************
*** 2021,2027 ****
consultant_service_pid = inputs.consultant_service_pid;
const rsa_public_key = make_rsa_public_key(crypto.rsa_modulus_hex);
const other_users_array = array_to_obj(consultant_chat_other_users_schema, psv_to_array(inputs.consultant_chat_other_users)).array;
! const consultant_chat_info = generate_new_consultant_chat_info(rsa_public_key, inputs.consultant_service_pid, other_users_array);
assert(consultant_chat_info.consultant_service_pid === inputs.consultant_service_pid);
}
--- 2021,2027 ----
consultant_service_pid = inputs.consultant_service_pid;
const rsa_public_key = make_rsa_public_key(crypto.rsa_modulus_hex);
const other_users_array = array_to_obj(consultant_chat_other_users_schema, psv_to_array(inputs.consultant_chat_other_users)).array;
! consultant_chat_info = generate_new_consultant_chat_info(rsa_public_key, inputs.consultant_service_pid, other_users_array);
assert(consultant_chat_info.consultant_service_pid === inputs.consultant_service_pid);
}
***************
*** 4419,4429 ****
let dialog = show_dialog();
basic_data_post('/file_list', obj_to_uri({}), function(success, info, data_psv)
{
! const values = psv_to_array(data_psv);
let files = [];
! for (let i = 0; i < values.length; i += 2) {
! const pid = values[i + 0];
! const name = values[i + 1];
files.push({
t: 'a', classes: 'attach_file_list_file',
children: [
--- 4419,4432 ----
let dialog = show_dialog();
basic_data_post('/file_list', obj_to_uri({}), function(success, info, data_psv)
{
! const schema = [ {
! type: 'array', name: 'items', schema: [ 'pid', 'name' ]
! }];
! const items = array_to_obj(schema, psv_to_array(data_psv)).items;
let files = [];
! for (let i = 0; i < items.length; ++i) {
! const pid = items[i].pid;
! const name = items[i].name;
files.push({
t: 'a', classes: 'attach_file_list_file',
children: [
***************
*** 6312,6349 ****
}
});
! if (g_env.user_pid) {
! const script_init_data_schema = [
! {
! type: 'array',
! name: 'chats',
! schema: [
! 'group_pid',
! 'last_other_msg_timestamp',
! ]
! },
{
! type: 'array',
! name: 'groups',
! schema: [
! 'group_pid',
! ]
}
- ];
- const script_init_data_obj = array_to_obj(script_init_data_schema, psv_to_array(g_env.script_init_data));
- g_env.chat_init_data = script_init_data_obj.chats;
- g_env.groups_init_data = script_init_data_obj.groups;
! const stored_status = window.localStorage.getItem('kv_store_' + KV_STORE_KEY_CHAT_STATUS);
! if (stored_status)
! g_env.kv_store_cache[KV_STORE_KEY_CHAT_STATUS] = JSON.parse(stored_status);
!
! const stored_timestamps = window.localStorage.getItem('kv_store_timestamps');
! if (stored_timestamps)
! g_env.kv_store_timestamps = JSON.parse(stored_timestamps);
!
! update_notifications();
}
const try_start_push_notifications = function()
{
--- 6315,6332 ----
}
});
!
! window.addEventListener('focus', function()
{
! if (g_env.cur_chat_group_pid) {
! on_user_viewed_chat(g_env.cur_chat_group_pid);
}
! if (g_env.has_title_alert) {
! clearInterval(g_env.title_alert_timer);
! document.title = g_env.saved_title;
}
+ });
const try_start_push_notifications = function()
{
***************
*** 6409,6414 ****
--- 6392,6429 ----
};
document.addEventListener('click', try_start_push_notifications);
+ if (g_env.user_pid) {
+ const script_init_data_schema = [
+ {
+ type: 'array',
+ name: 'chats',
+ schema: [
+ 'group_pid',
+ 'last_other_msg_timestamp',
+ ]
+ },
+ {
+ type: 'array',
+ name: 'groups',
+ schema: [
+ 'group_pid',
+ ]
+ }
+ ];
+ const script_init_data_obj = array_to_obj(script_init_data_schema, psv_to_array(g_env.script_init_data));
+ g_env.chat_init_data = script_init_data_obj.chats;
+ g_env.groups_init_data = script_init_data_obj.groups;
+
+ const stored_status = window.localStorage.getItem('kv_store_' + KV_STORE_KEY_CHAT_STATUS);
+ if (stored_status)
+ g_env.kv_store_cache[KV_STORE_KEY_CHAT_STATUS] = JSON.parse(stored_status);
+
+ const stored_timestamps = window.localStorage.getItem('kv_store_timestamps');
+ if (stored_timestamps)
+ g_env.kv_store_timestamps = JSON.parse(stored_timestamps);
+
+ update_notifications();
+ }
let msg = window.sessionStorage.getItem('page_notification');
if (msg) {
***************
*** 6417,6438 ****
}
if (g_env.has_crypto_user) {
-
g_env.msg_sound = new Audio('/static/msg.ogg');
init_websocket();
}
! window.addEventListener('focus', function()
! {
! if (g_env.cur_chat_group_pid) {
! on_user_viewed_chat(g_env.cur_chat_group_pid);
! }
!
! if (g_env.has_title_alert) {
! clearInterval(g_env.title_alert_timer);
! document.title = g_env.saved_title;
}
- });
apply_js_to_elem_tree(document);
};
--- 6432,6444 ----
}
if (g_env.has_crypto_user) {
g_env.msg_sound = new Audio('/static/msg.ogg');
init_websocket();
}
! if (!g_env.user_pid) {
! clear_local_session_data(function() { });
}
apply_js_to_elem_tree(document);
};
***************
*** 6543,6548 ****
});
};
! if (typeof window !== 'undefined') { // Prevent running in web worker
init();
}
--- 6549,6554 ----
});
};
! if (typeof window !== 'undefined') { // Prevent running in service worker
init();
}