/* import * as R from "ramda"; import { configureStore, createSlice } from "@reduxjs/toolkit"; import { IIdentifier } from "@veramo/core"; import { Contact } from "../entity/contact"; import { Settings } from "../entity/settings"; import * as utility from "../utility/utility"; const MAX_LOG_LENGTH = 2000000; export const DEFAULT_ENDORSER_API_SERVER = "https://endorser.ch:3000"; export const DEFAULT_ENDORSER_VIEW_SERVER = "https://endorser.ch"; export const LOCAL_ENDORSER_API_SERVER = "http://127.0.0.1:3000"; export const LOCAL_ENDORSER_VIEW_SERVER = "http://127.0.0.1:3001"; export const TEST_ENDORSER_API_SERVER = "https://test.endorser.ch:8000"; export const TEST_ENDORSER_VIEW_SERVER = "https://test.endorser.ch:8080"; // for contents set in reducers interface Payload { type: string; payload: T; } interface LogMsg { log: boolean; msg: string; } export const appSlice = createSlice({ name: "app", initialState: { // This is nullable because it is cached state from the DB... // it'll be null if we haven't even loaded from the DB yet. settings: null as Settings, // This is nullable because it is cached state from the DB... // it'll be null if we haven't even loaded from the DB yet. identifiers: null as Array | null, // This is nullable because it is cached state from the DB... // it'll be null if we haven't even loaded from the DB yet. contacts: null as Array | null, viewServer: DEFAULT_ENDORSER_VIEW_SERVER, logMessage: "", advancedMode: false, testMode: false, }, reducers: { addIdentifier: (state, contents: Payload) => { state.identifiers = state.identifiers.concat([contents.payload]); }, addLog: (state, contents: Payload) => { if (state.logMessage.length > MAX_LOG_LENGTH) { state.logMessage = "\n..." + state.logMessage.substring( state.logMessage.length - MAX_LOG_LENGTH / 2 ); } if (contents.payload.log) { console.log(contents.payload.msg); state.logMessage += "\n" + contents.payload.msg; } }, setAdvancedMode: (state, contents: Payload) => { state.advancedMode = contents.payload; }, setContacts: (state, contents: Payload>) => { state.contacts = contents.payload; }, setContact: (state, contents: Payload) => { const index = R.findIndex( (c) => c.did === contents.payload.did, state.contacts ); state.contacts[index] = contents.payload; }, setHomeScreen: (state, contents: Payload) => { state.settings.homeScreen = contents.payload; }, setIdentifiers: (state, contents: Payload>) => { state.identifiers = contents.payload; }, setSettings: (state, contents: Payload) => { state.settings = contents.payload; }, setTestMode: (state, contents: Payload) => { state.testMode = contents.payload; }, setViewServer: (state, contents: Payload) => { state.viewServer = contents.payload; }, }, }); export const appStore = configureStore({ reducer: appSlice.reducer }); */