[IMPROVE] Make the implementation of custom code easier by having placeholders for a custom folder (#15106)

pull/14085/head^2
justinr1234 6 years ago committed by GitHub
parent ae90799288
commit 53c4ecf610
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/callbacks/lib/callbacks.js
  2. 0
      app/custom/client/index.js
  3. 0
      app/custom/server/index.js
  4. 28
      app/discussion/server/hooks/propagateDiscussionMetadata.js
  5. 4
      app/ui-utils/client/lib/RoomManager.js
  6. 2
      app/ui-utils/client/lib/openRoom.js
  7. 1
      client/importPackages.js
  8. 1
      server/importPackages.js

@ -59,8 +59,8 @@ const combinedCallbacks = new Map();
/*
* Callback priorities
* @enum {CallbackPriority}
*/
callbacks.priority = {
HIGH: -1000,
MEDIUM: 0,
@ -73,8 +73,9 @@ const getHooks = (hookName) => callbacks[hookName] || [];
* Add a callback function to a hook
* @param {String} hook - The name of the hook
* @param {Function} callback - The callback function
* @param {CallbackPriority} priority - The callback run priority (order)
* @param {String} id - Human friendly name for this callback
*/
callbacks.add = function(
hook,
callback,

@ -23,15 +23,25 @@ callbacks.add('afterDeleteMessage', function(message, { _id, prid } = {}) {
return message;
}, callbacks.priority.LOW, 'PropagateDiscussionMetadata');
callbacks.add('afterDeleteRoom', (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));
return rid;
}, callbacks.priority.LOW, 'DeleteDiscussionChain');
// TODO discussions define new fields
callbacks.add('afterRoomNameChange', ({ rid, name, oldName }) => Rooms.update({ prid: rid, ...oldName && { topic: oldName } }, { $set: { topic: name } }, { multi: true }), 'updateTopicDiscussion');
callbacks.add('afterRoomNameChange', (roomConfig) => {
const { rid, name, oldName } = roomConfig;
Rooms.update({ prid: rid, ...oldName && { topic: oldName } }, { $set: { topic: name } }, { multi: true });
return roomConfig;
}, callbacks.priority.LOW, 'updateTopicDiscussion');
callbacks.add('afterDeleteRoom', (drid) => Messages.update({ drid }, {
$unset: {
dcount: 1,
dlm: 1,
drid: 1,
},
}), 'CleanDiscussionMessage');
callbacks.add('afterDeleteRoom', (drid) => {
Messages.update({ drid }, {
$unset: {
dcount: 1,
dlm: 1,
drid: 1,
},
});
return drid;
}, callbacks.priority.LOW, 'CleanDiscussionMessage');

@ -114,7 +114,7 @@ export const RoomManager = new function() {
return Object.keys(openedRooms).map((typeName) => openedRooms[typeName]).find((openedRoom) => openedRoom.rid === rid);
}
getDomOfRoom(typeName, rid) {
getDomOfRoom(typeName, rid, templateName) {
const room = openedRooms[typeName];
if (room == null) {
return;
@ -125,7 +125,7 @@ export const RoomManager = new function() {
room.dom.classList.add('room-container');
const contentAsFunc = (content) => () => content;
room.template = Blaze._TemplateWith({ _id: rid }, contentAsFunc(Template.room));
room.template = Blaze._TemplateWith({ _id: rid }, contentAsFunc(Template[templateName || 'room']));
Blaze.render(room.template, room.dom); // , nextNode, parentView
}

@ -84,7 +84,7 @@ export const openRoom = async function(type, name) {
return FlowRouter.go('direct', { rid: room._id }, FlowRouter.current().queryParams);
}
const roomDom = RoomManager.getDomOfRoom(type + name, room._id);
const roomDom = RoomManager.getDomOfRoom(type + name, room._id, roomTypes.getConfig(type).mainTemplate);
const mainNode = replaceCenterDomBy(roomDom);
if (mainNode) {

@ -107,3 +107,4 @@ import '../app/reactions/client';
import '../app/livechat/client';
import '../app/meteor-autocomplete/client';
import '../app/theme/client';
import '../app/custom/client';

@ -112,3 +112,4 @@ import '../app/ui-utils';
import '../app/action-links/server';
import '../app/reactions/server';
import '../app/livechat/server';
import '../app/custom/server';

Loading…
Cancel
Save