-
Notifications
You must be signed in to change notification settings - Fork 904
adds logic to LibraryPage to optionally display a particular device's… #10227
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 all commits
a35c401
441934c
667d2f7
633fbda
dcb88b4
ace1329
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 |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| import { get } from '@vueuse/core'; | ||
| import { ContentNodeResource } from 'kolibri.resources'; | ||
| import { ContentNodeResource, RemoteChannelResource } from 'kolibri.resources'; | ||
| import samePageCheckGenerator from 'kolibri.utils.samePageCheckGenerator'; | ||
| import { PageNames } from '../../constants'; | ||
| import { PageNames, KolibriStudioId } from '../../constants'; | ||
| import useChannels from '../../composables/useChannels'; | ||
| import { setCurrentDevice } from '../../composables/useDevices'; | ||
| import useLearnerResources from '../../composables/useLearnerResources'; | ||
| import { searchKeys } from '../../composables/useSearch'; | ||
| import plugin_data from 'plugin_data'; | ||
|
|
||
| const { channels, fetchChannels } = useChannels(); | ||
|
|
||
|
|
@@ -77,13 +78,39 @@ function _showLibrary(store, query, channels, baseurl) { | |
| } | ||
|
|
||
| export function showLibrary(store, query, deviceId = null) { | ||
| if (deviceId) { | ||
| return setCurrentDevice(deviceId).then(device => { | ||
| const baseurl = device.base_url; | ||
| return fetchChannels({ baseurl }).then(channels => { | ||
| return _showLibrary(store, query, channels, baseurl); | ||
| }); | ||
| /** | ||
| * ToDo: remove if block. | ||
| * Currently the channels & contentnode browser apis in studio | ||
| * are not able to load content using the the studio base url. | ||
| * Once studio is updated, this function will need to be refactored | ||
| * to use the else block code only. | ||
| * | ||
| * The if block is meant for UI viualization purposes only | ||
| * during development | ||
| */ | ||
| if (deviceId === KolibriStudioId) { | ||
| RemoteChannelResource.getKolibriStudioStatus().then(({ data }) => { | ||
| if (data.status === 'online') { | ||
| RemoteChannelResource.fetchCollection().then(channels => { | ||
| //This is a hack to return kolibri channels. | ||
| store.commit('SET_ROOT_NODES', channels); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jredrejo it looks like the current implementation within the LibraryPage returns the previously loaded library channels as the newly selected library loads. This is an issue that I think should be resolved once loading states are streamlined across the remote content browsing feature. @rtibbles any thoughts on this?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, it's showing both the channels existing in the local device plus the one on the remote device.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though the behavior is for previous results to be cleared once the loading is complete for remote devices. Not very sure the behavior with locally hosted devices
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the lack of the loading state is key here - especially as local channels are bootstrapped into the page so there's no loading at all. |
||
|
|
||
| store.commit('CORE_SET_PAGE_LOADING', false); | ||
| store.commit('CORE_SET_ERROR', null); | ||
| store.commit('SET_PAGE_NAME', PageNames.LIBRARY); | ||
| return Promise.resolve(); | ||
| }); | ||
| } | ||
| }); | ||
| } else { | ||
| if (deviceId) { | ||
| return setCurrentDevice(deviceId).then(device => { | ||
| const baseurl = deviceId === KolibriStudioId ? plugin_data.studio_baseurl : device.base_url; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe this is a naive question, but wouldn't it be possible to reuse the code from the device channel in the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ultimately, we should remove most of this special casing, once we have a version of Studio that we can test against that supports the v2 public content APIs, then all we need to do is pass in the Studio baseurl, and channels and resources should all be fetched properly from Studio. |
||
| return fetchChannels({ baseurl }).then(channels => { | ||
| return _showLibrary(store, query, channels, baseurl); | ||
| }); | ||
| }); | ||
| } | ||
| return _showLibrary(store, query, get(channels)); | ||
| } | ||
| return _showLibrary(store, query, get(channels)); | ||
| } | ||

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.
Flagging for any other reviewers that until we have a Studio server with the new public content APIs in them, we have to do it this way.