Skip to content

Commit 83466c0

Browse files
committed
(props) add loadFirstRoom
1 parent ea10cbd commit 83466c0

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

README.md

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -171,36 +171,39 @@ fetchMessages({ room, options }) {
171171
| rooms | Array | - | [ ] |
172172
| loadingRooms (2) | Boolean | - | false |
173173
| roomId (3) | [String, Number] | - | null |
174+
| loadFirstRoom (4) | Boolean | - | true |
174175
| messages | Array | - | [ ] |
175-
| roomMessage (4) | Object | - | null |
176-
| messagesLoaded (5) | Boolean | - | false |
177-
| menuActions (6) | Array | - | [ ] |
178-
| messageActions (7) | Array | - | (4) |
176+
| roomMessage (5) | Object | - | null |
177+
| messagesLoaded (6) | Boolean | - | false |
178+
| menuActions (7) | Array | - | [ ] |
179+
| messageActions (8) | Array | - | (4) |
179180
| showAddRoom | Boolean | - | true |
180181
| showSendIcon | Boolean | - | true |
181182
| showFiles | Boolean | - | true |
182183
| showAudio | Boolean | - | true |
183184
| showEmojis | Boolean | - | true |
184185
| showReactionEmojis | Boolean | - | true |
185-
| showNewMessagesDivider (8) | Boolean | - | true |
186-
| textMessages (9) | Object | - | null |
187-
| textFormatting (10) | Boolean | - | true |
188-
| responsiveBreakpoint (11) | Number | - | 900 |
189-
| singleRoom (12) | Boolean | - | false |
190-
| theme (13) | Sring | - | light |
191-
| styles (14) | Object | - | (10) |
186+
| showNewMessagesDivider (9) | Boolean | - | true |
187+
| textMessages (10) | Object | - | null |
188+
| textFormatting (11) | Boolean | - | true |
189+
| responsiveBreakpoint (12) | Number | - | 900 |
190+
| singleRoom (13) | Boolean | - | false |
191+
| theme (14) | Sring | - | light |
192+
| styles (15) | Object | - | (10) |
192193

193194
(1) `currentUserId` is required to display UI and trigger actions according to the user using the chat (ex: messages position on the right, etc.)
194195

195196
(2) `loadingRooms` can be used to show/hide a spinner icon while rooms are loading
196197

197198
(3) `roomId` can be used to load a specific room at any time
198199

199-
(4) `roomMessage` can be used to add a default textarea value
200+
(4) `loadFirstRoom` can be used to remove the default behaviour of opening the first room at initialization
200201

201-
(5) `messagesLoaded` must be manually set to `true` when all messages of a conversation have been loaded. Meaning the user cannot scroll on top anymore
202+
(5) `roomMessage` can be used to add a default textarea value
202203

203-
(6) `menuActions` can be used to display your own buttons when clicking the vertical dots icon inside a room.<br>
204+
(6) `messagesLoaded` must be manually set to `true` when all messages of a conversation have been loaded. Meaning the user cannot scroll on top anymore
205+
206+
(7) `menuActions` can be used to display your own buttons when clicking the vertical dots icon inside a room.<br>
204207
You can then use the [menuActionHandler](#events-api) event to call your own action after clicking a button. Ex:
205208

206209
```javascript
@@ -220,7 +223,7 @@ menuActions="[
220223
]"
221224
```
222225

223-
(7) `messageActions` can be used to display your own buttons when clicking the dropdown icon inside a message.<br>
226+
(8) `messageActions` can be used to display your own buttons when clicking the dropdown icon inside a message.<br>
224227
You can then use the [messageActionHandler](#events-api) event to call your own action after clicking a button. Ex:
225228

226229
```javascript
@@ -260,9 +263,9 @@ messageActions="[
260263
]"
261264
```
262265

263-
(8) `showNewMessagesDivider` can be used to show/hide the blue line divider between seen and unseen messages.
266+
(9) `showNewMessagesDivider` can be used to show/hide the blue line divider between seen and unseen messages.
264267

265-
(9) `textMessages` can be used to replace default i18n texts. Ex:
268+
(10) `textMessages` can be used to replace default i18n texts. Ex:
266269

267270
```javascript
268271
textMessages="{
@@ -279,7 +282,7 @@ textMessages="{
279282
}"
280283
```
281284

282-
(10) `textFormatting` can be used to add text formatting. Currently, bold, italic, strikethrough, underline, inline code and multiline code formatting are available and can be used in conjonction. You can disable text formatting by passing the prop as `:textFormatting="false"`.
285+
(11) `textFormatting` can be used to add text formatting. Currently, bold, italic, strikethrough, underline, inline code and multiline code formatting are available and can be used in conjonction. You can disable text formatting by passing the prop as `:textFormatting="false"`.
283286

284287
| Style | Syntax | Example | Output |
285288
| ----------------- | --------------- | -------------------------------------- | -------------------------------------- |
@@ -306,13 +309,13 @@ This is
306309
multiline code
307310
```
308311

309-
(11) `responsiveBreakpoint` can be used to collapse the rooms list on the left when then viewport size goes below the specified width.
312+
(12) `responsiveBreakpoint` can be used to collapse the rooms list on the left when then viewport size goes below the specified width.
310313

311-
(12) `singleRoom` can be used if you never want to show the rooms list on the left. You still need to pass the `rooms` prop as an array with a single element.
314+
(13) `singleRoom` can be used if you never want to show the rooms list on the left. You still need to pass the `rooms` prop as an array with a single element.
312315

313-
(13) `theme` can be used to change the chat theme. Currently, only `light` and `dark` are available.
316+
(14) `theme` can be used to change the chat theme. Currently, only `light` and `dark` are available.
314317

315-
(14) `styles` can be used to customize your own theme. Ex:
318+
(15) `styles` can be used to customize your own theme. Ex:
316319

317320
```javascript
318321
styles="{

src/ChatWindow/ChatWindow.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export default {
9090
rooms: { type: Array, default: () => [] },
9191
loadingRooms: { type: Boolean, default: false },
9292
roomId: { type: [String, Number], default: null },
93+
loadFirstRoom: { type: Boolean, default: true },
9394
messages: { type: Array, default: () => [] },
9495
messagesLoaded: { type: Boolean, default: false },
9596
menuActions: { type: Array, default: () => [] },
@@ -125,6 +126,8 @@ export default {
125126
rooms: {
126127
immediate: true,
127128
handler(newVal, oldVal) {
129+
if (!this.loadFirstRoom) return (this.showRoomsList = true)
130+
128131
if (
129132
!newVal[0] ||
130133
!newVal.find(room => room.roomId === this.room.roomId)

src/ChatWindow/Room.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</div>
4242
</slot>
4343
</div>
44-
<slot name="room-options">
44+
<slot v-if="room.roomId" name="room-options">
4545
<div
4646
class="svg-button room-options"
4747
v-if="menuActions.length"
@@ -969,7 +969,7 @@ textarea {
969969
}
970970
971971
.icon-microphone-off {
972-
animation: scaling .8s ease-in-out infinite alternate;
972+
animation: scaling 0.8s ease-in-out infinite alternate;
973973
}
974974
975975
@keyframes scaling {

0 commit comments

Comments
 (0)