Fix ability to create more than one team. Add chat notifications

pull/1/head
yflory 5 years ago
parent f8224ea427
commit 7a8908c93e

@ -13,7 +13,7 @@ define([
};
Notifier.notify = function (data) {
if (Visible.isSupported() && !Visible.currently()) {
if (Visible.isSupported() && (!Visible.currently() || (data && data.force))) {
if (data) {
var title = data.title;
if (document.title) { title += ' (' + document.title + ')'; }

@ -113,8 +113,12 @@ define([
var notifyToolbar = function () {
if (!toolbar || !toolbar['chat']) { return; }
if (toolbar['chat'].find('button').hasClass('cp-toolbar-button-active')) { return; }
toolbar['chat'].find('button').addClass('cp-toolbar-notification');
if (!toolbar['chat'].find('button').hasClass('cp-toolbar-button-active')) {
toolbar['chat'].find('button').addClass('cp-toolbar-notification');
}
if (!toolbar['chat'].hasClass('cp-leftside-active')) {
toolbar['chat'].find('span.fa').addClass('cp-team-chat-notification');
}
};
var notify = function (id) {
@ -568,12 +572,15 @@ define([
var el_message = markup.message(message);
common.notify();
if (message.type === 'MSG') {
var name = typeof message.name !== "undefined" ?
(message.name || Messages.anonymous) :
contactsData[message.author].displayName;
common.notify({title: name, msg: message.text});
common.notify({
title: name,
msg: message.text,
force: toolbar && toolbar.team && !toolbar['chat'].hasClass('cp-leftside-active')
});
}
notifyToolbar();

@ -195,6 +195,9 @@ define([
APP.$rightside.removeClass('cp-rightside-drive');
APP.$leftside.removeClass('cp-leftside-narrow');
}
if (key === 'chat') {
$category.find('.cp-team-chat-notification').removeClass('cp-team-chat-notification');
}
$categories.find('.cp-leftside-active').removeClass('cp-leftside-active');
$category.addClass('cp-leftside-active');
@ -205,7 +208,10 @@ define([
});
if (active === 'drive') {
APP.$rightside.addClass('cp-rightside-drive');
APP.$leftside.addClass('cp-leftside-narrow');
APP.$leftside.on('mouseover', function() {
APP.$leftside.addClass('cp-leftside-narrow');
APP.$leftside.off('mouseover');
});
} else {
APP.$rightside.removeClass('cp-rightside-drive');
APP.$leftside.removeClass('cp-leftside-narrow');
@ -360,11 +366,16 @@ define([
var isOwner = Object.keys(privateData.teams || {}).some(function (id) {
return privateData.teams[id].owner;
}) && !privateData.devMode; // XXX
if (Object.keys(privateData.teams || {}).length >= 3 || isOwner) {
content.push(h('div.alert.alert-warning', {
}) && !privateData.devMode;
var getWarningBox = function () {
return h('div.alert.alert-warning', {
role:'alert'
}, isOwner ? Messages.team_maxOwner : Messages._getKey('team_maxTeams', [MAX_TEAMS_SLOTS])));
}, isOwner ? Messages.team_maxOwner : Messages._getKey('team_maxTeams', [MAX_TEAMS_SLOTS]));
};
if (Object.keys(privateData.teams || {}).length >= 3 || isOwner) {
content.push(getWarningBox());
return void cb(content);
}
@ -384,7 +395,16 @@ define([
state = true;
APP.module.execCommand('CREATE_TEAM', {
name: name
}, function () {
}, function (obj) {
if (obj && obj.error) {
console.error(obj.error);
return void UI.warn(Messages.error);
}
// Redraw the create block
var $createDiv = $('div.cp-team-create').empty();
isOwner = true;
$createDiv.append(getWarningBox());
// Redraw the teams list
var $div = $('div.cp-team-list').empty();
refreshList(common, function (content) {
state = false;
@ -682,7 +702,10 @@ define([
return void UI.alert(Messages.error);
}
common.setTeamChat(obj.channel);
MessengerUI.create($(container), common, true);
MessengerUI.create($(container), common, {
chat: $('.cp-team-cat-chat'),
team: true
});
cb(content);
});
});

Loading…
Cancel
Save