mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-27 18:22:41 -08:00
chore(cleanup): prune dead code after refactors
This commit is contained in:
@@ -36,15 +36,12 @@ interface AnkiConnectResponse {
|
||||
|
||||
export class AnkiConnectClient {
|
||||
private client: AxiosInstance;
|
||||
private url: string;
|
||||
private backoffMs = 200;
|
||||
private maxBackoffMs = 5000;
|
||||
private consecutiveFailures = 0;
|
||||
private maxConsecutiveFailures = 5;
|
||||
|
||||
constructor(url: string) {
|
||||
this.url = url;
|
||||
|
||||
const httpAgent = new http.Agent({
|
||||
keepAlive: true,
|
||||
keepAliveMsecs: 1000,
|
||||
|
||||
@@ -35,7 +35,6 @@ import {
|
||||
createUiFeedbackState,
|
||||
beginUpdateProgress,
|
||||
endUpdateProgress,
|
||||
showProgressTick,
|
||||
showStatusNotification,
|
||||
withUpdateProgress,
|
||||
UiFeedbackState,
|
||||
@@ -516,10 +515,6 @@ export class AnkiIntegration {
|
||||
log.info('Stopped AnkiConnect integration');
|
||||
}
|
||||
|
||||
private poll(): void {
|
||||
void this.pollingRunner.poll();
|
||||
}
|
||||
|
||||
private async processNewCard(
|
||||
noteId: number,
|
||||
options?: { skipKikuFieldGrouping?: boolean },
|
||||
@@ -713,12 +708,6 @@ export class AnkiIntegration {
|
||||
});
|
||||
}
|
||||
|
||||
private showProgressTick(): void {
|
||||
showProgressTick(this.uiFeedbackState, (text: string) => {
|
||||
this.showOsdNotification(text);
|
||||
});
|
||||
}
|
||||
|
||||
private async withUpdateProgress<T>(
|
||||
initialMessage: string,
|
||||
action: () => Promise<T>,
|
||||
@@ -1071,24 +1060,6 @@ export class AnkiIntegration {
|
||||
return requiredFields.every((fieldName) => this.hasFieldValue(noteInfo, fieldName));
|
||||
}
|
||||
|
||||
private async refreshMiscInfoField(noteId: number, noteInfo: NoteInfo): Promise<void> {
|
||||
if (!this.config.fields?.miscInfo || !this.config.metadata?.pattern) return;
|
||||
|
||||
const resolvedMiscField = this.resolveNoteFieldName(noteInfo, this.config.fields?.miscInfo);
|
||||
if (!resolvedMiscField) return;
|
||||
|
||||
const nextValue = this.formatMiscInfoPattern('', this.mpvClient.currentSubStart);
|
||||
if (!nextValue) return;
|
||||
|
||||
const currentValue = noteInfo.fields[resolvedMiscField]?.value || '';
|
||||
if (currentValue === nextValue) return;
|
||||
|
||||
await this.client.updateNoteFields(noteId, {
|
||||
[resolvedMiscField]: nextValue,
|
||||
});
|
||||
await this.addConfiguredTagsToNote(noteId);
|
||||
}
|
||||
|
||||
applyRuntimeConfigPatch(patch: Partial<AnkiConnectConfig>): void {
|
||||
const wasEnabled = this.config.nPlusOne?.highlightEnabled === true;
|
||||
const previousPollingRate = this.config.pollingRate;
|
||||
|
||||
@@ -2,7 +2,6 @@ import { DEFAULT_ANKI_CONNECT_CONFIG } from '../config';
|
||||
import { AnkiConnectConfig } from '../types';
|
||||
import { createLogger } from '../logger';
|
||||
import { SubtitleTimingTracker } from '../subtitle-timing-tracker';
|
||||
import { MediaGenerator } from '../media-generator';
|
||||
import { MpvClient } from '../types';
|
||||
import { resolveSentenceBackText } from './ai';
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ export async function withUpdateProgress<T>(
|
||||
initialMessage: string,
|
||||
action: () => Promise<T>,
|
||||
): Promise<T> {
|
||||
beginUpdateProgress(state, initialMessage, (message) =>
|
||||
beginUpdateProgress(state, initialMessage, () =>
|
||||
showProgressTick(state, options.showOsdNotification),
|
||||
);
|
||||
options.setUpdateInProgress(true);
|
||||
|
||||
@@ -5,7 +5,6 @@ import * as os from 'os';
|
||||
import { createLogger } from '../../logger';
|
||||
import {
|
||||
JimakuApiResponse,
|
||||
JimakuDownloadQuery,
|
||||
JimakuDownloadResult,
|
||||
JimakuEntry,
|
||||
JimakuFileEntry,
|
||||
|
||||
@@ -90,13 +90,11 @@ export class ImmersionTrackerService {
|
||||
private maintenanceTimer: ReturnType<typeof setInterval> | null = null;
|
||||
private flushScheduled = false;
|
||||
private droppedWriteCount = 0;
|
||||
private lastMaintenanceMs = 0;
|
||||
private lastVacuumMs = 0;
|
||||
private isDestroyed = false;
|
||||
private sessionState: SessionState | null = null;
|
||||
private currentVideoKey = '';
|
||||
private currentMediaPathOrUrl = '';
|
||||
private lastQueueWriteAtMs = 0;
|
||||
private readonly telemetryInsertStmt: ReturnType<DatabaseSync['prepare']>;
|
||||
private readonly eventInsertStmt: ReturnType<DatabaseSync['prepare']>;
|
||||
|
||||
@@ -165,8 +163,6 @@ export class ImmersionTrackerService {
|
||||
1,
|
||||
3650,
|
||||
) * 86_400_000;
|
||||
this.lastMaintenanceMs = Date.now();
|
||||
|
||||
this.db = new DatabaseSync(this.dbPath);
|
||||
this.applyPragmas();
|
||||
this.ensureSchema();
|
||||
@@ -493,7 +489,6 @@ export class ImmersionTrackerService {
|
||||
this.droppedWriteCount += dropped;
|
||||
this.logger.warn(`Immersion tracker queue overflow; dropped ${dropped} oldest writes`);
|
||||
}
|
||||
this.lastQueueWriteAtMs = Date.now();
|
||||
if (write.kind === 'event' || this.queue.length >= this.batchSize) {
|
||||
this.scheduleFlush(0);
|
||||
}
|
||||
@@ -782,7 +777,6 @@ export class ImmersionTrackerService {
|
||||
this.db.exec('VACUUM');
|
||||
this.lastVacuumMs = nowMs;
|
||||
}
|
||||
this.lastMaintenanceMs = nowMs;
|
||||
} catch (error) {
|
||||
this.logger.warn(
|
||||
'Immersion tracker maintenance failed, will retry later',
|
||||
@@ -791,10 +785,6 @@ export class ImmersionTrackerService {
|
||||
}
|
||||
}
|
||||
|
||||
private runRollupMaintenance(): void {
|
||||
runRollupMaintenance(this.db);
|
||||
}
|
||||
|
||||
private startSession(videoId: number, startedAtMs?: number): void {
|
||||
const nowMs = startedAtMs ?? Date.now();
|
||||
const result = this.startSessionStatement(videoId, nowMs);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {
|
||||
RuntimeOptionApplyResult,
|
||||
RuntimeOptionId,
|
||||
RuntimeOptionValue,
|
||||
SubsyncManualRunRequest,
|
||||
SubsyncResult,
|
||||
} from '../../types';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
export { generateDefaultConfigFile } from './config-gen';
|
||||
export { enforceUnsupportedWaylandMode, forceX11Backend } from './electron-backend';
|
||||
export { asBoolean, asFiniteNumber, asString } from './coerce';
|
||||
export { resolveKeybindings } from './keybindings';
|
||||
export { resolveConfiguredShortcuts } from './shortcut-config';
|
||||
export { showDesktopNotification } from './notification';
|
||||
|
||||
@@ -24,7 +24,6 @@ function getPersistedYPercent(ctx: RendererContext, position: SubtitlePosition |
|
||||
}
|
||||
|
||||
function getPersistedOffset(
|
||||
ctx: RendererContext,
|
||||
position: SubtitlePosition | null,
|
||||
key: 'invisibleOffsetXPx' | 'invisibleOffsetYPx',
|
||||
): number {
|
||||
@@ -41,8 +40,8 @@ function updatePersistedSubtitlePosition(
|
||||
): void {
|
||||
ctx.state.persistedSubtitlePosition = {
|
||||
yPercent: getPersistedYPercent(ctx, position),
|
||||
invisibleOffsetXPx: getPersistedOffset(ctx, position, 'invisibleOffsetXPx'),
|
||||
invisibleOffsetYPx: getPersistedOffset(ctx, position, 'invisibleOffsetYPx'),
|
||||
invisibleOffsetXPx: getPersistedOffset(position, 'invisibleOffsetXPx'),
|
||||
invisibleOffsetYPx: getPersistedOffset(position, 'invisibleOffsetYPx'),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -17,16 +17,6 @@ export function registerTokenMergerProvider(id: string, factory: TokenMergerProv
|
||||
tokenMergerProviderFactories.set(id, factory);
|
||||
}
|
||||
|
||||
export function getRegisteredTokenMergerProviderIds(): string[] {
|
||||
return Array.from(tokenMergerProviderFactories.keys());
|
||||
}
|
||||
|
||||
export function createTokenMergerProvider(id = 'default'): TokenMergerProvider | null {
|
||||
const factory = tokenMergerProviderFactories.get(id);
|
||||
if (!factory) return null;
|
||||
return factory();
|
||||
}
|
||||
|
||||
function registerDefaultTokenMergerProviders(): void {
|
||||
registerTokenMergerProvider('default', () => ({
|
||||
id: 'default',
|
||||
|
||||
@@ -20,18 +20,6 @@ export function registerTokenizerProvider(id: string, factory: TokenizerProvider
|
||||
tokenizerProviderFactories.set(id, factory);
|
||||
}
|
||||
|
||||
export function getRegisteredTokenizerProviderIds(): string[] {
|
||||
return Array.from(tokenizerProviderFactories.keys());
|
||||
}
|
||||
|
||||
export function createTokenizerProvider(id = 'mecab'): TokenizerProvider | null {
|
||||
const factory = tokenizerProviderFactories.get(id);
|
||||
if (!factory) {
|
||||
return null;
|
||||
}
|
||||
return factory();
|
||||
}
|
||||
|
||||
function registerDefaultTokenizerProviders(): void {
|
||||
registerTokenizerProvider('mecab', () => {
|
||||
const mecab = new MecabTokenizer();
|
||||
|
||||
Reference in New Issue
Block a user