Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { ref, computed, onMounted, getCurrentInstance } from 'vue';
import { useRouter, useRoute } from 'vue-router/composables';
import useKResponsiveWindow from 'kolibri-design-system/lib/composables/useKResponsiveWindow';
import orderBy from 'lodash/orderBy';
import { RouteNames } from '../constants';

/**
* Composable for channel list functionality
*
* @param {Object} options - Configuration options
* @param {string} options.listType - Type of channel list (from ChannelListTypes)
* @param {Array<string>} options.sortFields - Fields to sort by (default: ['modified'])
* @param {Array<string>} options.orderFields - Sort order (default: ['desc'])
* @returns {Object} Channel list state and methods
*/
export function useChannelList(options = {}) {
const { listType, sortFields = ['modified'], orderFields = ['desc'] } = options;

const instance = getCurrentInstance();
const store = instance.proxy.$store;

const router = useRouter();
const route = useRoute();

const { windowIsMedium, windowIsLarge, windowBreakpoint } = useKResponsiveWindow();

const loading = ref(false);

const channels = computed(() => store.getters['channel/channels'] || []);

const listChannels = computed(() => {
if (!channels.value || channels.value.length === 0) {
return [];
}

const filtered = channels.value.filter(channel => channel[listType] && !channel.deleted);

return orderBy(filtered, sortFields, orderFields);
});

const hasChannels = computed(() => listChannels.value.length > 0);

const maxWidthStyle = computed(() => {
if (windowBreakpoint.value >= 5) return '50%';
if (windowBreakpoint.value === 4) return '66.66%';
if (windowBreakpoint.value === 3) return '83.33%';

if (windowIsLarge.value) return '50%';
if (windowIsMedium.value) return '83.33%';

return '100%';
});

const loadData = async () => {
loading.value = true;
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried, just from how the implementation is done - it seems that if there was an error when loading a channel list, it would fail silently? We don't need any new UI, mostly wondering what would experience be like and how it compares to the original version (e.g. was there a console error displayed before or not,...)?

Copy link
Contributor Author

@yeshwanth235 yeshwanth235 Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In previous version. There is no catch block.
L151

await store.dispatch('channel/loadChannelList', { listType });
} catch (error) {
loading.value = false;
} finally {
loading.value = false;
}
};

onMounted(() => {
loadData();
});

return {
loading,
channels,
listChannels,
hasChannels,

maxWidthStyle,

loadData,
};
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import VueRouter from 'vue-router';
import ChannelList from './views/Channel/ChannelList';
import StudioMyChannels from './views/Channel/StudioMyChannels.vue';
import StudioStarredChannels from './views/Channel/StudioStarredChannels.vue';
import ChannelSetList from './views/ChannelSet/ChannelSetList';
import ChannelSetModal from './views/ChannelSet/ChannelSetModal';
import CatalogList from './views/Channel/CatalogList';
Expand Down Expand Up @@ -37,8 +38,7 @@ const router = new VueRouter({
{
name: RouteNames.CHANNELS_STARRED,
path: '/starred',
component: ChannelList,
props: { listType: ChannelListTypes.STARRED },
component: StudioStarredChannels,
},
{
name: RouteNames.CHANNELS_VIEW_ONLY,
Expand Down
Loading
Loading