Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Small fixes for Game Center #17018

Merged
merged 6 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions app/apps/client/gameCenter/gameCenter.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/apps/client/gameCenter/gameContainer.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{{#if showBackButton}}
<button
class="rc-button rc-button--nude contextual-bar__header-back-btn js-back"
title="{{_ 'Back_to_Game_Center'}}"
title="{{_ 'Apps_Game_Center_Back'}}"
>
<i class="icon-angle-left"></i>
</button>
Expand Down
22 changes: 16 additions & 6 deletions app/apps/client/gameCenter/invitePlayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 2 additions & 6 deletions app/apps/client/gameCenter/tabBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,27 @@ 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';

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,
Expand Down
8 changes: 6 additions & 2 deletions app/livestream/client/tabBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
17 changes: 17 additions & 0 deletions app/ui-utils/client/lib/TabBar.js
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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) {
d-gubert marked this conversation as resolved.
Show resolved Hide resolved
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) {
d-gubert marked this conversation as resolved.
Show resolved Hide resolved
Tracker.nonreactive(() => this.size--);
}

delete btns[id];

this.buttons.set(btns);
}

Expand Down
7 changes: 4 additions & 3 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1612,8 +1615,6 @@
"From_Email": "From Email",
"From_email_warning": "<b>Warning</b>: The field <b>From</b> 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",
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?",
Expand Down Expand Up @@ -1476,7 +1477,6 @@
"From_Email": "Email De",
"From_email_warning": "<b>Aviso</b>: O campo <b>De</b> 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",
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-i18n/i18n/zh.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "修改订阅",
Expand Down Expand Up @@ -1551,7 +1552,6 @@
"From_Email": "从电子邮件",
"From_email_warning": "<b>警告</b>:<b>From</b> 字段来自于邮件服务器的设置。",
"Full_Screen": "全屏",
"Game_Center": "游戏中心",
"Gaming": "游戏",
"General": "通用",
"Get_link": "获取链接",
Expand Down