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/>
|
<input id="chat-input" type="text" placeholder="say anything" autofocus/>
|
||||||
</section>
|
</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="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||||
<script src="index.js"></script>
|
<script src="index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -63,23 +63,21 @@ $(function() {
|
|||||||
var promise = chatClient.getChannelByUniqueName('general');
|
var promise = chatClient.getChannelByUniqueName('general');
|
||||||
promise.then(function(channel) {
|
promise.then(function(channel) {
|
||||||
generalChannel = channel;
|
generalChannel = channel;
|
||||||
if (!generalChannel) {
|
console.log('Found general channel:');
|
||||||
// If it doesn't exist, let's create it
|
console.log(generalChannel);
|
||||||
console.log('Creating general channel');
|
setupChannel();
|
||||||
chatClient.createChannel({
|
}).catch(function() {
|
||||||
uniqueName: 'general',
|
// If it doesn't exist, let's create it
|
||||||
friendlyName: 'General Chat Channel'
|
console.log('Creating general channel');
|
||||||
}).then(function(channel) {
|
chatClient.createChannel({
|
||||||
console.log('Created general channel:');
|
uniqueName: 'general',
|
||||||
console.log(channel);
|
friendlyName: 'General Chat Channel'
|
||||||
generalChannel = channel;
|
}).then(function(channel) {
|
||||||
setupChannel();
|
console.log('Created general channel:');
|
||||||
});
|
console.log(channel);
|
||||||
} else {
|
generalChannel = channel;
|
||||||
console.log('Found general channel:');
|
|
||||||
console.log(generalChannel);
|
|
||||||
setupChannel();
|
setupChannel();
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user