Skip to content

Commit

Permalink
readd and fix learneth
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 committed Jul 17, 2024
1 parent 3f32f99 commit 2d9b720
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 80 deletions.
6 changes: 3 additions & 3 deletions apps/learneth/src/pages/StepList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ function StepListPage(): JSX.Element {
</div>
</div>
<div id="top"></div>
<h1 className="pl-3 pr-3 pt-2 pb-1 menuspacer">{entity.name}</h1>
<h1 className="pl-3 pr-3 pt-2 pb-1 menuspacer">{entity && entity.name}</h1>
<div className="container-fluid">
<Markdown>{entity.text}</Markdown>
<Markdown>{entity && entity.text}</Markdown>
</div>
<SlideIn>
<article className="list-group m-3">
{entity.steps.map((step: any, i: number) => (
{entity && entity.steps.map((step: any, i: number) => (
<Link key={i} to={`/detail?id=${id}&stepId=${i}`} className="rounded-0 btn btn-light border-bottom text-left steplink" onClick={() => (window as any)._paq.push(['trackEvent', 'learneth', 'step_slide_in', `${id}/${i}/${step.name}`])}>
{step.name} »
</Link>
Expand Down
155 changes: 79 additions & 76 deletions apps/learneth/src/redux/models/workshop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,103 +44,106 @@ const Model: ModelType = {
*loadRepo({ payload }, { put, select }) {
toast.info(`loading ${payload.name}/${payload.branch}`)

yield put({
type: 'loading/save',
payload: {
screen: true,
},
})

const { list, detail } = yield select((state) => state.workshop)

const url = `${apiUrl}/clone/${encodeURIComponent(payload.name)}/${payload.branch}?${Math.random()}`
console.log('loading ', url)
const { data } = yield axios.get(url)
const repoId = `${payload.name}-${payload.branch}`
const { list, detail } = yield select((state) => state.workshop)

for (let i = 0; i < data.ids.length; i++) {
const {
steps,
metadata: {
data: { steps: metadataSteps },
if (!detail[repoId]) {
yield put({
type: 'loading/save',
payload: {
screen: true,
},
} = data.entities[data.ids[i]]

let newSteps = []
})

if (metadataSteps) {
newSteps = metadataSteps.map((step: any) => {
return {
...steps.find((item: any) => item.name === step.path),
name: step.name,
}
})
} else {
newSteps = steps.map((step: any) => ({
...step,
name: step.name.replace('_', ' '),
}))
}
const url = `${apiUrl}/clone/${encodeURIComponent(payload.name)}/${payload.branch}?${Math.random()}`
console.log('loading ', url)
const { data } = yield axios.get(url)

for (let i = 0; i < data.ids.length; i++) {
const {
steps,
metadata: {
data: { steps: metadataSteps },
},
} = data.entities[data.ids[i]]

let newSteps = []

if (metadataSteps) {
newSteps = metadataSteps.map((step: any) => {
return {
...steps.find((item: any) => item.name === step.path),
name: step.name,
}
})
} else {
newSteps = steps.map((step: any) => ({
...step,
name: step.name.replace('_', ' '),
}))
}

const stepKeysWithFile = ['markdown', 'solidity', 'test', 'answer', 'js', 'vy']

for (let j = 0; j < newSteps.length; j++) {
const step = newSteps[j]
for (let k = 0; k < stepKeysWithFile.length; k++) {
const key = stepKeysWithFile[k]
if (step[key]) {
try {
step[key].content = null // we load this later
} catch (error) {
console.error(error)
const stepKeysWithFile = ['markdown', 'solidity', 'test', 'answer', 'js', 'vy']

for (let j = 0; j < newSteps.length; j++) {
const step = newSteps[j]
for (let k = 0; k < stepKeysWithFile.length; k++) {
const key = stepKeysWithFile[k]
if (step[key]) {
try {
step[key].content = null // we load this later
} catch (error) {
console.error(error)
}
}
}
}
data.entities[data.ids[i]].steps = newSteps
}
data.entities[data.ids[i]].steps = newSteps
}

const workshopState = {
detail: {
...detail,
[repoId]: {
...data,
group: groupBy(
data.ids.map((id: string) => pick(data.entities[id], ['level', 'id'])),
(item: any) => item.level
),
...payload,
const workshopState = {
detail: {
...detail,
[repoId]: {
...data,
group: groupBy(
data.ids.map((id: string) => pick(data.entities[id], ['level', 'id'])),
(item: any) => item.level
),
...payload,
},
},
},
list: detail[repoId] ? list : [...list, payload],
selectedId: repoId,
}
yield put({
type: 'workshop/save',
payload: workshopState,
})
localStorage.setItem('workshop.state', JSON.stringify(workshopState))
list: detail[repoId] ? list : [...list, payload],
selectedId: repoId,
}
yield put({
type: 'workshop/save',
payload: workshopState,
})
localStorage.setItem('workshop.state', JSON.stringify(workshopState))

toast.dismiss()
yield put({
type: 'loading/save',
payload: {
screen: false,
},
})
toast.dismiss()
yield put({
type: 'loading/save',
payload: {
screen: false,
},
});
(<any>window)._paq.push(['trackEvent', 'learneth', 'load_repo', payload.name])
}

if (payload.id) {
const { detail, selectedId } = workshopState
const { ids, entities } = detail[selectedId]
const { detail } = yield select((state) => state.workshop)
const { ids, entities } = detail[repoId]
for (let i = 0; i < ids.length; i++) {
const entity = entities[ids[i]]
if (entity.metadata.data.id === payload.id || i + 1 === payload.id) {
yield router.navigate(`/list?id=${ids[i]}`)
break
}
}
};
(<any>window)._paq.push(['trackEvent', 'learneth', 'start_tutorial', payload.name])
}
(<any>window)._paq.push(['trackEvent', 'learneth', 'load_repo', payload.name])
},
*resetAll(_, { put }) {
yield put({
Expand Down
2 changes: 1 addition & 1 deletion libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {
{!(platform === appPlatformTypes.desktop) ?
<HomeTabFile plugin={plugin} />:
<HomeTabFileElectron plugin={plugin}></HomeTabFileElectron>}
{/* <HomeTabLearn plugin={plugin} /> */}
<HomeTabLearn plugin={plugin} />
</div>
<div className="pl-2 pr-3 justify-content-start d-flex flex-column" style={{ width: `${carouselWidth}%` }} id="remixUIHTRight">
<LanguageOptions plugin={plugin}/>
Expand Down

0 comments on commit 2d9b720

Please sign in to comment.