Fix flickering avatar in firefox

pull/1/head
yflory 7 years ago
parent 4db4f66786
commit 0ce32464fd

@ -1,4 +1,4 @@
define(function () {
define(['json.sortify'], function (Sortify) {
var module = {};
module.create = function (info, onLocal, Cryptget, Cryptpad) {
@ -15,6 +15,7 @@ define(function () {
var parsed = Cryptpad.parsePadUrl(window.location.href);
var appType = parsed ? parsed.type : undefined;
var oldUserData = {};
var addToUserData = exp.addToUserData = function(data) {
var users = userList.users;
for (var attrname in data) { userData[attrname] = data[attrname]; }
@ -28,6 +29,10 @@ define(function () {
}
if(userList && typeof userList.onChange === "function") {
// Make sure we don't update the userlist everytime someone makes a change to the pad
if (Sortify(oldUserData) === Sortify(userData)) { return; }
oldUserData = JSON.parse(JSON.stringify(userData));
userList.onChange(userData);
}
};

@ -1793,12 +1793,15 @@ define([
};
var $userAdmin = createDropdown(dropdownConfigUser);
var oldUrl;
if (account && !config.static && store) {
var $avatar = $userAdmin.find('.buttonTitle');
var updateButton = function (newName) {
var profile = store.getProfile();
var url = profile && profile.avatar;
if (oldUrl === url) { return; }
oldUrl = url;
$avatar.html('');
common.displayAvatar($avatar, url, newName, function ($img) {
if ($img) {

@ -1,4 +1,4 @@
define([], function () {
define(['json.sortify'], function (Sortify) {
var UNINIT = 'uninitialized';
var create = function (sframeChan) {
var meta = UNINIT;
@ -102,7 +102,9 @@ define([], function () {
return Object.freeze({
updateMetadata: function (m) {
if (JSON.stringify(metadataObj) === JSON.stringify(m)) { return; }
// JSON.parse(JSON.stringify()) reorders the json, so we have to use sortify even
// if it's on our own computer
if (Sortify(metadataLazyObj) === Sortify(m)) { return; }
metadataObj = JSON.parse(JSON.stringify(m));
metadataLazyObj = JSON.parse(JSON.stringify(m));
change(false);

@ -208,15 +208,17 @@ define([
var $displayName = $userAdmin.find('.'+displayNameCls);
var $avatar = $userAdmin.find('.buttonTitle');
var oldUrl;
var updateButton = function () {
var myData = metadataMgr.getUserData();
if (!myData) { return; }
var newName = myData.name;
var url = myData.avatar;
$displayName.text(newName || Messages.anonymous);
if (accountName) {
if (accountName && oldUrl !== url) {
$avatar.html('');
UI.displayAvatar(Common, $avatar, url, newName, function ($img) {
oldUrl = url;
if ($img) {
$userAdmin.find('button').addClass('avatar');
}

@ -188,7 +188,6 @@ define([
var $editUsersList = $('<div>', {'class': 'userlist-others'});
// Editors
// TODO iframe enable friends
var pendingFriends = Common.getPendingFriends();
editUsersNames.forEach(function (data) {
var name = data.name || Messages.anonymous;

Loading…
Cancel
Save