parent
a74db27644
commit
8ddb090526
@ -1,11 +1,17 @@ |
||||
Meteor.startup(function _loadDynamicallyDefinedCommands() { |
||||
// The reason there is a 500 millisecond delay is so that we are
|
||||
// a little "easier" on the server during start up
|
||||
setTimeout(() => { |
||||
RocketChat.API.v1.get('commands.list').then(function _loadedCommands(result) { |
||||
result.commands.forEach((command) => { |
||||
RocketChat.slashCommands.commands[command.command] = command; |
||||
//Track logins and when they login, get the commands
|
||||
(() => { |
||||
let oldUserId = null; |
||||
|
||||
Meteor.autorun(() => { |
||||
const newUserId = Meteor.userId(); |
||||
if (oldUserId === null && newUserId) { |
||||
RocketChat.API.v1.get('commands.list').then(function _loadedCommands(result) { |
||||
result.commands.forEach((command) => { |
||||
RocketChat.slashCommands.commands[command.command] = command; |
||||
}); |
||||
}); |
||||
}); |
||||
}, 500); |
||||
}); |
||||
} |
||||
|
||||
oldUserId = Meteor.userId(); |
||||
}); |
||||
})(); |
||||
|
||||
@ -1,3 +1,22 @@ |
||||
Template.rocketlets.onCreated(function() { |
||||
console.log('hello'); |
||||
const instance = this; |
||||
this.ready = new ReactiveVar(false); |
||||
this.rocketlets = new ReactiveVar([]); |
||||
|
||||
RocketChat.API.get('rocketlets').then((result) => { |
||||
instance.rocketlets.set(result.rocketlets); |
||||
}); |
||||
}); |
||||
|
||||
Template.rocketlets.helpers({ |
||||
isReady() { |
||||
if (Template.instance().ready != null) { |
||||
return Template.instance().ready.get(); |
||||
} |
||||
|
||||
return false; |
||||
}, |
||||
rocketlets() { |
||||
return Template.instance().rocketlets.get(); |
||||
} |
||||
}); |
||||
|
||||
@ -0,0 +1,35 @@ |
||||
export class RocketletActivationBridge { |
||||
constructor(orch) { |
||||
this.orch = orch; |
||||
} |
||||
|
||||
rocketletEnabled(rocketlet) { |
||||
console.log(`The Rocketlet ${ rocketlet.getName() } (${ rocketlet.getID() }) has been enabled.`); |
||||
} |
||||
|
||||
rocketletDisabled(rocketlet) { |
||||
console.log(`The Rocketlet ${ rocketlet.getName() } (${ rocketlet.getID() }) has been disabled.`); |
||||
} |
||||
|
||||
rocketletLoaded(rocketlet, enabled) { |
||||
console.log(`The Rocketlet ${ rocketlet.getName() } (${ rocketlet.getID() }) has been loaded and enabled? ${ enabled }`); |
||||
|
||||
if (enabled) { |
||||
this.orch.getNotifier().rocketletAdded(rocketlet.getID()); |
||||
} |
||||
} |
||||
|
||||
rocketletUpdated(rocketlet, enabled) { |
||||
console.log(`The Rocketlet ${ rocketlet.getName() } (${ rocketlet.getID() }) has been updated and enabled? ${ enabled }`); |
||||
|
||||
if (enabled) { |
||||
this.orch.getNotifier().rocketletUpdated(rocketlet.getID()); |
||||
} |
||||
} |
||||
|
||||
rocketletRemoved(rocketlet) { |
||||
console.log(`The Rocketlet ${ rocketlet.getName() } (${ rocketlet.getID() }) has been removed.`); |
||||
|
||||
this.orch.getNotifier().rocketletRemoved(rocketlet.getID()); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue