mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-12 22:46:58 +03:00
refactor: reorganize services
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { TabServiceInstance } from './tab.service';
|
||||
import { store } from '../../store';
|
||||
import { store } from './store.service';
|
||||
|
||||
export function coreService() {
|
||||
TabServiceInstance.onChange((activeId, tabs) => {
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
export * from './tab.service';
|
||||
export * from './core.service';
|
||||
export * from './socket.service';
|
||||
export * from './store.service';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Podkop } from './podkop/types';
|
||||
import { initialDiagnosticStore } from './podkop/tabs/diagnostic/diagnostic.store';
|
||||
import { Podkop } from '../types';
|
||||
import { initialDiagnosticStore } from '../tabs/diagnostic/diagnostic.store';
|
||||
|
||||
function jsonStableStringify<T, V>(obj: T): string {
|
||||
return JSON.stringify(obj, (_, value) => {
|
||||
@@ -29,7 +29,7 @@ function jsonEqual<A, B>(a: A, b: B): boolean {
|
||||
type Listener<T> = (next: T, prev: T, diff: Partial<T>) => void;
|
||||
|
||||
// eslint-disable-next-line
|
||||
class Store<T extends Record<string, any>> {
|
||||
class StoreService<T extends Record<string, any>> {
|
||||
private value: T;
|
||||
private readonly initial: T;
|
||||
private listeners = new Set<Listener<T>>();
|
||||
@@ -207,4 +207,4 @@ const initialStore: StoreType = {
|
||||
...initialDiagnosticStore,
|
||||
};
|
||||
|
||||
export const store = new Store<StoreType>(initialStore);
|
||||
export const store = new StoreService<StoreType>(initialStore);
|
||||
@@ -4,8 +4,6 @@ import {
|
||||
onMount,
|
||||
preserveScrollForPage,
|
||||
} from '../../../helpers';
|
||||
import { store, StoreType } from '../../../store';
|
||||
import { socket } from '../../../socket';
|
||||
import { prettyBytes } from '../../../helpers/prettyBytes';
|
||||
import { renderSections } from './renderSections';
|
||||
import { renderWidget } from './renderWidget';
|
||||
@@ -14,6 +12,7 @@ import {
|
||||
CustomPodkopMethods,
|
||||
PodkopShellMethods,
|
||||
} from '../../methods';
|
||||
import { socket, store, StoreType } from '../../services';
|
||||
|
||||
// Fetchers
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
|
||||
import { insertIf } from '../../../../helpers';
|
||||
import { IDiagnosticsChecksItem } from '../../../../store';
|
||||
import { DIAGNOSTICS_CHECKS_MAP } from './contstants';
|
||||
import { PodkopShellMethods } from '../../../methods';
|
||||
import { IDiagnosticsChecksItem } from '../../../services';
|
||||
|
||||
export async function runDnsCheck() {
|
||||
const { order, title, code } = DIAGNOSTICS_CHECKS_MAP.DNS;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
|
||||
import { insertIf } from '../../../../helpers';
|
||||
import { IDiagnosticsChecksItem } from '../../../../store';
|
||||
import { DIAGNOSTICS_CHECKS_MAP } from './contstants';
|
||||
import { PodkopShellMethods, RemoteFakeIPMethods } from '../../../methods';
|
||||
import { IDiagnosticsChecksItem } from '../../../services';
|
||||
|
||||
export async function runFakeIPCheck() {
|
||||
const { order, title, code } = DIAGNOSTICS_CHECKS_MAP.FAKEIP;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
|
||||
import { DIAGNOSTICS_CHECKS_MAP } from './contstants';
|
||||
import { RemoteFakeIPMethods } from '../../../methods/fakeip';
|
||||
import { PodkopShellMethods } from '../../../methods';
|
||||
import { RemoteFakeIPMethods, PodkopShellMethods } from '../../../methods';
|
||||
|
||||
export async function runNftCheck() {
|
||||
const { order, title, code } = DIAGNOSTICS_CHECKS_MAP.NFT;
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
DIAGNOSTICS_CHECKS,
|
||||
DIAGNOSTICS_CHECKS_MAP,
|
||||
} from './checks/contstants';
|
||||
import { StoreType } from '../../../store';
|
||||
import { StoreType } from '../../services';
|
||||
|
||||
export const initialDiagnosticStore: Pick<
|
||||
StoreType,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { onMount, preserveScrollForPage } from '../../../helpers';
|
||||
import { store, StoreType } from '../../../store';
|
||||
import { renderCheckSection } from './renderCheckSection';
|
||||
import { runDnsCheck } from './checks/runDnsCheck';
|
||||
import { runSingBoxCheck } from './checks/runSingBoxCheck';
|
||||
@@ -9,6 +8,7 @@ import { renderDiagnosticRunAction } from './renderDiagnosticRunAction';
|
||||
import { renderAvailableActions } from './renderAvailableActions';
|
||||
import { renderSystemInfo } from './renderSystemInfo';
|
||||
import { loadingDiagnosticsChecksStore } from './diagnostic.store';
|
||||
import { store, StoreType } from '../../services';
|
||||
|
||||
function renderDiagnosticsChecks() {
|
||||
console.log('renderDiagnosticsChecks');
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
renderTriangleAlertIcon24,
|
||||
renderXIcon24,
|
||||
} from '../../../icons';
|
||||
import { IDiagnosticsChecksStoreItem } from '../../../store';
|
||||
import { IDiagnosticsChecksStoreItem } from '../../services';
|
||||
|
||||
type IRenderCheckSectionProps = IDiagnosticsChecksStoreItem;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IDiagnosticsChecksStoreItem, store } from '../../../store';
|
||||
import { IDiagnosticsChecksStoreItem, store } from '../../services';
|
||||
|
||||
export function updateDiagnosticsCheck(
|
||||
check: IDiagnosticsChecksStoreItem,
|
||||
|
||||
Reference in New Issue
Block a user