In this special edition live episode, Bryant is joined by Kevin, Alex, and Matt to build a clone on Slack in just one hour with Directus Realtime and Nuxt. Join the absolute chaos as friends and colleagues try to "help" against the clock.
Speaker 0: Build in an extra 15 minutes for chaos. I'm gonna be here for the first 20. Then for the 1st presales engineers, Alex, will be here for 20, and then Matt will be here for 20. With that in mind, Bryant, I'm gonna start a timer. No stress, but stress.
Take it away.
Speaker 1: Yeah. Let's start the timer. What are we building?
Speaker 0: You tell me.
Speaker 1: Yeah. So you you let me know ahead of time, maybe, like, just a hour ago that we were gonna be building. Any guesses in the chat. Right? This might be fun to do live.
Right? What are the guesses? No guesses. Alright. I don't see him coming through.
We are going to be building a Slack clone. Build direct to us.
Speaker 0: In an hour.
Speaker 1: No. In an hour. Alright. So, Slack. Right?
Yeah. Everybody uses it. You either love it, hate it. Xbox Live. Yeah.
We'll do Xbox Live next time. Alright. So let's sketch this thing out. Right? What do we need out of a Slack clone?
What feels good as far as functionality for this? How are we gonna set it up in direct us? Facebook, they need some help with their APIs. Yep. Certainly.
Yeah. Experienced
Speaker 0: that. We all saw that today. What is needed for Slack? I suppose the lightest version is gonna be you have channels, and inside of channels, you have users, and then you have channels. And then inside the channels, you have messages with, like, real time.
And I think the that's the slimmest version. Right?
Speaker 1: Yeah. So let's put, like, channels and messages at the top. We would call, like, threads a stretch goal. Yeah. Thread threading feels like, probably more than an hour.
Alright. So we got channels. We got messages. We're gonna get the user authentication from direct to its users. And as far as functionality, what do we wanna do?
We wanna have a channel. We want to submit messages in the channel. We want that all to update in real time. Notifications? Do we want notifications?
We'll
Speaker 0: I never wanna be notified when people send me messages ever. There is literally no world where I want that feature. So
Speaker 1: so how many Slack groups are you a part of where, like, you just got the whole thing muted, Kevin? That would be a good question.
Speaker 0: So let's take a look here. Let me let me open Slack for the first time in a in a hot minute. Okay. I'm in 123456789101112 Slacks. 12 Slacks.
And I look at 2 of them regularly. 3 of them regularly. Most of the others are muted.
Speaker 1: Alright. Yep. That's how it goes. Same thing for me. Alright.
So I've got a brand new instance. Please don't use this password.
Speaker 0: Oh my lord. I okay. That's fine. Everything's fine.
Speaker 1: Probably need to change that before we get some surprises. Right? Change that real quick. Okay. Alright.
So we're inside Directus. How are we gonna map this out? Right? We get the Directus users already out of the box. We get the authentication.
We should get real time out of the box as well. So we just need these components. Right? Channels and messages should be fairly straightforward. We'll just call it a channel.
Speaker 0: Why would you say that? That's like the beginning of the it should be it should be straightforward. Keep it simple, and it won't be complicated.
Speaker 1: Keep it simple, and it won't be complicated. Yeah. Alright. What do we need for a channel? Do we yeah.
Yeah. We don't even really need any of this. Right? I don't care when it was created, who it was created by. Just need a name for the channel.
That'll be an input. We're going to go to the advanced settings. And because I want this to be URL safe, right, we'll use the slugify option inside the interface, and boom. There's channels. That was really complicated.
I I saw Ben was
Speaker 0: He begins now.
Speaker 1: Let's let's do, like, the sahash. Oh, egg.
Speaker 0: Oh, god. We don't have time for this, Brian. Dude God, I'm stressed already, and we're, like, 4 minutes in. Everything.
Speaker 1: Yep. Alright. So then we've got messages. Alright. So as far as messages, we want when that message was created.
So let's just call that timestamp for simplicity. Fun fact.
Speaker 0: I didn't know you could rename those. I literally didn't that is the first time I've ever seen that. Damn.
Speaker 1: Yeah. You could change it. You know, like, some people prefer updated at, versus date created or update updated. Do whatever you want with it. Alright.
So we've got some messages within the messages. What do we have? We have what do we wanna do? Just text text area. We could go to markdown to be super complicated, but we'll just call it content, text, message.
What do you Yeah.
Speaker 0: I literally I literally don't care. Oh my god. No. I I wouldn't do message because if you're, like, looping through messages, you might use message as the singular, and then, yeah, text feels good.
Speaker 1: Text. Alright. Let's unhide this just so we could see.
Speaker 0: My leg's literally doing its nervous shake. I'm so glad this is your series and not mine. Oh my gosh. I'm sweating. Is it is it
Speaker 1: just the technical difficulties at the start of it? Or or what?
Speaker 0: No. It's having an hour on the clock. It's having an hour on the clock, Brian. It's the very format.
Speaker 1: Yeah. No worries. Alright. So we got some messages. We got some channels.
What else do we really need here? Oh, we'll come back to threads later. Right? We've already got our users. I'm gonna go ahead and, let's add you as a user, Kevin.
Kevin, add example. And I'm not gonna tell you guys what the password is here. Alright. Now let's go into
Speaker 0: I did actually think reactions would be a nice sorry. That was me interacting with, Ben in the chat. I did actually think reactions would be a nice a nice one as well. It's quite common.
Speaker 1: Yeah. Cool. It'd be an interesting one to add. Yeah. We'll come back to it for sure.
Alright. So we're gonna create a role for users so we can give access to messages for channels, etcetera. We're just gonna go ahead and give all access to this to start with. And the other thing that I'm gonna do, let's give public access to create we'll come back to, like, registering users.
Speaker 0: Yeah. Yeah. Yeah. No. That's later.
Speaker 1: Yeah. Okay. Alright. So we've given access. Now we can access any as long as we're in this user role, we'll be able to access channels, messages, all of that.
Let's actually start to build something. Right? If I wanted to, I could give Kevin access to this right now. He could log in. Let's just do that.
Speaker 0: You're just seeing my stress face here. Okay.
Speaker 1: I just see your stress face. Kevin at example.
Speaker 0: And Kevin Oh, that is a lowbrow password.
Speaker 1: Is it lowbrow?
Speaker 0: Wow. I mean Yeah.
Speaker 1: So let's go in. I'm gonna just create a couple
Speaker 2: of channels.
Speaker 0: Tests, though.
Speaker 1: Oh, yeah. That's right. Let me just go ahead and give that. Because eventually, you're gonna be interacting through this Nuxt front end. But Yeah.
Yeah. Cool. Alright. So we create a couple channels. Right?
What do we like, guys? Throw some suggestions in the chat. We'll add a few of these channels. Let's start with Random? Evan is crazy nervous channel.
Speaker 0: My leg's shaking.
Speaker 1: General, memes. Okay. Sounds great. Got some memes. Alright.
And now as far as messages, right, we got the user. We got the timestamp. We've got when it was updated. In case we change it, we got the text. But the thing that we don't have is how these messages belong to a channel.
So inside Directus, we'll just go in. Again, creating these relationships, super easy. I don't even have to touch SQL. We'll go in, create a mini to 1 relationship for this. We'll call it channel, and we'll use our channels collection.
And
Speaker 2: what else do we need?
Speaker 1: Maybe display template. We'll use name. Great. Cool. And now I could populate a message into a specific channel.
Hey, Kev. I'll be nervous.
Speaker 0: I have the most faith in you while having absolutely no faith in you at the same time. By the way, that user you created for me still doesn't have app access. You might need to go into the user settings and allow that. I thought doing the role would be sufficient, but, oh, I'm not I'm not in that role. I'm not in that role.
Users in that role was 0.
Speaker 1: Yeah. Gotcha. Yep. Try it now. Okay.
Speaker 0: I'll tell you in a moment.
Speaker 1: Tell me in a moment. Alright. So we've got the basic logic here. Like, we could go and fetch the data from this API if we wanted to just by going to messages or item slash messages. We're gonna get a forbidden because I'm not logged in, but that's okay.
We'll take care of that.
Speaker 0: Oh, we're 10 minutes in. This? Sorry. No stress, but we're 10 minutes in. That's half my time here.
I'm I'm halfway to freedom because I am sweating so hard.
Speaker 1: Don't sweat, man. Somehow I got logged out. So chaos rains, my friend. Oh my gosh. Glass work.
Okay. Alright. I don't know how I got logged out, but okay. So we've got channels. We've got messages.
Let's actually do something. I low key hate this, he says. I can still see the chat in the other window, Kevin. So you're not you're not giving me much confidence.
Speaker 0: I'm so sorry.
Speaker 1: Alright. Yeah. No worries, man. No worries. Alright.
So this is my NUC starter from all the other episodes that we've got. I've switched it up a little bit just so you have a simple plug in for the sake of this live instance because the the other starter that had had a Nuxt module. It's got a lot going on. This is really simple. Right?
So we've got a direct us plug in, that is in the plug ins directory inside Nuxt, which will automatically register this. And really simple. Right? Inside Nuxt, we've got a runtime config that we're calling to get the directus URL. And my Nuxt config looks like this.
Right? We've got a direct us URL. Right now, that is pointing to, like, a local host, so we do need to switch this over. We'll just go to our URL here. It is switched over.
Great. As far as the server token, I don't think we even actually will be using this. I don't think I've got it anywhere else in my config either. Cool. So we'll save that.
And now we want to, like, start fetching some data. Right? There's a couple of routes that I already have set up in this, like a login and a register route. Drink a red bar too.
Speaker 0: I've got all my caffeine.
Speaker 1: More I've
Speaker 0: got my caffeine right here. Don't you worry.
Speaker 1: Give him some more energy drinks, please.
Speaker 0: I'm gonna go get one. I'll be right back. Woof. Woof. I am actually doing it.
Speaker 1: Alright. So let's fire up the dev server for Nux here. As far as the stuff that I've already got, like I said, I've got a a login route, a register route that we'll try to mess with. Looks like this. We'll go in and log in, where we can register.
Very simple. And then we just have a index page, and then, I had some testing that I was doing here. Alright. So as far as layout, what do we want? You know, a lot of times, I it's like I I love Tailwind.
Tailwind UI is totally worth the money, especially for, like, quick prototypes like this. I usually like, if it's just something I'm hacking on personally, I'll start with, like, the application shells. Like, sidebar layout. Right? This feels pretty good for, like, a Slack type of setup.
Speaker 0: Yeah. That looks good.
Speaker 1: Yep. So let's just go in. We've got that set to view. Where are we gonna run into issues at? Probably with the icons because I don't have those set, but no matter.
Alright. So as far as our pages, let's do what are we gonna do here? Let's just do, like, an app directory. Within that, we'll probably have, like, some channels.
Speaker 0: Yeah. That makes sense. Just just And then the dynamic route inside of that. Yeah.
Speaker 1: Yep. So we'll do, like, channel dot view. And then also, what I can do is set up, like, a a parent root for the app. So if I go here inside the pages directory and I do app dot view, I paste this in.
Speaker 0: Is this for, like, the sidebar? Like, the sidebar will be held in this?
Speaker 1: Yeah. Exactly. Nice. Alright. So we'll save that.
Let's see what we get.
Speaker 0: That is a major indentation. Yikes.
Speaker 1: K. So these are Rike's rules. I'm not sure if he's on here, but, alright.
Speaker 0: He quit out. He hit the wrong keyboard shortcut. That is absolutely what happened. He got arced. That's what our team say when you accidentally, like, quit the whole window.
I'm sure he'll be back in a moment. Until then, you got me, stressed as heck. Got my energy drink, waiting for the waiting for the stress to return. This is my brief moment of respite here. That was a major indentation, right?
Is it worth the time of pause? Is it worth the time of pause?
Speaker 1: Did you get arced? I I don't know what happened. Yeah. I guess I did.
Speaker 0: We're back. Sorry. You don't need to be sorry and you don't get that time back.
Speaker 1: Oh, yeah. Yeah. It's still running. I don't know what happened, man. I really don't.
Speaker 0: Weird.
Speaker 1: All right. So getting some errors here. We get console wise. Home icon. Navigation.
Yeah. This is the only bad part. I'm gonna zoom out just a little bit here so I can find
Speaker 0: Just to actually navigate this, healthscape of tabs. Yeah.
Speaker 1: Just delete a bunch of these icons. Gosh. They put so many icons in this.
Speaker 0: Everyone that direct us has a personal choice between Mac and Windows, by the way. So, you know, some folks use use either. I would say with the folks I work with directly, I think we mostly use Max, but that's definitely not the case across the board. Tim is my resident, brain slug. Tim is is my resident Windows user.
Oh, let's see. It's not about getting to use Linux. It's about wanting to use Linux. So folks wanna use it, whatever. Most of the stuff we use is in the cloud, so it doesn't really
Speaker 1: matter. Yeah. Okay. Well, at least we got something now. Right?
Alright. We're gonna ditch teams here at the bottom. Where are you? Your teams. Great.
Just ditch that list of stuff.
Speaker 0: Can you zoom back in? I'm like, I need my spectacles to see it over there.
Speaker 1: Alright. Teams is gone. Right? So now we want to fetch the list of channels here and display those. So how do we do that, Kev?
Speaker 2: Do you have the
Speaker 0: Directus SDK in this app?
Speaker 1: We do have the Directus SDK in this app.
Speaker 0: Lovely stuff. Well, have you got it set up as, like, a as, like, a plug in, or do we need to do that now?
Speaker 1: As a Nuxt plug in. So we're gonna Very good. We'll use dollar sign direct us, use Nuxt app. The only thing that I don't have is, like, the auto imports from the SDK. That was one of the nice things about the the other module I had.
So we're gonna need to do, what, read items? Yeah. From atdirectus SDK.
Speaker 0: I think that's it.
Speaker 1: Speaking of this.
Speaker 0: What's it complaining about? White space, I think. Yeah.
Speaker 1: Yeah. These are, again, these are Rikes, ESLint, and
Speaker 0: Which are very legit for building actually serious things unlike this.
Speaker 1: They're very, very legit. Right? Alright. So let's do what do we want? We want channels.
There's a ref for channels, and then we're going to well, actually, we should just be able to use Nuxt async data. Right? Nuxt data error. We get an error. We're gonna go, wait, use async data.
We'll give this a key. Let's just call it channels. And then we just return something from Directus, right? So Oh,
Speaker 0: look at that interesting code pilot code using old SDK methods. Fascinating.
Speaker 1: Yeah. Not right. Right? That's a oh, what are we doing there? Auto completion or something.
So we'll do read items. We've got channels. Rates. Oh, man. GitHub Copilot is getting on the way this time.
Speaker 0: You can turn it off if you want.
Speaker 1: We do only have an hour. We'll see. Alright. So, basically, we're gonna read all the items from channels. We wanna get the fields.
We'll just use the wild card. It's basically just name and ID. Does that do it? It should do it. Let's just destructure this and oh.
Speaker 0: Yeah.
Speaker 1: Are you are you
Speaker 0: As as channels.
Speaker 1: Needs to be channels, and we'll just call this channels. And hopefully
Speaker 0: And now now usually use channels.
Speaker 1: Yep. We just go down here. Item in channels.
Speaker 0: Very nice. And I think we could it is name. The key is name. Yeah.
Speaker 1: Yeah. Item dot name. We're just gonna swap this for, like, Nuxt link. One of the interesting things, like, Nuxt link will take a h ref or, like, a 2 property. So that's one of the nice things that I like about it just because it's you know, you're used to using h ref on the regular side when you're creating a regular link.
Right. Do you wanna do
Speaker 0: you wanna know what's happened? We've, we've hit the 20 minute mark, and, thank gosh. I don't have to be here like, I can sweat from the audience. At this point, I'm gonna I'm gonna hand off to the amazing Alex who I'm gonna bring in. Hang on.
Let let me add him in. Alex, would you, would you like to say hello?
Speaker 2: Good evening, everyone. Can you hear me alright?
Speaker 0: I can hear you grand. Lovely. Your your lovely tones. Excellent. I've
Speaker 2: I've, enjoyed watching you sweat, Jacob. It's been great.
Speaker 0: Oh, I'm sorry. It's coming it's coming for you too, mate.
Speaker 2: Yeah. Yeah. Yeah. I'm I'm learning a lot of you right now as well. So
Speaker 1: Hey, Viv. Hey. We failed to resolve next link. What is that all about?
Speaker 0: I'm gonna peace out everyone. I'm gonna put you in Alex's very capable hands for 20 minutes, and then, he will be handing off to Matt. Bye for now, folks. Enjoy the rest. Yeah.
Speaker 1: I thought we were doing, like, Royal Rumble rules. Everybody just hangs on. Be fun. Oh.
Speaker 2: You just call me now, Brian.
Speaker 1: I that's alright, my friend. How are you, dude? It's been a while since we've, like like paired up for something.
Speaker 2: Yeah. Yeah. Yeah. This is this is cool, man. I, always enjoy, seeing all this view code, which I wish I understood better.
Speaker 1: Yeah. Most of it is is tailwind at this point. But, yeah. So we having an error right now. Right?
We're not having permission to access the channels. So we just need to log in. Right? So I'm gonna go to my login form components. Let's redirect to slash app.
And we're gonna try to log in to this thing as well. I guess I need to add a user for you. Yep. I have one for Alex. Alright.
Oh, don't forget the role. Alright. So I'm just gonna try to log in as Alex now. So we're gonna log in. Oops.
Nope. That's not right. It's auth/login. I already used the link on the home page. That would have worked.
So we got Alex at example, and the password is super secure. Okay. Alright. So now we can see at least we have our channels up here. Right?
That looks good.
Speaker 2: Yep. Yeah. Nice.
Speaker 1: Alright. How are you feeling, Alex? Are you nervous as as Kevin? Like, feeling good? I
Speaker 2: I've got a feeling you got the power of Bry Ross, under the hood there. So Ross. Big. I've got confidence, man. I got confidence.
Speaker 1: Okay. Right. Alright. So now we need to fix, like, the h refs here. Like, hey.
We wanna navigate to one of these channels. Right? Let's just test if this is gonna work. I'm a script at the top guy. Not sure if we've got any other view fans or not.
I like seeing what's going on with the JavaScript first, and we're going to use the routes. So we'll do routes. Let's use routes. And I'm just gonna do this. I'm just gonna log this out.
Right? I wanna look at routes a params.channel. K. Good. The other thing that we're gonna need to do somewhere in here where's the main dev?
Main content. We're gonna plug in this Nux page here. So this should render the child page, for all my nested routes. Yeah. Alex is a boss.
So, I'm not sure if that's John Daniels or not, but, I will say, like, if you've used the template CLI tool at all, Alex is is that guy. He's the guy that put that together originally.
Speaker 2: Yeah. Thanks thanks to directors having good APIs. It was, yeah, difficult, but we we got there, and it's pretty cool right now.
Speaker 1: Yeah. Alright. So we got the next page. I save. 2 2 what's going on?
Oh, yeah. I forgot to fix the login again. Yeah. Apparently.
Speaker 2: Yeah.
Speaker 1: You need to persist that. Alright. So what else do we need to do? We need to fix those links. Channels.
Where are you? Alright. So this will be channel or item dot name.
Speaker 2: Item dot name. Yeah.
Speaker 1: And then we'll do /channels /item.name. Should get it. We'll do a Nuxt link. Oh, duh. It's app dot channels.
Speaker 2: Nice.
Speaker 1: So now we have our channels working. Right? What are we gonna do inside the channels? Right? Great call.
What do we do inside the channels? We are going to here is this is where we're actually gonna fetch, like, real time data. Right?
Speaker 2: Yeah. You think? Yeah. Yeah. I'm looking forward to this part, the the, real time.
Speaker 1: Okay. Alright. So I'm gonna cheat a little bit. We're just gonna go into our documentation. We do have this nice guide, if you haven't checked it out, on real time multi user chat.
There's a vanilla JavaScript version. There's React. There's Vue. Let's just take a look at this. Right?
Alright. How are we going to authenticate with real time? So we've got, the authentication composable. We've added the real time composable. All of those are in my plug in here.
So it should be as simple as, by calling connect. That'd be right. Let's see. Kevin's got a I think it was Kevin that he's got. We've got a subscribe function here.
So we're gonna subscribe to the messages, client dot connect. Yep. Let's see here.
Speaker 2: This is usually where I run into some SSR issues, but I'll we'll see how you manage this one, Brian.
Speaker 1: Let me show you. SSR equals false.
Speaker 2: That's That's the solution there?
Speaker 1: That's the easiest way. Yeah. Yeah. Absolutely. Alright.
Alright. So let's just, is this cheating? Yeah. This probably is. Use whatever you have at your disposal.
Right? So the subscription client dot subscribe messages, that's correct. Our fields here that we want, we're grabbing the all the fields on the root level. I guess I could zoom in a little bit and make that easier for everybody. Then we have user.
So let's just grab all the fields from the user. We've got message of subscription, and then it looks like there's a receive message function that goes along with this.
Speaker 2: Yeah. You yeah, you might need to filter on the channel as well, but maybe we can do that in the next step.
Speaker 1: Yeah. So we've got data type equals subscription. This is just like the init. Right? Let's see if we are getting any.
No. Yeah. This is gonna be interesting. I should have set up better authentication. So persisted on this.
Alright. Do we see anything from, see some more issues from Tailwind? X mark icon. Where are you? Note to self, on the next one, do not import any of the icons from.
So this should be, like, we definitely wanna redirect on this. Right? Let's add app. Let's add some page meta. Define oh, actually, it's not a const.
We'll just do define page meta. And if we give this a middleware of auth, it should automatically redirect. And then I'm gonna go into where's my login form? I'm gonna make this really easy for myself, Alex.
Speaker 2: Oh, good idea.
Speaker 1: And password, super secure. We'll learn a little bit about everything here. Okay. So it's redirected. Sign in.
This should take us back to the app, where we could get all the channels. What am I not seeing here? Right. Do we have to do we need to connect to the client, I guess? Let's plug in why we're not receiving
Speaker 2: Yeah. Client dot connect. Right? Isn't that it?
Speaker 1: Okay.
Speaker 2: Yeah.
Speaker 1: Yeah. So this is on mounted, but we're not using SSR. This should just work. Right? Where are we gonna stick that?
On? Oh, what if we just call subscribe? Set up all these functions, forgot to call them. Alright. Client is not defined.
Duh. Because it's not the client, it should be directus dot subscribe. So, again, we're gonna grab that directus plugin that we set up from use Nuxt app. It's error data is not defined. Oh, we gotta pass the data to that.
Depcription started. Okay. Alright. So what do we wanna do now? Within the channel, we wanna have all of our messages.
Right? I'm assuming that will be an array.
Speaker 2: Sounds good to me.
Speaker 1: In our received messages Actually, let's just do this to start with, see what type of data we're getting back. Received message. Alright. So now if we go in, I got, like, 35 tabs here, don't I?
Speaker 2: Don't we all?
Speaker 1: For apps. For hours. Live.
Speaker 0: Or I
Speaker 1: forgot the URL. It's just 100 apps dotdirectus.app. And I've logged myself out again. Let's keep that.
Speaker 2: I can't help you here, Brian. Okay.
Speaker 1: Alright. So now how do I split these out? That's the only thing I get hung up on on our half the time. It's like, hey. How do we make this, go split screen?
Alright. So couple things should be happening here. Right? We've got our subscription. Let's make this larger.
Right. So the subscription has started. We're in the Kevin is crazy crazy nervous. We'll probably have to filter that on our front end anyway, but, testing 1, 2, 3. We'll just add the channel to begin with.
And Oh. Cool. So we we see the real time is connecting. We're getting our data. There's the actual messages.
Great. Right. We've got the test. We've got the user is null.
Speaker 2: Probably permissions.
Speaker 1: Correct. That is correct. Alright. We need to make sure that the user role can access all the users. So right now, it's just by default, like, just a one user.
We'll just make it so we can read all the users, and let's send a new one. Test 567. Save. Get our message. Okay.
Now do we get the user data? Okay. Cool. That's a lot more user data than we actually wanted. So let's go in and trim that down.
We'll just do first name, last name, avatar. We probably want the ID too.
Speaker 2: And the
Speaker 1: dot ID.
Speaker 2: And the first name, not the first name.
Speaker 1: First name.
Speaker 2: Not the
Speaker 1: catch. Good catch. Alright. Cool. And then here, we need to what?
We want to see the message. Where's that message at? Alright. Subscription, create data. We want to filter that.
Right? What are we gonna call this? For each message of subscription, We need to populate that data. Right?
Speaker 2: Do do you wanna filter it at the at the WebSocket level or just at the whenever a new message is received? You could do both, I guess. But
Speaker 1: Yeah. I I'm trying to think of, like, in Slack, you'd probably have, like, some kinda indicator up here that's, like, hey. Yeah. Yeah. Even if a message in a different channel popped up, you would probably filter it out on the the front end.
Right? Yeah. On on the specific channel Because you probably have, like, some type of yeah. Alright. So receive message here.
What do we does it show the oh, let's get the channel name as well. Query Oh, yeah. That's that'd be a useful one. Dotidchannel.name. So here, if the data type equals subscription.
Create. And data event equals create. We will push those messages into our array of messages. And then instead of this, we should be showing a some messages. Alright.
What we doing on time? I've totally lost the window here.
Speaker 2: Yeah. Me too. Me too. It's about quarter to the hour on my clock. Let's
Speaker 1: just take a look. 22 minutes left. Okay. Alright. Cool.
Fun. Fun. Fun. Alright. GitHub Copilot for the win.
Do we how confident are we feeling? I can't even see the chat at this point.
Speaker 2: But Not confident in that one.
Speaker 1: So we'll do, like, a list for all the message. Yeah. Again, hey. Like, you gotta take it with a grain of salt. Message dot content.
You know, I I think this would get better if we had typed this out, but Yeah. Key message dot ID, we should have that for sure. We'll just close that list, see what we get. Alright. Do we have any messages?
The other thing is, like, do we fetch the messages for this channel on
Speaker 2: Initially. Right?
Speaker 1: On yeah. And, like, do you have you messed with the the real time and, like, the chat stuff at all, Alex, or no?
Speaker 2: Not not a not as much as I should have, but, this is an interesting one because you might not even need to use the real time in this in this example.
Speaker 0: Just Hello, everyone. It's the disembodied voice of Kevin here. Hello. I'm watching, I've been screaming into the void in chat. I know this isn't I know this is an illegal move to throw you a bone here, but the init payload comes with the initial items.
Up to a 100, and you can set limit minus 1 to get more than a 100. Okay. Peace out. Bye. What was that, Alex?
You wanna miss off the clock, mate.
Speaker 2: Okay. Thanks, Gabe. I think that's probably just, just we you can start logging out the the all all the messages that come through from the website. Right? So it's probably a yeah.
So it would be one of the messages received maybe, with the initial with a different type. I don't know if I've seen that in your logs to be fair. But
Speaker 1: Yeah. Let's back up. Subscription started. Received message. No.
Matt's gonna save the day on this.
Speaker 2: We should know this. I should know this, Bryant.
Speaker 1: That's alright. So, like, we we'd also do it this way as well. Right? Where we go in and read items. Oh, nope.
That's gonna be coming from the SDK. Read items from directus s e k. Let's just call this
Speaker 2: Oh, I think no. I'm starting to sweat. Thanks, Kevin.
Speaker 1: Yeah. No worries. God. What am I doing? Constant populate messages equals async.
Yeah. There we go. This is wrong. Totally wrong. Oh, no.
That's not that bad, actually. Filter channel equals route dot params.channel. Equal route dot value. No. Should just be route dot is it route dot value?
Is route
Speaker 0: reactive? Hello. Hello, everyone. It's me again. It's Kevin again.
I was I was having the chat with Matt, and in the nature of chaos, we've decided to Royal Rumble this. So it is my pleasure to introduce mister Matt Minor. Hello, Matt.
Speaker 3: Hey, everyone. I, will be the most useless person on this call because I'm not
Speaker 0: Oh, hardly.
Speaker 3: I'll help you pick the colors. And I was actually thinking, maybe I could just sabotage Bryant here at the end.
Speaker 1: Just Sabotage.
Speaker 3: The headlines of the day or something. Do it,
Speaker 0: man. Oh, no. Don't don't do that. Can you imagine?
Speaker 3: What do we have? We have we have 15 minutes.
Speaker 0: No. There's there's 20 left. We got just just 20 minutes left. We're 2 thirds of the way in. No pressure.
But it it doesn't look like Slack yet, does it? Where are the messages? Yeah. Alex, is it is this what you did with your 20 minutes, mate?
Speaker 2: Mate, we were we were work we were working hard. Yeah. We were working hard. All hardly working.
Speaker 1: Yeah. Yeah. This was
Speaker 3: where are we stuck?
Speaker 1: What are
Speaker 3: we, what are we doing?
Speaker 1: Just gonna load the initial messages.
Speaker 0: So so I know from experience that when you I don't know what's up with maybe how you're including real time here, but that init payload that init message does come. It definitely comes with all of the mess with all of the items in the collection, but I have also observed it's not happening here. So I think that would be the easiest fix is, like, why isn't that working? Because then you can just use the real time interface.
Speaker 1: Right. Why isn't that working
Speaker 2: Yeah. Kevin?
Speaker 0: Yeah. Bloody great question, mate.
Speaker 1: So I log in. We go to Kevin is crazy nervous. We start this subscription.
Speaker 0: Yeah. But where is the where's the payload? Where's that init payload? So in oh, oh, I think maybe it Oh,
Speaker 1: is it is it here?
Speaker 0: Is it is it because you're just subscribing to the single event? If you remove the event from, like, inside of the, if you get rid of that and get every everything over that subscription, does that help? There it is.
Speaker 1: Data. Oh, okay. Yep. Okay. So just use that.
Nice. Okay. There we go. My man.
Speaker 3: That's what I was gonna say too. But, Kevin
Speaker 0: I know. Sorry. I felt I felt emanating from your your corner of the ring. How are you doing today, Matt?
Speaker 1: Is I'm good. I'm doing good.
Speaker 3: I'm excited to be
Speaker 0: here. Good. News headlines for today?
Speaker 3: Facebook and Instagram. No. Struggling.
Speaker 0: I I sorry. I was too busy working, so I didn't know that.
Speaker 1: Oh, yeah.
Speaker 3: Sorry. I was too I, it just came up
Speaker 2: when
Speaker 3: I was logging in to work today. So, how's the chat doing? Is anybody Let's see.
Speaker 2: You you might have to spread that one, Bryant. I think.
Speaker 0: Yeah. Yeah. You will. You will.
Speaker 3: Just enjoying the chaos. Yeah. But for a net
Speaker 0: but for a net, dude, for a net, don't push it into the array. Just replace the array because
Speaker 1: Oh, okay.
Speaker 0: There's gonna be nothing in it at the start.
Speaker 1: Data dot data.
Speaker 0: Joshua, just enjoying the cast. Honestly, so are we. As I said, this is our first kind of live event of this kind, and I don't know. I'm having a great time. It is chaotic, and we're just making it up.
We changed the format. Who bloody cares? Love it.
Speaker 1: Yeah. Nope. Alright. So now we got some messages. Right?
Let's, let's mess with this a bit. Alright. So we're gonna have a div. We're gonna show the avatar, image source,
Speaker 0: message. Joshua, it's so funny. You're like, yeah. You know, I'm struggling, like, getting this, you know, flow automation thing to work while listening to you in the background. And the funny bit is some of the people who would be there to help you are currently here.
So it's like, have fun struggling, but you're struggling on your own for the next, 15. Nah. Jonathan's there. Funny. And
Speaker 3: you think you're struggling
Speaker 1: to get, like,
Speaker 3: 4 people watching you work at the they were all just staring over Brian Schuler right now.
Speaker 1: I love it, man. Thank you. This is this is this is more fun for me. I think I feel
Speaker 3: like I go, when I go shopping with my wife and, like, just follow her around the store. That's what I feel like right now. I know value just in the way.
Speaker 0: Alright. So far.
Speaker 1: Let's add some padding for these. What else?
Speaker 0: We have time for the padding. We have time for the padding. Dude. I'm good. God.
I'm sweating again.
Speaker 1: All things, man. All things. You you gotta have time for it. Alright. So we got some messages.
Great. Now we need what? We need a form at the bottom of this one. Right? So we got VText.
What does this thing do? This is, just text. Okay. Great. We don't need that.
So we just got an input. Text input, b model, new message. Right? So we're gonna populate. We can just scrap all this shit.
Oh, were we allowed to curse on this one or no?
Speaker 0: Well, you've done it now. So yeah. Sure. Anything anything goes.
Speaker 1: Anything goes. Alright. So we got a new message. We're just gonna add a ref for that. We will remodel new message at key up, enter, send message.
Yeah. I don't like that, but, let's just wrap it. We'll give it a button. Oh, actually, I forgot I got the Nux UI library included in this. So we should be able to get something nice just by doing new input.
Did that work? No. Nope. Did not work.
Speaker 2: No pressure, Brian. That's
Speaker 1: the beauty of this. No pressure.
Speaker 0: Yeah. We've all gone quiet. Just letting you work
Speaker 1: for a moment. New button. Just add send message. What are we doing now? Nope.
Gotta close that guy. Alright. So we got this. Right? We need to add a handler for this.
Just click send oh, let me just remove that. Send message.
Speaker 0: Nice.
Speaker 1: And then we've got should have an async function for send message. And this is not right at all. Right? So I think
Speaker 0: I don't know. How are you gonna tap into the because you you've gotta you've got to send it over the subscription, don't you?
Speaker 1: Yeah. That's that's where I was going back to your wonderful guy.
Speaker 0: Oh, no. No. No. I think it's fine. No.
No. No. Ignore me. It's totally fine. You can do it.
You can do it at that level where you've written send message because received message is at that level too. Right? So Actually Actually
Speaker 1: client.send message. Right? Should be possible or no?
Speaker 0: We'll find out in a minute. I think there's gonna be a weird scoping thing here. Let's find out.
Speaker 2: Well, I think if you just use the create item function with the new SDK,
Speaker 0: that should work. Do that,
Speaker 1: but you could also
Speaker 0: send it over you could send it over the WebSocket connection, and then you're just using that one connection use make a make a HTTP request, honestly.
Speaker 1: Test. Oh, yeah. That's why you don't trust this. Right?
Speaker 0: Yes.
Speaker 1: Request. Yeah. Create item.
Speaker 2: Yeah.
Speaker 1: Did you get it? Test. Send message. Alright. What do we get?
Unexpected error occurred.
Speaker 0: Good. Good. Good. Helpful. Helpful.
Helpful.
Speaker 2: That's the channel that's the channel name. That should be the ID. Right?
Speaker 1: Yes. Correct.
Speaker 2: Oh, did we get the channel ID?
Speaker 0: No. That's right. Because, it's in the it's coming from the URL.
Speaker 2: Yeah. But it's
Speaker 0: That value there is coming from the URL. Yeah. Yeah. The dynamic part.
Speaker 1: But the channel itself
Speaker 0: Oh, wait. Right. Right. It's saying here, ding, ding, Alex. Got it.
So hang on. I lower my confidence.
Speaker 1: There you go. Yeah. Yeah. So we gotta get the channel ID. Where do we have the data?
Right?
Speaker 0: Oh, I understand now. I understand what you mean the ID. Got it. Got it. Got it.
So I I think you'll need to do that. That initial load. Yeah. I think I think you do. Yeah.
Just to fetch that ID.
Speaker 1: I really don't wanna do that. But
Speaker 0: Mate, you've got you've got 10 9 minutes. Oh, we got left? You're doing that.
Speaker 1: We're doing it. Yeah. Alright. So read items, channels, filter ID equals no. That's our ID.
Speaker 2: What's the channel name? Right? Or
Speaker 1: Channel name. This will be wrapped. We'll have what equals. Alright. So you can have the channel.
There's the ID. Good.
Speaker 2: And it's an array out, which is a rookie error that I often make.
Speaker 1: Woah. Yep. That is. Yeah. So this will be
Speaker 0: How are you doing over there, Matt? Having a good time?
Speaker 3: Watching all along. Yeah. I'm waiting for us to get to the colors. I think that's where I'll have my most, impact.
Speaker 0: Well, we've got we've got a whole 8 minutes, and I think we're about to be finished, I guess. So, you you get a pick of the next function now or 2.
Speaker 1: If I use the, what, If we use async data, and you can do, like, some transforms on this as well. Using data. Channel. Turn up paste. Is this guy out?
Speaker 2: I think I think Greg's suggestion was the best to just use the channel ID in the in the URL.
Speaker 1: Probably. 100%. Requests from that. This needs to be here. I like the pretty URLs, though.
Alright. I will just refresh. Go to crazy nervous. Okay. So now we've got the channel.
Alright. So we got channel. This should just be the channel dot ID. Best. Okay.
So we're okay. It seems that, like, the message was sent, unless I'm wrong. Test. Okay. So it did populate the message.
We just don't see it show up here. Alright. So what are we doing wrong there?
Speaker 2: In that payload, shouldn't it also have the the channel ID?
Speaker 1: Yep. It does.
Speaker 2: But it does, but it's not showing in the console there.
Speaker 1: Test. Okay. There's the test. Send messages. Yeah.
That's kinda odd. Why is it not showing that in the payload? Alright. Regardless, we should be getting a message back. Right?
Reading undefined dot avatar. This is a simple v f. Right? Yes. Message.
Speaker 0: Just get rid of it. No one needs an image. No one needs an image. We're using Slack compact mode. Ditch it off.
Get rid of it. Just saying that's 5 that's 5 and a half minutes.
Speaker 1: Yeah. No worries, man. Alright. Test. Alright.
So first name. Why is this not populating? User but we gotta have the username. Right? It cannot read first name.
Speaker 0: It's not user. It's user created or whatever you called it. Right? Or did you rename it to user?
Speaker 1: No. It should be user created. Yeah. Channel messages dotuser.firstname. This is used, like, a v f message.
A user? You're trying to get something out of this. Oh, shoot. Blah blah blah. Kevin is crazy nervous.
Still crazy nervous.
Speaker 0: I'm literally rocking back and forward in my chair here by feeling
Speaker 1: the heat. So, like, the the messages are coming in, but we're just not populating. We missed something. Messages dot value dot push data dot data. Alright.
So if we're receiving data, we're getting data. It's it's
Speaker 2: a it's another array in there.
Speaker 1: Data is an array. Yeah. Okay. So, we'll just do this.
Speaker 0: Someone else who has the cute baby in the background, and I'm using a hardware mute, but, I think that's that's me. And they're they're they're hungry. They're not.
Speaker 2: Sorry. That might be my fault.
Speaker 0: Oh, do you I haven't heard I haven't heard yours in the background.
Speaker 2: Okay. Was it yours? Alright.
Speaker 0: Could be.
Speaker 2: They came
Speaker 0: home, but they're not sounding cute. They're not sounding cute. They're sounding angry.
Speaker 1: Alright. So now what is the Nuxt command? Right? I think there's one where I can let you guys tunnel into this. Right?
Nuxt dev tunnel? Where is this guy?
Speaker 0: That is brand that must be brand new because I didn't know that was there. But it's built into Visual Studio Code. If you bring up your status bar at the bottom, I thought it was baked in now. No way. That is sick.
Alright. So
Speaker 1: does this actually work?
Speaker 0: There there's the tunnel right there, the Cloudflare URL. Womp womp.
Speaker 1: Why Why doesn't it work?
Speaker 0: You better work it out because you got 2 minutes.
Speaker 1: At this point, I don't know. Do you guys just, do me a favor and then log in to the direct us instance in this firehouse message?
Speaker 0: I got you.
Speaker 1: P p m. Yeah. Nux. Dev. Oh, p m p m.
It would be, like, running the let's see. I don't know if that's it or not. I'm stressed. Yeah. So there we go.
Yeah.
Speaker 0: That was me.
Speaker 1: It's Does it work
Speaker 0: does it work if you type it in here as well? Yes.
Speaker 1: I I'm logged in as Alex. I'm logged in as Alex. Alright. Send send one more just so we can say something.
Speaker 0: Alright.
Speaker 1: Here? Less stressed. Yay.
Speaker 0: Yeah. Rock
Speaker 1: on. Some concept.
Speaker 0: That's basically feature complete.
Speaker 3: I was shitting. Hit right at the buzzer. Is Let's go.
Speaker 1: Because this is a winner. Yeah?
Speaker 0: Yay. Holy heck. My heart rate. I'm I'm gonna need to take a shower. I'm sweating.
Oof. Look at that.
Speaker 1: Yeah. Wow.
Speaker 0: Stop the timer.
Speaker 1: Yeah. Leave it for Stop. Yeah. Series a already. I've watched them, man.
Speaker 0: And don't forget, there's more in your stressing and dressing in 100 hours. A whole season now available on Directus TV with more coming in April.
Speaker 1: I I look forward to the other episodes where you guys are are it may be not on there. I I've enjoyed this a lot, though. This is fun. It definitely distracted a little bit.
Speaker 0: Yeah. I did feel like, should this be, like, 1 app in a 100 hours, but with guests? Oh, wow.
Speaker 1: Oh, so takeaways from this. Right? What did we what did we learn?
Speaker 0: I'm not coming back to the next one.
Speaker 3: Spend more time with Patty.
Speaker 1: More time with that. Dude, I'm sorry we didn't get to the, like, colors. Like, do you wanna what what color are you feeling, Matt? It's the only reason I'm so sorry. Pick the color.
I'm looking for the color.
Speaker 3: I can't think of the hex code
Speaker 1: for
Speaker 3: I didn't 466, double f.
Speaker 1: What do you want? 4466
Speaker 3: f f.
Speaker 0: No. It's 6644 f f.
Speaker 3: Knew it. Hopefully, Ben's not watching.
Speaker 0: What is it? Oh, he's watching. 6:6:8. He's watching.
Speaker 1: 44 f f. Where are we? Is it not updating? Is that already the indigo oh, there it is. Okay.
No?
Speaker 0: Maybe it wasn't on it here. Is that the sidebar?
Speaker 1: Yeah. Okay. Sidebar. Yeah. There you go.
BG you're gonna find me one more time. 6644 f f? Yep.
Speaker 0: That's the one.
Speaker 1: That's it. There it is.
Speaker 0: Subtleship. Boom. Feature comp New product. Ship it. Thanks everyone for joining us.
Speaker 1: Yeah.
Speaker 0: I'm not I'm not kidding. We probably won't do another one now. We probably will, but I won't be here. Gosh. Literally, 30 seconds to go.
30 seconds to go. Congratulations, Brian.
Speaker 1: Yeah. I feel like we started off on the wrong foot with the 5 minutes of technical difficulties. The for the nodes. Selecting 5 minutes of technical difficulties at the the start of this thing. That's what everybody did not see on the front
Speaker 0: end. We got there. We got there.
Speaker 1: Now we're now we're ready to code for, like, another 2 hours. And if you're
Speaker 0: watching this live, this whole episode will be packaged up as a special at the end of season 1 of a 100 and a 100 hours on director's TV. We'll pop that out tomorrow. And then there are new episodes of a 100 apps and a 100 hours coming in April.
Speaker 1: Amazing. Excellent. Yeah. Well, thanks for joining us, to the circus episode of 100 Hours 100 Hours. I'm your host, Brian Gillispie.
Thanks to my special guests, mister Kevin Lewis, mister Avdv, and Awesome. With the crazy colors coming in.
Speaker 0: Thank you, everyone. Bye for now.
Speaker 2: Cheers. Bye. Cheers.