Merge pull request #4 from TwilioDevEd/update-chat-channels
Updated Chat SDK version and the way channels are created if not found
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
<input id="chat-input" type="text" placeholder="say anything" autofocus/>
|
||||
</section>
|
||||
|
||||
<script src="///media.twiliocdn.com/sdk/js/chat/releases/0.11.0/twilio-chat.min.js"></script>
|
||||
<script src="///media.twiliocdn.com/sdk/js/chat/v0.11/twilio-chat.js"></script>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script src="index.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -63,23 +63,21 @@ $(function() {
|
||||
var promise = chatClient.getChannelByUniqueName('general');
|
||||
promise.then(function(channel) {
|
||||
generalChannel = channel;
|
||||
if (!generalChannel) {
|
||||
// If it doesn't exist, let's create it
|
||||
console.log('Creating general channel');
|
||||
chatClient.createChannel({
|
||||
uniqueName: 'general',
|
||||
friendlyName: 'General Chat Channel'
|
||||
}).then(function(channel) {
|
||||
console.log('Created general channel:');
|
||||
console.log(channel);
|
||||
generalChannel = channel;
|
||||
setupChannel();
|
||||
});
|
||||
} else {
|
||||
console.log('Found general channel:');
|
||||
console.log(generalChannel);
|
||||
console.log('Found general channel:');
|
||||
console.log(generalChannel);
|
||||
setupChannel();
|
||||
}).catch(function() {
|
||||
// If it doesn't exist, let's create it
|
||||
console.log('Creating general channel');
|
||||
chatClient.createChannel({
|
||||
uniqueName: 'general',
|
||||
friendlyName: 'General Chat Channel'
|
||||
}).then(function(channel) {
|
||||
console.log('Created general channel:');
|
||||
console.log(channel);
|
||||
generalChannel = channel;
|
||||
setupChannel();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user