forked from cory/tildefriends
Redid lots of things about viewing an invidual user's feed, their profile, and following users.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3740 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@@ -16,12 +16,20 @@ var g_data = {
|
||||
mentions: {},
|
||||
unread: 0,
|
||||
loading: true,
|
||||
selected: null,
|
||||
edit_profile_name: null,
|
||||
edit_profile_description: null,
|
||||
};
|
||||
|
||||
var g_data_initial = JSON.parse(JSON.stringify(g_data));
|
||||
var g_message_queue = [];
|
||||
var g_process_pending = false;
|
||||
|
||||
function updateEditUser() {
|
||||
g_data.edit_profile_name = g_data.users[g_data.whoami] ? g_data.users[g_data.whoami].name : null;
|
||||
g_data.edit_profile_description = g_data.users[g_data.whoami] ? g_data.users[g_data.whoami].description : null;
|
||||
}
|
||||
|
||||
function processMessages() {
|
||||
for (let event of g_message_queue) {
|
||||
var key = Object.keys(event.data)[0];
|
||||
@@ -56,6 +64,9 @@ function processMessages() {
|
||||
g_data[key + 's'].push(event.data[key]);
|
||||
} else if (key == 'user') {
|
||||
Vue.set(g_data.users, event.data.user.user, Object.assign({}, g_data.users[event.data.user.user] || {}, event.data.user.about));
|
||||
if (event.data.user.user == g_data.whoami) {
|
||||
updateEditUser();
|
||||
}
|
||||
} else if (key == 'followers') {
|
||||
if (!g_data.users[event.data.followers.id]) {
|
||||
Vue.set(g_data.users, event.data.followers.id, {});
|
||||
@@ -104,7 +115,10 @@ function processMessages() {
|
||||
} else if (key == 'unread') {
|
||||
g_data.unread += event.data.unread;
|
||||
} else if (key == 'hash') {
|
||||
console.log(event.data);
|
||||
g_data.selected = event.data.hash;
|
||||
if (g_data.selected == g_data.whoami) {
|
||||
updateEditUser();
|
||||
}
|
||||
} else {
|
||||
g_data[key] = event.data[key];
|
||||
}
|
||||
@@ -155,6 +169,14 @@ window.addEventListener('load', function() {
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
markdown: function(md) {
|
||||
if (!md) {
|
||||
return;
|
||||
}
|
||||
var reader = new commonmark.Parser({safe: true});
|
||||
var writer = new commonmark.HtmlRenderer();
|
||||
return writer.render(reader.parse(md));
|
||||
},
|
||||
refresh: function() {
|
||||
window.parent.postMessage({refresh: true}, '*');
|
||||
},
|
||||
@@ -168,6 +190,28 @@ window.addEventListener('load', function() {
|
||||
remove_from_mentions: function(link) {
|
||||
Vue.delete(g_data.mentions, link);
|
||||
},
|
||||
save_profile: function() {
|
||||
var message = {appendMessage: {
|
||||
type: 'about',
|
||||
about: g_data.selected,
|
||||
name: g_data.edit_profile_name,
|
||||
description: g_data.edit_profile_description,
|
||||
}};
|
||||
window.parent.postMessage(message, '*');
|
||||
},
|
||||
follow: function(id) {
|
||||
if (confirm('Are you sure you want to follow ' + id + '?')) {
|
||||
window.parent.postMessage({appendMessage: {type: "contact", following: true, contact: id}}, '*');
|
||||
}
|
||||
},
|
||||
unfollow: function(id) {
|
||||
if (confirm('Are you sure you want to unfollow ' + id + '?')) {
|
||||
window.parent.postMessage({appendMessage: {type: "contact", following: false, contact: id}}, '*');
|
||||
}
|
||||
},
|
||||
set_hash(hash) {
|
||||
window.parent.postMessage({action: 'setHash', hash: hash ? hash : '#'}, '*');
|
||||
},
|
||||
}
|
||||
});
|
||||
window.parent.postMessage('ready', '*');
|
||||
|
Reference in New Issue
Block a user