sort channels
This commit is contained in:
parent
951906335a
commit
22794f7bfb
5 changed files with 26 additions and 9 deletions
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
.files {
|
.files {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
max-width: calc(100vw - 140px);
|
max-width: calc(100vw - 140px);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
margin-top: 12px;
|
||||||
.filesView {
|
.filesView {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: 0.3s ease-in-out;
|
transition: 0.3s ease-in-out;
|
||||||
|
|
|
||||||
|
|
@ -157,8 +157,10 @@ export class AddNewChannelComponent {
|
||||||
* @param channelName
|
* @param channelName
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
chechIfChannelExist(channelName: string){
|
chechIfChannelExist(channelName: string) {
|
||||||
const filterChannel = this.channelService.allChannels.some(channel => channel.name === channelName);
|
const filterChannel = this.channelService.allChannels.some(
|
||||||
|
(channel) => channel.name === channelName
|
||||||
|
);
|
||||||
if (filterChannel) {
|
if (filterChannel) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -178,6 +180,7 @@ export class AddNewChannelComponent {
|
||||||
hashtag: this.channelName,
|
hashtag: this.channelName,
|
||||||
createdDate: this.currentDate,
|
createdDate: this.currentDate,
|
||||||
addedUser: this.checkUserArray(),
|
addedUser: this.checkUserArray(),
|
||||||
|
index: this.lastChannelIndex() + 1,
|
||||||
};
|
};
|
||||||
const channelId = await this.channelService.createNewChannel(
|
const channelId = await this.channelService.createNewChannel(
|
||||||
newChannel,
|
newChannel,
|
||||||
|
|
@ -190,6 +193,17 @@ export class AddNewChannelComponent {
|
||||||
this.route.navigateByUrl(`main/${channelId}`);
|
this.route.navigateByUrl(`main/${channelId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the index of the last channel and returns the next available index.
|
||||||
|
* @returns {number} The next available channel index.
|
||||||
|
*/
|
||||||
|
lastChannelIndex(): number {
|
||||||
|
const channels = this.channelService.allChannels.filter(
|
||||||
|
(channel) => channel.index !== undefined && channel.index !== null
|
||||||
|
);
|
||||||
|
return Math.max(...channels.map((channel) => channel.index));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the user array.
|
* Checks the user array.
|
||||||
* @returns The user array.
|
* @returns The user array.
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
class="arrowImg"
|
class="arrowImg"
|
||||||
/>
|
/>
|
||||||
<img src="./assets/img/sidebar/bubbles.svg" alt="" />
|
<img src="./assets/img/sidebar/bubbles.svg" alt="" />
|
||||||
<p> {{ 'sidebar-channels.channel' | translate }}</p>
|
<p>{{ "sidebar-channels.channel" | translate }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn">
|
<div class="btn">
|
||||||
<app-small-btn
|
<app-small-btn
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
showAllChanneld: minimizeChannels
|
showAllChanneld: minimizeChannels
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
@for (channel of getChannels(); track channel; let i = $index) {
|
@for (channel of getChannels(); track channel) {
|
||||||
<div
|
<div
|
||||||
class="channelName"
|
class="channelName"
|
||||||
routerLink="/main/{{ channel.id }}"
|
routerLink="/main/{{ channel.id }}"
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
<div class="circle">
|
<div class="circle">
|
||||||
<img src="./assets/img/sidebar/add-circle.svg" alt="" />
|
<img src="./assets/img/sidebar/add-circle.svg" alt="" />
|
||||||
</div>
|
</div>
|
||||||
<p>{{ 'sidebar-channels.addChannel' | translate }}</p>
|
<p>{{ "sidebar-channels.addChannel" | translate }}</p>
|
||||||
</div>
|
</div>
|
||||||
<app-add-new-channel
|
<app-add-new-channel
|
||||||
[viewWidth]="viewWidth"
|
[viewWidth]="viewWidth"
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,8 @@ export class SidebarChannelsComponent {
|
||||||
(channel) => !priorityChannels.includes(channel)
|
(channel) => !priorityChannels.includes(channel)
|
||||||
);
|
);
|
||||||
|
|
||||||
return [...priorityChannels, ...otherChannels];
|
return [...priorityChannels, ...otherChannels].sort(
|
||||||
|
(a, b) => a.index - b.index
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ export interface Channel {
|
||||||
hashtag: string;
|
hashtag: string;
|
||||||
createdDate: string;
|
createdDate: string;
|
||||||
addedUser: Array<string>;
|
addedUser: Array<string>;
|
||||||
|
index: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PrvChannel {
|
export interface PrvChannel {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue