diff --git a/app/apps/client/gameCenter/gameCenter.js b/app/apps/client/gameCenter/gameCenter.js
index 91e092b4f97a..c7eef85de989 100644
--- a/app/apps/client/gameCenter/gameCenter.js
+++ b/app/apps/client/gameCenter/gameCenter.js
@@ -1,16 +1,15 @@
-import toastr from 'toastr';
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import { modal } from '../../../ui-utils/client';
-import { APIClient, t } from '../../../utils/client';
+import { APIClient, t, handleError } from '../../../utils/client';
const getExternalComponents = async (instance) => {
try {
const { externalComponents } = await APIClient.get('apps/externalComponents');
instance.games.set(externalComponents);
} catch (e) {
- toastr.error((e.xhr.responseJSON && e.xhr.responseJSON.error) || e.message);
+ handleError(e);
}
instance.isLoading.set(false);
@@ -98,7 +97,7 @@ Template.GameCenter.events({
'click .js-invite'(event) {
event.stopPropagation();
modal.open({
- title: t('Invite You Friends to Join'),
+ title: t('Apps_Game_Center_Invite_Friends'),
content: 'InvitePlayers',
data: this,
confirmOnEnter: false,
diff --git a/app/apps/client/gameCenter/gameContainer.html b/app/apps/client/gameCenter/gameContainer.html
index 6bbb136df0ed..7955cc95577d 100644
--- a/app/apps/client/gameCenter/gameContainer.html
+++ b/app/apps/client/gameCenter/gameContainer.html
@@ -5,7 +5,7 @@
{{#if showBackButton}}
diff --git a/app/apps/client/gameCenter/invitePlayers.js b/app/apps/client/gameCenter/invitePlayers.js
index 31616bbf3862..1f0b6f07455e 100644
--- a/app/apps/client/gameCenter/invitePlayers.js
+++ b/app/apps/client/gameCenter/invitePlayers.js
@@ -4,6 +4,8 @@ import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import { Blaze } from 'meteor/blaze';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
+import { Tracker } from 'meteor/tracker';
+import { Session } from 'meteor/session';
import { AutoComplete } from '../../../meteor-autocomplete/client';
import { roomTypes } from '../../../utils/client';
@@ -79,15 +81,23 @@ Template.InvitePlayers.events({
roomTypes.openRouteLink(result.t, result);
- // setTimeout ensures the message is only sent after the
+ // This ensures the message is only sent after the
// user has been redirected to the new room, preventing a
// weird bug that made the message appear as unsent until
// the screen gets refreshed
- setTimeout(() => call('sendMessage', {
- _id: Random.id(),
- rid: result.rid,
- msg: TAPi18n.__('Game_Center_Play_Game_Together', { name }),
- }), 100);
+ Tracker.autorun((c) => {
+ if (Session.get('openedRoom') !== result.rid) {
+ return;
+ }
+
+ call('sendMessage', {
+ _id: Random.id(),
+ rid: result.rid,
+ msg: TAPi18n.__('Apps_Game_Center_Play_Game_Together', { name }),
+ });
+
+ c.stop();
+ });
modal.close();
} catch (err) {
diff --git a/app/apps/client/gameCenter/tabBar.js b/app/apps/client/gameCenter/tabBar.js
index 0d5aff24c957..fe5883119c97 100644
--- a/app/apps/client/gameCenter/tabBar.js
+++ b/app/apps/client/gameCenter/tabBar.js
@@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { APIClient } from '../../../utils/client';
-import { TabBar, TABBAR_DEFAULT_VISIBLE_ICON_COUNT } from '../../../ui-utils/client';
+import { TabBar } from '../../../ui-utils/client';
import { settings } from '../../../settings/client';
import './gameCenter.html';
@@ -10,23 +10,19 @@ import './gameCenter.html';
Meteor.startup(function() {
Tracker.autorun(async function() {
if (!settings.get('Apps_Game_Center_enabled')) {
- TabBar.size = TABBAR_DEFAULT_VISIBLE_ICON_COUNT;
return TabBar.removeButton('gameCenter');
}
const { externalComponents } = await APIClient.get('apps/externalComponents');
if (!externalComponents.length) {
- TabBar.size = TABBAR_DEFAULT_VISIBLE_ICON_COUNT;
return TabBar.removeButton('gameCenter');
}
- TabBar.size = TABBAR_DEFAULT_VISIBLE_ICON_COUNT + 1;
-
TabBar.addButton({
groups: ['channel', 'group', 'direct'],
id: 'gameCenter',
- i18nTitle: 'Game_Center',
+ i18nTitle: 'Apps_Game_Center',
icon: 'game',
template: 'GameCenter',
order: -1,
diff --git a/app/livestream/client/tabBar.js b/app/livestream/client/tabBar.js
index 1ebd068b2719..a1041cac5256 100644
--- a/app/livestream/client/tabBar.js
+++ b/app/livestream/client/tabBar.js
@@ -10,8 +10,12 @@ Meteor.startup(function() {
Tracker.autorun(function() {
TabBar.removeButton('livestream');
if (settings.get('Livestream_enabled')) {
- const live = Rooms.findOne({ _id: Session.get('openedRoom'), 'streamingOptions.type': 'livestream', 'streamingOptions.id': { $exists: 1 } }, { fields: { streamingOptions: 1 } });
- TabBar.size = live ? 5 : 4;
+ const live = Rooms.findOne({
+ _id: Session.get('openedRoom'),
+ 'streamingOptions.type': 'livestream',
+ 'streamingOptions.id': { $exists: 1 },
+ }, { fields: { streamingOptions: 1 } });
+
return TabBar.addButton({
groups: ['channel', 'group'],
id: 'livestream',
diff --git a/app/ui-utils/client/lib/TabBar.js b/app/ui-utils/client/lib/TabBar.js
index b9ec9039e3d7..15568d7be4e9 100644
--- a/app/ui-utils/client/lib/TabBar.js
+++ b/app/ui-utils/client/lib/TabBar.js
@@ -1,5 +1,6 @@
import _ from 'underscore';
import { ReactiveVar } from 'meteor/reactive-var';
+import { Tracker } from 'meteor/tracker';
export const TABBAR_DEFAULT_VISIBLE_ICON_COUNT = 4;
@@ -38,12 +39,28 @@ export const TabBar = new class TabBar {
btns[config.id].groups = _.union(btns[config.id].groups || [], this.extraGroups[config.id]);
}
+ // When you add a button with an order value of -1
+ // we assume you want to force the visualization of your button
+ // so we increase the number of buttons that are shown so you
+ // don't end up hiding any of the default ones
+ if (config.order === -1) {
+ Tracker.nonreactive(() => this.size++);
+ }
+
this.buttons.set(btns);
}
removeButton(id) {
const btns = this.buttons.curValue;
+
+ // Here we decrease the shown count as your
+ // button is no longer present
+ if (btns[id] && btns[id].order === -1) {
+ Tracker.nonreactive(() => this.size--);
+ }
+
delete btns[id];
+
this.buttons.set(btns);
}
diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json
index 5c8e260d2f98..dd9a3327143c 100644
--- a/packages/rocketchat-i18n/i18n/en.i18n.json
+++ b/packages/rocketchat-i18n/i18n/en.i18n.json
@@ -392,7 +392,11 @@
"Apps_Framework_Development_Mode": "Enable development mode",
"Apps_Framework_Development_Mode_Description": "Development mode allows the installation of Apps that are not from the Rocket.Chat's Marketplace.",
"Apps_Framework_enabled": "Enable the App Framework",
+ "Apps_Game_Center": "Game Center",
+ "Apps_Game_Center_Back": "Back to Game Center",
"Apps_Game_Center_enabled": "Enable the Game Center",
+ "Apps_Game_Center_Play_Game_Together": "@here Let's play __name__ together!",
+ "Apps_Game_Center_Invite_Friends": "Invite your friends to join",
"Apps_Marketplace_Deactivate_App_Prompt": "Do you really want to disable this app?",
"Apps_Marketplace_Modify_App_Subscription": "Modify Subscription",
"Apps_Marketplace_Uninstall_App_Prompt": "Do you really want to uninstall this app?",
@@ -495,7 +499,6 @@
"Back": "Back",
"Back_to_applications": "Back to applications",
"Back_to_chat": "Back to chat",
- "Back_to_Game_Center": "Back to Game Center",
"Back_to_imports": "Back to imports",
"Back_to_integration_detail": "Back to the integration detail",
"Back_to_integrations": "Back to integrations",
@@ -1612,8 +1615,6 @@
"From_Email": "From Email",
"From_email_warning": "Warning: The field From is subject to your mail server settings.",
"Full_Screen": "Full Screen",
- "Game_Center": "Game Center",
- "Game_Center_Play_Game_Together": "@here Let's play __name__ together!",
"Gaming": "Gaming",
"General": "General",
"Get_link": "Get Link",
diff --git a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json
index 1b7210b17d34..e26ed0ea5829 100644
--- a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json
+++ b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json
@@ -370,6 +370,7 @@
"Apps_Engine_Version": "Versão da Apps Engine",
"Apps_Framework_Development_Mode": "Habilitar modo de desenvolvimento",
"Apps_Framework_enabled": "Ativar o App Framework",
+ "Apps_Game_Center": "Game Center",
"Apps_Game_Center_enabled": "Habilitar Game Center",
"Apps_Settings": "Configurações da aplicação",
"Apps_WhatIsIt": "Apps: o que são eles?",
@@ -1476,7 +1477,6 @@
"From_Email": "Email De",
"From_email_warning": "Aviso: O campo De está sujeito às configurações do seu servidor de emails.",
"Full_Screen": "Tela cheia",
- "Game_Center": "Game Center",
"Gaming": "Jogos",
"General": "Geral",
"Get_link": "Obter Link",
diff --git a/packages/rocketchat-i18n/i18n/zh.i18n.json b/packages/rocketchat-i18n/i18n/zh.i18n.json
index 735d4d3d1517..273c4640ecdd 100644
--- a/packages/rocketchat-i18n/i18n/zh.i18n.json
+++ b/packages/rocketchat-i18n/i18n/zh.i18n.json
@@ -374,6 +374,7 @@
"Apps_Framework_Development_Mode": "启用开发模式",
"Apps_Framework_Development_Mode_Description": "开发模式允许您安装那些不在 Rocket.Chat 市场中的应用。",
"Apps_Framework_enabled": "启用应用框架",
+ "Apps_Game_Center": "游戏中心",
"Apps_Game_Center_enabled": "启用游戏中心",
"Apps_Marketplace_Deactivate_App_Prompt": "是否确定要禁用此应用程序?",
"Apps_Marketplace_Modify_App_Subscription": "修改订阅",
@@ -1551,7 +1552,6 @@
"From_Email": "从电子邮件",
"From_email_warning": "警告:From 字段来自于邮件服务器的设置。",
"Full_Screen": "全屏",
- "Game_Center": "游戏中心",
"Gaming": "游戏",
"General": "通用",
"Get_link": "获取链接",