"use strict"; Vue.component('tf-user', { data: function() { return { show_user_dialog: false, show_follow_dialog: false, edit_profile_name: null, edit_profile_description: null, } }, props: ['id'], computed: { following: { get: function() { return g_data.users && g_data.users[g_data.whoami] && g_data.users[g_data.whoami].following[this.id]; }, set: function(newValue) { var already_following = g_data.users && g_data.users[g_data.whoami] && g_data.users[g_data.whoami].following && g_data.users[g_data.whoami].following[this.id]; if (newValue && !already_following) { if (confirm("Are you sure you want to follow " + this.id + "?")) { window.parent.postMessage({appendMessage: {type: "contact", following: true, contact: this.id}}, '*'); } } else if (!newValue && already_following) { if (confirm("Are you sure you want to unfollow " + this.id + "?")) { window.parent.postMessage({appendMessage: {type: "contact", following: false, contact: this.id}}, '*'); } } }, }, whoami: { get: function() { return g_data.whoami; } }, users: { get: function() { return g_data.users; } }, }, methods: { save_profile: function() { var message = {appendMessage: { type: 'about', about: this.id, name: this.edit_profile_name, description: this.edit_profile_description, }}; window.parent.postMessage(message, '*'); }, show_user: function() { this.show_user_dialog = true; if (this.id == this.whoami) { this.edit_profile_name = this.users[this.id].name; this.edit_profile_description = this.users[this.id].description; } }, }, template: ` {{users[id] && users[id].name ? users[id].name : id}} {{id}} {{users[id] && users[id].name ? users[id].name : id}}
Save Profile Close
`, });