mirror of
https://github.com/spacebarchat/client.git
synced 2024-11-25 11:42:30 +01:00
new channel sorting
This commit is contained in:
parent
5a654d340b
commit
bdefa79025
@ -6,6 +6,7 @@ import {
|
||||
type GatewayGuildMemberListUpdateDispatchData,
|
||||
} from "@spacebarchat/spacebar-api-types/v9";
|
||||
import { ObservableMap, ObservableSet, action, computed, makeObservable, observable } from "mobx";
|
||||
import { compareChannels } from "../../utils/Utils";
|
||||
import AppStore from "../AppStore";
|
||||
import GuildMemberListStore from "../GuildMemberListStore";
|
||||
import GuildMemberStore from "../GuildMemberStore";
|
||||
@ -142,9 +143,15 @@ export default class Guild {
|
||||
|
||||
@computed
|
||||
get channels() {
|
||||
return this.app.channels.all
|
||||
.filter((channel) => this.channels_.has(channel.id))
|
||||
.sort((a, b) => (a.position ?? 0) - (b.position ?? 0));
|
||||
const guildChannels = this.app.channels.all.filter((channel) => this.channels_.has(channel.id));
|
||||
const topLevelChannels = guildChannels.filter((channel) => !channel.parentId);
|
||||
const sortedChannels = topLevelChannels
|
||||
.sort(compareChannels)
|
||||
.flatMap((topLevelChannel) => [
|
||||
topLevelChannel,
|
||||
...guildChannels.filter((channel) => channel.parentId === topLevelChannel.id).sort(compareChannels),
|
||||
]);
|
||||
return sortedChannels;
|
||||
}
|
||||
|
||||
@computed
|
||||
|
@ -1,5 +1,6 @@
|
||||
import * as Icons from "@mdi/js";
|
||||
import { APIAttachment, EmbedType } from "@spacebarchat/spacebar-api-types/v9";
|
||||
import Channel from "../stores/objects/Channel";
|
||||
import { ARCHIVE_MIMES, EMBEDDABLE_AUDIO_MIMES, EMBEDDABLE_IMAGE_MIMES, EMBEDDABLE_VIDEO_MIMES } from "./constants";
|
||||
|
||||
export const decimalColorToHex = (decimal: number) => {
|
||||
@ -128,3 +129,7 @@ export function hexToRGB(hex: string) {
|
||||
b: parseInt(m[3], 16),
|
||||
};
|
||||
}
|
||||
|
||||
export function compareChannels(a: Channel, b: Channel): number {
|
||||
return (a.position ?? 0) - (b.position ?? 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user