fixing linting for learneth

pull/4771/head
lianahus 7 months ago
parent 46fed5488b
commit d0dd8a27a2
  1. 4
      apps/learneth/src/redux/hooks.ts
  2. 8
      apps/learneth/src/redux/models/loading.ts
  3. 40
      apps/learneth/src/redux/models/remixide.ts
  4. 26
      apps/learneth/src/redux/models/workshop.ts
  5. 6
      apps/learneth/src/redux/store.ts
  6. 8
      apps/learneth/src/remix-client.ts

@ -1,5 +1,5 @@
import {useDispatch, type TypedUseSelectorHook, useSelector} from 'react-redux' import { useDispatch, type TypedUseSelectorHook, useSelector } from 'react-redux'
import {type AppDispatch, type RootState} from './store' import { type AppDispatch, type RootState } from './store'
export const useAppDispatch: () => AppDispatch = useDispatch export const useAppDispatch: () => AppDispatch = useDispatch
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector

@ -1,11 +1,11 @@
import {type ModelType} from '../store' import { type ModelType } from '../store'
const Model: ModelType = { const Model: ModelType = {
namespace: 'loading', namespace: 'loading',
state: {screen: true}, state: { screen: true },
reducers: { reducers: {
save(state, {payload}) { save(state, { payload }) {
return {...state, ...payload} return { ...state, ...payload }
}, },
}, },
effects: {}, effects: {},

@ -1,7 +1,7 @@
import {toast} from 'react-toastify' import { toast } from 'react-toastify'
import {type ModelType} from '../store' import { type ModelType } from '../store'
import remixClient from '../../remix-client' import remixClient from '../../remix-client'
import {router} from '../../App' import { router } from '../../App'
function getFilePath(file: string): string { function getFilePath(file: string): string {
const name = file.split('/') const name = file.split('/')
@ -17,12 +17,12 @@ const Model: ModelType = {
// theme: '', // theme: '',
}, },
reducers: { reducers: {
save(state, {payload}) { save(state, { payload }) {
return {...state, ...payload} return { ...state, ...payload }
}, },
}, },
effects: { effects: {
*connect(_, {put}) { *connect(_, { put }) {
toast.info('connecting to the REMIX IDE') toast.info('connecting to the REMIX IDE')
yield put({ yield put({
@ -45,7 +45,7 @@ const Model: ModelType = {
yield router.navigate('/home') yield router.navigate('/home')
}, },
*displayFile({payload: step}, {select, put}) { *displayFile({ payload: step }, { select, put }) {
let content = '' let content = ''
let path = '' let path = ''
if (step.solidity?.file) { if (step.solidity?.file) {
@ -73,7 +73,7 @@ const Model: ModelType = {
}, },
}) })
const {detail, selectedId} = yield select((state) => state.workshop) const { detail, selectedId } = yield select((state) => state.workshop)
const workshop = detail[selectedId] const workshop = detail[selectedId]
console.log('loading ', step, workshop) console.log('loading ', step, workshop)
@ -87,7 +87,7 @@ const Model: ModelType = {
yield remixClient.call('fileManager', 'switchFile', `${path}`) yield remixClient.call('fileManager', 'switchFile', `${path}`)
yield put({ yield put({
type: 'remixide/save', type: 'remixide/save',
payload: {errorLoadingFile: false}, payload: { errorLoadingFile: false },
}) })
toast.dismiss() toast.dismiss()
} catch (error) { } catch (error) {
@ -95,7 +95,7 @@ const Model: ModelType = {
toast.error('File could not be loaded. Please try again.') toast.error('File could not be loaded. Please try again.')
yield put({ yield put({
type: 'remixide/save', type: 'remixide/save',
payload: {errorLoadingFile: true}, payload: { errorLoadingFile: true },
}) })
} }
yield put({ yield put({
@ -105,7 +105,7 @@ const Model: ModelType = {
}, },
}) })
}, },
*testStep({payload: step}, {select, put}) { *testStep({ payload: step }, { select, put }) {
yield put({ yield put({
type: 'loading/save', type: 'loading/save',
payload: { payload: {
@ -116,9 +116,9 @@ const Model: ModelType = {
try { try {
yield put({ yield put({
type: 'remixide/save', type: 'remixide/save',
payload: {success: false}, payload: { success: false },
}) })
const {detail, selectedId} = yield select((state) => state.workshop) const { detail, selectedId } = yield select((state) => state.workshop)
const workshop = detail[selectedId] const workshop = detail[selectedId]
@ -141,7 +141,7 @@ const Model: ModelType = {
if (!result) { if (!result) {
yield put({ yield put({
type: 'remixide/save', type: 'remixide/save',
payload: {errors: ['Compiler failed to test this file']}, payload: { errors: ['Compiler failed to test this file']},
}) })
} else { } else {
const success = result.totalFailing === 0 const success = result.totalFailing === 0
@ -149,7 +149,7 @@ const Model: ModelType = {
if (success) { if (success) {
yield put({ yield put({
type: 'remixide/save', type: 'remixide/save',
payload: {errors: [], success: true}, payload: { errors: [], success: true },
}) })
} else { } else {
yield put({ yield put({
@ -164,7 +164,7 @@ const Model: ModelType = {
console.log('TESTING ERROR', err) console.log('TESTING ERROR', err)
yield put({ yield put({
type: 'remixide/save', type: 'remixide/save',
payload: {errors: [String(err)]}, payload: { errors: [String(err)]},
}) })
} }
yield put({ yield put({
@ -174,7 +174,7 @@ const Model: ModelType = {
}, },
}) })
}, },
*showAnswer({payload: step}, {select, put}) { *showAnswer({ payload: step }, { select, put }) {
yield put({ yield put({
type: 'loading/save', type: 'loading/save',
payload: { payload: {
@ -189,7 +189,7 @@ const Model: ModelType = {
const content = step.answer.content const content = step.answer.content
let path = getFilePath(step.answer.file) let path = getFilePath(step.answer.file)
const {detail, selectedId} = yield select((state) => state.workshop) const { detail, selectedId } = yield select((state) => state.workshop)
const workshop = detail[selectedId] const workshop = detail[selectedId]
path = `.learneth/${workshop.name}/${step.name}/${path}` path = `.learneth/${workshop.name}/${step.name}/${path}`
@ -198,7 +198,7 @@ const Model: ModelType = {
} catch (err) { } catch (err) {
yield put({ yield put({
type: 'remixide/save', type: 'remixide/save',
payload: {errors: [String(err)]}, payload: { errors: [String(err)]},
}) })
} }
@ -210,7 +210,7 @@ const Model: ModelType = {
}, },
}) })
}, },
*testSolidityCompiler(_, {put, select}) { *testSolidityCompiler(_, { put, select }) {
try { try {
yield remixClient.call('solidity', 'getCompilationResult') yield remixClient.call('solidity', 'getCompilationResult')
} catch (err) { } catch (err) {

@ -1,10 +1,10 @@
import axios from 'axios' import axios from 'axios'
import {toast} from 'react-toastify' import { toast } from 'react-toastify'
import groupBy from 'lodash/groupBy' import groupBy from 'lodash/groupBy'
import pick from 'lodash/pick' import pick from 'lodash/pick'
import {type ModelType} from '../store' import { type ModelType } from '../store'
import remixClient from '../../remix-client' import remixClient from '../../remix-client'
import {router} from '../../App' import { router } from '../../App'
// const apiUrl = 'http://localhost:3001'; // const apiUrl = 'http://localhost:3001';
const apiUrl = 'https://static.220.14.12.49.clients.your-server.de:3000' const apiUrl = 'https://static.220.14.12.49.clients.your-server.de:3000'
@ -17,12 +17,12 @@ const Model: ModelType = {
selectedId: '', selectedId: '',
}, },
reducers: { reducers: {
save(state, {payload}) { save(state, { payload }) {
return {...state, ...payload} return { ...state, ...payload }
}, },
}, },
effects: { effects: {
*init(_, {put}) { *init(_, { put }) {
const cache = localStorage.getItem('workshop.state') const cache = localStorage.getItem('workshop.state')
if (cache) { if (cache) {
@ -41,7 +41,7 @@ const Model: ModelType = {
}) })
} }
}, },
*loadRepo({payload}, {put, select}) { *loadRepo({ payload }, { put, select }) {
toast.info(`loading ${payload.name}/${payload.branch}`) toast.info(`loading ${payload.name}/${payload.branch}`)
yield put({ yield put({
@ -51,18 +51,18 @@ const Model: ModelType = {
}, },
}) })
const {list, detail} = yield select((state) => state.workshop) const { list, detail } = yield select((state) => state.workshop)
const url = `${apiUrl}/clone/${encodeURIComponent(payload.name)}/${payload.branch}?${Math.random()}` const url = `${apiUrl}/clone/${encodeURIComponent(payload.name)}/${payload.branch}?${Math.random()}`
console.log('loading ', url) console.log('loading ', url)
const {data} = yield axios.get(url) const { data } = yield axios.get(url)
const repoId = `${payload.name}-${payload.branch}` const repoId = `${payload.name}-${payload.branch}`
for (let i = 0; i < data.ids.length; i++) { for (let i = 0; i < data.ids.length; i++) {
const { const {
steps, steps,
metadata: { metadata: {
data: {steps: metadataSteps}, data: { steps: metadataSteps },
}, },
} = data.entities[data.ids[i]] } = data.entities[data.ids[i]]
@ -130,8 +130,8 @@ const Model: ModelType = {
}) })
if (payload.id) { if (payload.id) {
const {detail, selectedId} = workshopState const { detail, selectedId } = workshopState
const {ids, entities} = detail[selectedId] const { ids, entities } = detail[selectedId]
for (let i = 0; i < ids.length; i++) { for (let i = 0; i < ids.length; i++) {
const entity = entities[ids[i]] const entity = entities[ids[i]]
if (entity.metadata.data.id === payload.id || i + 1 === payload.id) { if (entity.metadata.data.id === payload.id || i + 1 === payload.id) {
@ -141,7 +141,7 @@ const Model: ModelType = {
} }
} }
}, },
*resetAll(_, {put}) { *resetAll(_, { put }) {
yield put({ yield put({
type: 'workshop/save', type: 'workshop/save',
payload: { payload: {

@ -1,6 +1,6 @@
import {configureStore, createSlice, type PayloadAction, type Reducer} from '@reduxjs/toolkit' import { configureStore, createSlice, type PayloadAction, type Reducer } from '@reduxjs/toolkit'
import createSagaMiddleware from 'redux-saga' import createSagaMiddleware from 'redux-saga'
import {call, put, takeEvery, delay, select, all, fork, type ForkEffect} from 'redux-saga/effects' import { call, put, takeEvery, delay, select, all, fork, type ForkEffect } from 'redux-saga/effects'
// @ts-expect-error // @ts-expect-error
const context = require.context('./models', false, /\.ts$/) const context = require.context('./models', false, /\.ts$/)
@ -39,7 +39,7 @@ function createReducer(model: ModelType): Reducer {
} }
const rootReducer = models.reduce((prev: any, model: ModelType) => { const rootReducer = models.reduce((prev: any, model: ModelType) => {
return {...prev, [model.namespace]: createReducer(model)} return { ...prev, [model.namespace]: createReducer(model) }
}, {}) }, {})
function watchEffects(model: ModelType): ForkEffect { function watchEffects(model: ModelType): ForkEffect {

@ -1,7 +1,7 @@
import {PluginClient} from '@remixproject/plugin' import { PluginClient } from '@remixproject/plugin'
import {createClient} from '@remixproject/plugin-webview' import { createClient } from '@remixproject/plugin-webview'
import {store} from './redux/store' import { store } from './redux/store'
import {router} from './App' import { router } from './App'
class RemixClient extends PluginClient { class RemixClient extends PluginClient {
constructor() { constructor() {

Loading…
Cancel
Save