-
Notifications
You must be signed in to change notification settings - Fork 256
[Remove Vuetify from Studio] Cards in Starred channels changes #5556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| 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 { | ||
| await store.dispatch('channel/loadChannelList', { listType }); | ||
| } catch (error) { | ||
| loading.value = false; | ||
| } finally { | ||
| loading.value = false; | ||
| } | ||
| }; | ||
|
|
||
| const newChannel = () => { | ||
|
||
| if (window.$analytics) { | ||
| window.$analytics.trackClick('channel_list', 'Create channel'); | ||
| } | ||
|
|
||
| router.push({ | ||
| name: RouteNames.NEW_CHANNEL, | ||
| query: { last: route.name }, | ||
| }); | ||
| }; | ||
|
|
||
| const goToChannel = channelId => { | ||
| window.location.href = window.Urls.channel(channelId); | ||
| }; | ||
|
|
||
| onMounted(() => { | ||
| loadData(); | ||
| }); | ||
|
|
||
| return { | ||
| loading, | ||
| channels, | ||
| listChannels, | ||
| hasChannels, | ||
|
|
||
| maxWidthStyle, | ||
|
|
||
| loadData, | ||
| newChannel, | ||
| goToChannel, | ||
|
||
| }; | ||
| } | ||
There was a problem hiding this comment.
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,...)?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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