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

Improve: Make the implementation of custom code easier by having placeholders for a custom folder #15106

Merged
merged 4 commits into from
May 30, 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
5 changes: 3 additions & 2 deletions app/callbacks/lib/callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ const combinedCallbacks = new Map();

/*
* Callback priorities
* @enum {CallbackPriority}
*/

callbacks.priority = {
HIGH: -1000,
MEDIUM: 0,
Expand All @@ -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,
Expand Down
Empty file added app/custom/client/index.js
Empty file.
Empty file added app/custom/server/index.js
Empty file.
28 changes: 19 additions & 9 deletions app/discussion/server/hooks/propagateDiscussionMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
4 changes: 2 additions & 2 deletions app/ui-utils/client/lib/RoomManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion app/ui-utils/client/lib/openRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions client/importPackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
1 change: 1 addition & 0 deletions server/importPackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';