diff --git a/app/autotranslate/client/lib/actionButton.js b/app/autotranslate/client/lib/actionButton.js index 2c1069095deb..41440be6b6ff 100644 --- a/app/autotranslate/client/lib/actionButton.js +++ b/app/autotranslate/client/lib/actionButton.js @@ -25,11 +25,9 @@ Meteor.startup(function() { AutoTranslate.messageIdsToWait[message._id] = true; Messages.update({ _id: message._id }, { $set: { autoTranslateFetching: true } }); Meteor.call('autoTranslate.translateMessage', message, language); - } else if (message.autoTranslateShowInverse) { - Messages.update({ _id: message._id }, { $unset: { autoTranslateShowInverse: true } }); - } else { - Messages.update({ _id: message._id }, { $set: { autoTranslateShowInverse: true } }); } + const action = message.autoTranslateShowInverse ? '$unset' : '$set'; + Messages.update({ _id: message._id }, { [action]: { autoTranslateShowInverse: true } }); }, condition(message) { return message && message.u && message.u._id !== Meteor.userId(); diff --git a/app/autotranslate/client/lib/autotranslate.js b/app/autotranslate/client/lib/autotranslate.js index 7ce10296636c..e4e1b60768e9 100644 --- a/app/autotranslate/client/lib/autotranslate.js +++ b/app/autotranslate/client/lib/autotranslate.js @@ -61,7 +61,7 @@ export const AutoTranslate = { if (!message.translations) { message.translations = {}; } - if (subscription && subscription.autoTranslate !== message.autoTranslateShowInverse) { + if (!!(subscription && subscription.autoTranslate) !== !!message.autoTranslateShowInverse) { message.translations.original = message.html; if (message.translations[autoTranslateLanguage]) { message.html = message.translations[autoTranslateLanguage]; diff --git a/app/autotranslate/client/lib/tabBar.js b/app/autotranslate/client/lib/tabBar.js index b73ad1172064..d3077ec0c636 100644 --- a/app/autotranslate/client/lib/tabBar.js +++ b/app/autotranslate/client/lib/tabBar.js @@ -7,7 +7,7 @@ import { TabBar } from '../../../ui-utils'; Meteor.startup(function() { Tracker.autorun(function() { if (settings.get('AutoTranslate_Enabled') && hasAtLeastOnePermission(['auto-translate'])) { - TabBar.addButton({ + return TabBar.addButton({ groups: ['channel', 'group', 'direct'], id: 'autotranslate', i18nTitle: 'Auto_Translate', @@ -15,8 +15,7 @@ Meteor.startup(function() { template: 'autoTranslateFlexTab', order: 20, }); - } else { - TabBar.removeButton('autotranslate'); } + TabBar.removeButton('autotranslate'); }); }); diff --git a/app/channel-settings/server/functions/saveRoomName.js b/app/channel-settings/server/functions/saveRoomName.js index e10c75674f29..3a3af38819ff 100644 --- a/app/channel-settings/server/functions/saveRoomName.js +++ b/app/channel-settings/server/functions/saveRoomName.js @@ -1,6 +1,7 @@ import { Meteor } from 'meteor/meteor'; import { Rooms, Messages, Subscriptions, Integrations } from '../../../models'; import { roomTypes, getValidRoomName } from '../../../utils'; +import { callbacks } from '../../../callbacks'; export const saveRoomName = function(rid, displayName, user, sendMessage = true) { const room = Rooms.findOneById(rid); @@ -26,5 +27,6 @@ export const saveRoomName = function(rid, displayName, user, sendMessage = true) if (sendMessage) { Messages.createRoomRenamedWithRoomIdRoomNameAndUser(rid, displayName, user); } + callbacks.run('afterRoomNameChange', { rid, name: displayName }); return displayName; }; diff --git a/app/discussion/server/hooks/propagateDiscussionMetadata.js b/app/discussion/server/hooks/propagateDiscussionMetadata.js index 9724de1cd1de..b763bbd1cd45 100644 --- a/app/discussion/server/hooks/propagateDiscussionMetadata.js +++ b/app/discussion/server/hooks/propagateDiscussionMetadata.js @@ -23,6 +23,15 @@ callbacks.add('afterDeleteMessage', function(message, { _id, prid } = {}) { return message; }, callbacks.priority.LOW, 'PropagateDiscussionMetadata'); -callbacks.add('afterDeleteRoom', function(rid) { - Rooms.find({ prid: rid }, { fields: { _id: 1 } }).forEach(({ _id }) => deleteRoom(_id)); -}, 'DeleteDiscussionChain'); +callbacks.add('afterDeleteRoom', (rid) => Rooms.find({ prid: rid }, { fields: { _id: 1 } }).forEach(({ _id }) => deleteRoom(_id)), 'DeleteDiscussionChain'); + +// TODO discussions define new fields +callbacks.add('afterRoomNameChange', ({ rid, name }) => Rooms.update({ prid: rid }, { $set: { topic: name } }, { multi: true })); + +callbacks.add('afterDeleteRoom', (drid) => Messages.update({ drid }, { + $unset: { + dcount: 1, + dlm: 1, + drid: 1, + }, +}), 'CleanDiscussionMessage'); diff --git a/app/theme/client/imports/forms/input.css b/app/theme/client/imports/forms/input.css index 0ac7abd71bdf..0be7e3f66a48 100644 --- a/app/theme/client/imports/forms/input.css +++ b/app/theme/client/imports/forms/input.css @@ -1,8 +1,8 @@ textarea.rc-input__element { height: auto; + padding: 0.5rem 1rem; font-family: inherit; - line-height: 0.5rem 1rem; } .rc-input { diff --git a/app/ui-message/client/message.js b/app/ui-message/client/message.js index 0299d8d7f30c..d2010b3964bc 100644 --- a/app/ui-message/client/message.js +++ b/app/ui-message/client/message.js @@ -224,7 +224,8 @@ Template.message.helpers({ const { msg, subscription, settings } = this; if (settings.AutoTranslate_Enabled && msg.u && msg.u._id !== Meteor.userId() && !MessageTypes.isSystemMessage(msg)) { const language = AutoTranslate.getLanguage(msg.rid); - return msg.autoTranslateFetching || (subscription && subscription.autoTranslate !== msg.autoTranslateShowInverse && msg.translations && msg.translations[language]); + const autoTranslate = subscription && subscription.autoTranslate; + return msg.autoTranslateFetching || (!!autoTranslate !== !!msg.autoTranslateShowInverse && msg.translations && msg.translations[language]); } }, edited() { diff --git a/server/startup/migrations/index.js b/server/startup/migrations/index.js index fac1f2fd867f..7465d88879ae 100644 --- a/server/startup/migrations/index.js +++ b/server/startup/migrations/index.js @@ -137,4 +137,5 @@ import './v136'; import './v137'; import './v138'; import './v139'; +import './v140'; import './xrun'; diff --git a/server/startup/migrations/v140.js b/server/startup/migrations/v140.js new file mode 100644 index 000000000000..efa35de80778 --- /dev/null +++ b/server/startup/migrations/v140.js @@ -0,0 +1,17 @@ +import { Migrations } from '../../../app/migrations/server'; + +import { Messages, Rooms } from '../../../app/models/server'; + +Migrations.add({ + version: 140, + up() { + Messages.find({ drid: { $exists: 1 } }, { fields: { drid: 1 } }).forEach(({ _id, drid }) => Rooms.findOne({ _id: drid }) || Messages.update({ _id }, { + $unset: { + drid: 1, + dcount: 1, + dlm: 1, + t: 1, + }, + })); + }, +});