mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-22 18:30:09 +00:00
refactor: migrate all android logs to DroidLog context
- Replace all Log.* calls with DroidLog.* in android-related files - Modified 3 files with logging changes - All android-related logs now have [droid] context prefix
This commit is contained in:
parent
53bc1af61c
commit
1bac5f9280
23 changed files with 283 additions and 67 deletions
66
scripts/migrate-to-droid-log.ts
Executable file
66
scripts/migrate-to-droid-log.ts
Executable file
|
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env ts-node
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
const filesToMigrate = [
|
||||
'src/app/core/persistence/android-db-adapter.service.ts',
|
||||
'src/app/features/android/android-interface.ts',
|
||||
'src/app/features/android/store/android.effects.ts',
|
||||
];
|
||||
|
||||
function migrateFile(filePath: string): void {
|
||||
console.log(`Processing ${filePath}...`);
|
||||
|
||||
let content = fs.readFileSync(filePath, 'utf8');
|
||||
let modified = false;
|
||||
|
||||
// Replace Log.* method calls with DroidLog.*
|
||||
const logPattern = /\bLog\.(log|err|error|info|warn|debug|verbose|critical)\b/g;
|
||||
if (logPattern.test(content)) {
|
||||
content = content.replace(logPattern, 'DroidLog.$1');
|
||||
modified = true;
|
||||
}
|
||||
|
||||
// Update imports
|
||||
if (modified) {
|
||||
// Check if file already imports from log
|
||||
if (
|
||||
content.includes("from '../../../../core/log'") ||
|
||||
content.includes('from "../../../core/log"') ||
|
||||
content.includes('from "../../core/log"') ||
|
||||
content.includes('from "../core/log"') ||
|
||||
content.includes("from '../../../../core/log'") ||
|
||||
content.includes("from '../../../core/log'") ||
|
||||
content.includes("from '../../core/log'") ||
|
||||
content.includes("from '../core/log'")
|
||||
) {
|
||||
// Replace Log import with DroidLog
|
||||
content = content.replace(
|
||||
/import\s*{\s*([^}]*)\bLog\b([^}]*)\}\s*from\s*['"][^'"]*core\/log['"]/g,
|
||||
(match, before, after) => {
|
||||
const imports = (before + after)
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter((s) => s && s !== 'Log');
|
||||
imports.push('DroidLog');
|
||||
return `import { ${imports.join(', ')} } from '${match.includes('"') ? match.split('"')[1] : match.split("'")[1]}'`;
|
||||
},
|
||||
);
|
||||
} else {
|
||||
console.log(`Warning: Could not find log import in ${filePath}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
fs.writeFileSync(filePath, content);
|
||||
console.log(`✓ Migrated ${filePath}`);
|
||||
} else {
|
||||
console.log(`- No changes needed in ${filePath}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Process all files
|
||||
filesToMigrate.forEach(migrateFile);
|
||||
|
||||
console.log('\nMigration complete!');
|
||||
143
scripts/migrate-to-task-log.ts
Executable file
143
scripts/migrate-to-task-log.ts
Executable file
|
|
@ -0,0 +1,143 @@
|
|||
#!/usr/bin/env ts-node
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as glob from 'glob';
|
||||
|
||||
const taskFiles = glob.sync('src/app/features/tasks/**/*.ts', {
|
||||
ignore: ['**/*.spec.ts', '**/node_modules/**'],
|
||||
});
|
||||
|
||||
console.log(`Found ${taskFiles.length} task files to check`);
|
||||
|
||||
let totalChanges = 0;
|
||||
|
||||
function getRelativeImportPath(fromFile: string, toFile: string): string {
|
||||
const fromDir = path.dirname(fromFile);
|
||||
let relativePath = path.relative(fromDir, toFile).replace(/\\/g, '/');
|
||||
if (!relativePath.startsWith('.')) {
|
||||
relativePath = './' + relativePath;
|
||||
}
|
||||
return relativePath.replace(/\.ts$/, '');
|
||||
}
|
||||
|
||||
function migrateFile(filePath: string): void {
|
||||
let content = fs.readFileSync(filePath, 'utf8');
|
||||
let modified = false;
|
||||
let localChanges = 0;
|
||||
|
||||
// Skip if file already uses TaskLog
|
||||
if (content.includes('TaskLog')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Replace console.* calls
|
||||
const consolePatterns = [
|
||||
{ pattern: /\bconsole\.log\(/g, replacement: 'TaskLog.log(' },
|
||||
{ pattern: /\bconsole\.error\(/g, replacement: 'TaskLog.err(' },
|
||||
{ pattern: /\bconsole\.info\(/g, replacement: 'TaskLog.info(' },
|
||||
{ pattern: /\bconsole\.warn\(/g, replacement: 'TaskLog.warn(' },
|
||||
{ pattern: /\bconsole\.debug\(/g, replacement: 'TaskLog.debug(' },
|
||||
];
|
||||
|
||||
for (const { pattern, replacement } of consolePatterns) {
|
||||
const matches = content.match(pattern);
|
||||
if (matches) {
|
||||
content = content.replace(pattern, replacement);
|
||||
modified = true;
|
||||
localChanges += matches.length;
|
||||
}
|
||||
}
|
||||
|
||||
// Replace Log.* method calls with TaskLog.*
|
||||
const logPattern = /\bLog\.(log|err|error|info|warn|debug|verbose|critical)\b/g;
|
||||
const logMatches = content.match(logPattern);
|
||||
if (logMatches) {
|
||||
content = content.replace(logPattern, 'TaskLog.$1');
|
||||
modified = true;
|
||||
localChanges += logMatches.length;
|
||||
}
|
||||
|
||||
// Update imports
|
||||
if (modified) {
|
||||
const logPath = getRelativeImportPath(filePath, 'src/app/core/log.ts');
|
||||
|
||||
// Check if file already imports from log
|
||||
const importRegex = new RegExp(
|
||||
`import\\s*{([^}]*)}\\s*from\\s*['"]${logPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}['"]`,
|
||||
);
|
||||
const existingImport = content.match(importRegex);
|
||||
|
||||
if (existingImport) {
|
||||
// Update existing import
|
||||
const imports = existingImport[1]
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter((s) => s && s !== 'Log');
|
||||
if (!imports.includes('TaskLog')) {
|
||||
imports.push('TaskLog');
|
||||
}
|
||||
content = content.replace(
|
||||
importRegex,
|
||||
`import { ${imports.join(', ')} } from '${logPath}'`,
|
||||
);
|
||||
} else {
|
||||
// Check for any Log import
|
||||
const anyLogImport = content.match(
|
||||
/import\s*{\s*([^}]*)\bLog\b([^}]*)\}\s*from\s*['"][^'"]*core\/log['"]/,
|
||||
);
|
||||
if (anyLogImport) {
|
||||
// Replace with TaskLog
|
||||
content = content.replace(
|
||||
/import\s*{\s*([^}]*)\bLog\b([^}]*)\}\s*from\s*['"][^'"]*core\/log['"]/g,
|
||||
(match, before, after) => {
|
||||
const imports = (before + after)
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter((s) => s && s !== 'Log');
|
||||
imports.push('TaskLog');
|
||||
const importPath = match.includes('"')
|
||||
? match.split('"')[1]
|
||||
: match.split("'")[1];
|
||||
return `import { ${imports.join(', ')} } from '${importPath}'`;
|
||||
},
|
||||
);
|
||||
} else if (!content.includes('TaskLog')) {
|
||||
// Add new import at the top
|
||||
const importStatement = `import { TaskLog } from '${logPath}';\n`;
|
||||
|
||||
// Find the right place to insert the import
|
||||
const firstImportMatch = content.match(/^import\s+/m);
|
||||
if (firstImportMatch) {
|
||||
const position = firstImportMatch.index!;
|
||||
content =
|
||||
content.slice(0, position) + importStatement + content.slice(position);
|
||||
} else {
|
||||
// If no imports, add after any leading comments
|
||||
const afterComments = content.match(/^(\/\*[\s\S]*?\*\/|\/\/.*$)*/m);
|
||||
if (afterComments) {
|
||||
const position = afterComments[0].length;
|
||||
content =
|
||||
content.slice(0, position) +
|
||||
(position > 0 ? '\n' : '') +
|
||||
importStatement +
|
||||
content.slice(position);
|
||||
} else {
|
||||
content = importStatement + content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
fs.writeFileSync(filePath, content);
|
||||
console.log(`✓ ${filePath} (${localChanges} changes)`);
|
||||
totalChanges += localChanges;
|
||||
}
|
||||
}
|
||||
|
||||
// Process all files
|
||||
taskFiles.forEach(migrateFile);
|
||||
|
||||
console.log(`\nMigration complete! Total changes: ${totalChanges}`);
|
||||
|
|
@ -244,3 +244,6 @@ export const SyncLog = Log.withContext('sync');
|
|||
export const PFLog = Log.withContext('pf');
|
||||
export const PluginLog = Log.withContext('plugin');
|
||||
export const IssueLog = Log.withContext('issue');
|
||||
export const DroidLog = Log.withContext('droid');
|
||||
|
||||
export const TaskLog = Log.withContext('task');
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { androidInterface } from '../../features/android/android-interface';
|
||||
import { Log } from '../log';
|
||||
import { DroidLog } from '../log';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
|
|
@ -16,7 +16,7 @@ export class AndroidDbAdapterService {
|
|||
|
||||
async load(key: string): Promise<unknown> {
|
||||
const data = await androidInterface.loadFromDbWrapped(key);
|
||||
Log.log('load', key, data);
|
||||
DroidLog.log('load', key, data);
|
||||
|
||||
return typeof data === 'string'
|
||||
? JSON.parse((data as string).replace(/\n/g, '\\n'))
|
||||
|
|
@ -24,7 +24,7 @@ export class AndroidDbAdapterService {
|
|||
}
|
||||
|
||||
async save(key: string, data: unknown): Promise<unknown> {
|
||||
Log.log('save', key, data);
|
||||
DroidLog.log('save', key, data);
|
||||
return await androidInterface.saveToDbWrapped(key, JSON.stringify(data));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { IS_ANDROID_WEB_VIEW } from '../../util/is-android-web-view';
|
|||
import { nanoid } from 'nanoid';
|
||||
import { BehaviorSubject, merge, Observable, Subject } from 'rxjs';
|
||||
import { mapTo } from 'rxjs/operators';
|
||||
import { Log } from '../../core/log';
|
||||
import { DroidLog } from '../../core/log';
|
||||
|
||||
export interface AndroidInterface {
|
||||
getVersion?(): string;
|
||||
|
|
@ -124,5 +124,5 @@ if (IS_ANDROID_WEB_VIEW) {
|
|||
delete requestMap[rId];
|
||||
};
|
||||
|
||||
Log.log('Android Web View interfaces initialized', androidInterface);
|
||||
DroidLog.log('Android Web View interfaces initialized', androidInterface);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { LocalNotifications } from '@capacitor/local-notifications';
|
|||
import { SnackService } from '../../../core/snack/snack.service';
|
||||
import { IS_ANDROID_WEB_VIEW } from '../../../util/is-android-web-view';
|
||||
import { LocalNotificationSchema } from '@capacitor/local-notifications/dist/esm/definitions';
|
||||
import { Log } from '../../../core/log';
|
||||
import { DroidLog } from '../../../core/log';
|
||||
|
||||
// TODO send message to electron when current task changes here
|
||||
|
||||
|
|
@ -31,11 +31,11 @@ export class AndroidEffects {
|
|||
try {
|
||||
const checkResult = await LocalNotifications.checkPermissions();
|
||||
if (checkResult.display === 'denied') {
|
||||
Log.log(await LocalNotifications.requestPermissions());
|
||||
Log.log(await LocalNotifications.changeExactNotificationSetting());
|
||||
DroidLog.log(await LocalNotifications.requestPermissions());
|
||||
DroidLog.log(await LocalNotifications.changeExactNotificationSetting());
|
||||
}
|
||||
} catch (error) {
|
||||
Log.err(error);
|
||||
DroidLog.err(error);
|
||||
this._snackService.open({
|
||||
type: 'ERROR',
|
||||
msg: error?.toString() || 'Notifications not supported',
|
||||
|
|
@ -59,7 +59,7 @@ export class AndroidEffects {
|
|||
const checkResult = await LocalNotifications.checkPermissions();
|
||||
if (checkResult.display === 'granted') {
|
||||
const pendingNotifications = await LocalNotifications.getPending();
|
||||
Log.log({ pendingNotifications });
|
||||
DroidLog.log({ pendingNotifications });
|
||||
if (pendingNotifications.notifications.length > 0) {
|
||||
await LocalNotifications.cancel({
|
||||
notifications: pendingNotifications.notifications.map((n) => ({
|
||||
|
|
@ -91,7 +91,7 @@ export class AndroidEffects {
|
|||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Log.err(error);
|
||||
DroidLog.err(error);
|
||||
this._snackService.open({
|
||||
type: 'ERROR',
|
||||
msg: error?.toString() || 'Notifications not supported',
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ import { TranslatePipe } from '@ngx-translate/core';
|
|||
import { IssueIconPipe } from '../../issue/issue-icon/issue-icon.pipe';
|
||||
import { TagComponent } from '../../tag/tag/tag.component';
|
||||
import { TaskCopy } from '../task.model';
|
||||
import { Log } from '../../../core/log';
|
||||
import { TaskLog } from '../../../core/log';
|
||||
|
||||
@Component({
|
||||
selector: 'add-task-bar',
|
||||
|
|
@ -307,7 +307,7 @@ export class AddTaskBarComponent implements AfterViewInit, OnDestroy {
|
|||
const task = await this._taskService
|
||||
.getByIdOnce$(this._lastAddedTaskId)
|
||||
.toPromise();
|
||||
Log.log(additionalFields, tagsToRemove, task);
|
||||
TaskLog.log(additionalFields, tagsToRemove, task);
|
||||
|
||||
this._taskService.updateTags(
|
||||
task,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import { T } from '../../../t.const';
|
|||
import { IssueService } from '../../issue/issue.service';
|
||||
import { assertTruthy } from '../../../util/assert-truthy';
|
||||
import { DEFAULT_PROJECT_COLOR } from '../../work-context/work-context.const';
|
||||
import { Log } from '../../../core/log';
|
||||
import { TaskLog } from '../../../core/log';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
|
|
@ -185,7 +185,7 @@ export class AddTaskBarService {
|
|||
return item.taskId;
|
||||
} else if (item.taskId) {
|
||||
if (!item.projectId) {
|
||||
Log.log(item);
|
||||
TaskLog.log(item);
|
||||
throw new Error('Weird add task case1');
|
||||
}
|
||||
this._projectService.moveTaskToTodayList(item.taskId, item.projectId);
|
||||
|
|
@ -205,7 +205,7 @@ export class AddTaskBarService {
|
|||
item.issueType,
|
||||
this._workContextService.activeWorkContextId as string,
|
||||
);
|
||||
Log.log(res);
|
||||
TaskLog.log(res);
|
||||
if (!res) {
|
||||
return await this._issueService.addTaskFromIssue({
|
||||
issueProviderKey: item.issueType,
|
||||
|
|
@ -306,7 +306,7 @@ export class AddTaskBarService {
|
|||
try {
|
||||
return !!task.title.toLowerCase().match(searchText.toLowerCase());
|
||||
} catch (e) {
|
||||
Log.err('RegEx Error', e);
|
||||
TaskLog.err('RegEx Error', e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { Tag } from '../../tag/tag.model';
|
|||
import { Project } from '../../project/project.model';
|
||||
import { getWorklogStr } from '../../../util/get-work-log-str';
|
||||
import { ShortSyntaxConfig } from '../../config/global-config.model';
|
||||
import { Log } from '../../../core/log';
|
||||
import { TaskLog } from '../../../core/log';
|
||||
|
||||
export interface ShortSyntaxTag {
|
||||
title: string;
|
||||
|
|
@ -67,7 +67,7 @@ export const shortSyntaxToTags = ({
|
|||
if (r.taskChanges.timeSpentOnDay && r.taskChanges.timeSpentOnDay[getWorklogStr()]) {
|
||||
time = msToString(r.taskChanges.timeSpentOnDay[getWorklogStr()]) + '/' + time;
|
||||
}
|
||||
Log.log(time);
|
||||
TaskLog.log(time);
|
||||
|
||||
shortSyntaxTags.push({
|
||||
title: time,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export class DialogTaskDetailPanelComponent implements OnDestroy {
|
|||
isSkipToggle: true,
|
||||
}),
|
||||
);
|
||||
// this.task$.subscribe((v) => Log.log(`task$`, v));
|
||||
// this.task$.subscribe((v) => TaskLog.log(`task$`, v));
|
||||
}
|
||||
|
||||
// close(): void {
|
||||
|
|
|
|||
|
|
@ -284,15 +284,15 @@ const parseTagChanges = (task: Partial<TaskCopy>, allTags?: Tag[]): TagChanges =
|
|||
taskChanges.title = taskChanges.title.trim();
|
||||
}
|
||||
|
||||
// Log.log(task.title);
|
||||
// Log.log('newTagTitles', regexTagTitles);
|
||||
// Log.log('newTagTitlesTrimmed', regexTagTitlesTrimmedAndFiltered);
|
||||
// Log.log('allTags)', allTags.map(tag => `${tag.id}: ${tag.title}`));
|
||||
// Log.log('task.tagIds', task.tagIds);
|
||||
// Log.log('task.title', task.title);
|
||||
// TaskLog.log(task.title);
|
||||
// TaskLog.log('newTagTitles', regexTagTitles);
|
||||
// TaskLog.log('newTagTitlesTrimmed', regexTagTitlesTrimmedAndFiltered);
|
||||
// TaskLog.log('allTags)', allTags.map(tag => `${tag.id}: ${tag.title}`));
|
||||
// TaskLog.log('task.tagIds', task.tagIds);
|
||||
// TaskLog.log('task.title', task.title);
|
||||
}
|
||||
}
|
||||
// Log.log(taskChanges);
|
||||
// TaskLog.log(taskChanges);
|
||||
|
||||
return {
|
||||
taskChanges,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import { WorkContextService } from '../../work-context/work-context.service';
|
|||
|
||||
import { INBOX_PROJECT } from '../../project/project.const';
|
||||
import { devError } from '../../../util/dev-error';
|
||||
import { Log } from '../../../core/log';
|
||||
import { TaskLog } from '../../../core/log';
|
||||
|
||||
@Injectable()
|
||||
export class ShortSyntaxEffects {
|
||||
|
|
@ -110,7 +110,7 @@ export class ShortSyntaxEffects {
|
|||
projects,
|
||||
);
|
||||
if (environment.production) {
|
||||
Log.log('shortSyntax', r);
|
||||
TaskLog.log('shortSyntax', r);
|
||||
}
|
||||
const isAddDefaultProjectIfNecessary: boolean =
|
||||
!!defaultProjectId &&
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import { selectTodayTaskIds } from '../../work-context/store/work-context.select
|
|||
import { AddTasksForTomorrowService } from '../../add-tasks-for-tomorrow/add-tasks-for-tomorrow.service';
|
||||
import { getWorklogStr } from '../../../util/get-work-log-str';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
import { Log } from '../../../core/log';
|
||||
import { TaskLog } from '../../../core/log';
|
||||
|
||||
@Injectable()
|
||||
export class TaskDueEffects {
|
||||
|
|
@ -99,7 +99,7 @@ export class TaskDueEffects {
|
|||
.map((task) => task.id);
|
||||
|
||||
if (!environment.production && missingTaskIds.length > 0) {
|
||||
Log.err(
|
||||
TaskLog.err(
|
||||
'[TaskDueEffects] Found tasks due today missing from TODAY tag:',
|
||||
{
|
||||
tasksDueToday: tasksDueToday.length,
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ import { PlannerActions } from '../../planner/store/planner.actions';
|
|||
import { getWorklogStr } from '../../../util/get-work-log-str';
|
||||
import { TaskSharedActions } from '../../../root-store/meta/task-shared.actions';
|
||||
import { TimeTrackingActions } from '../../time-tracking/store/time-tracking.actions';
|
||||
import { Log } from '../../../core/log';
|
||||
import { TaskLog } from '../../../core/log';
|
||||
|
||||
export const TASK_FEATURE_NAME = 'tasks';
|
||||
|
||||
|
|
@ -281,14 +281,14 @@ export const taskReducer = createReducer<TaskState>(
|
|||
on(moveSubTaskUp, (state, { id, parentId }) => {
|
||||
const parentTask = state.entities[parentId];
|
||||
if (!parentTask) {
|
||||
Log.err(`Parent task ${parentId} not found`);
|
||||
TaskLog.err(`Parent task ${parentId} not found`);
|
||||
return state;
|
||||
}
|
||||
const parentSubTaskIds = parentTask.subTaskIds;
|
||||
|
||||
// Check if the subtask is actually in the parent's subtask list
|
||||
if (!parentSubTaskIds.includes(id)) {
|
||||
Log.err(`Subtask ${id} not found in parent ${parentId} subtasks`);
|
||||
TaskLog.err(`Subtask ${id} not found in parent ${parentId} subtasks`);
|
||||
return state;
|
||||
}
|
||||
|
||||
|
|
@ -306,14 +306,14 @@ export const taskReducer = createReducer<TaskState>(
|
|||
on(moveSubTaskDown, (state, { id, parentId }) => {
|
||||
const parentTask = state.entities[parentId];
|
||||
if (!parentTask) {
|
||||
Log.err(`Parent task ${parentId} not found`);
|
||||
TaskLog.err(`Parent task ${parentId} not found`);
|
||||
return state;
|
||||
}
|
||||
const parentSubTaskIds = parentTask.subTaskIds;
|
||||
|
||||
// Check if the subtask is actually in the parent's subtask list
|
||||
if (!parentSubTaskIds.includes(id)) {
|
||||
Log.err(`Subtask ${id} not found in parent ${parentId} subtasks`);
|
||||
TaskLog.err(`Subtask ${id} not found in parent ${parentId} subtasks`);
|
||||
return state;
|
||||
}
|
||||
|
||||
|
|
@ -331,14 +331,14 @@ export const taskReducer = createReducer<TaskState>(
|
|||
on(moveSubTaskToTop, (state, { id, parentId }) => {
|
||||
const parentTask = state.entities[parentId];
|
||||
if (!parentTask) {
|
||||
Log.err(`Parent task ${parentId} not found`);
|
||||
TaskLog.err(`Parent task ${parentId} not found`);
|
||||
return state;
|
||||
}
|
||||
const parentSubTaskIds = parentTask.subTaskIds;
|
||||
|
||||
// Check if the subtask is actually in the parent's subtask list
|
||||
if (!parentSubTaskIds.includes(id)) {
|
||||
Log.err(`Subtask ${id} not found in parent ${parentId} subtasks`);
|
||||
TaskLog.err(`Subtask ${id} not found in parent ${parentId} subtasks`);
|
||||
return state;
|
||||
}
|
||||
|
||||
|
|
@ -356,14 +356,14 @@ export const taskReducer = createReducer<TaskState>(
|
|||
on(moveSubTaskToBottom, (state, { id, parentId }) => {
|
||||
const parentTask = state.entities[parentId];
|
||||
if (!parentTask) {
|
||||
Log.err(`Parent task ${parentId} not found`);
|
||||
TaskLog.err(`Parent task ${parentId} not found`);
|
||||
return state;
|
||||
}
|
||||
const parentSubTaskIds = parentTask.subTaskIds;
|
||||
|
||||
// Check if the subtask is actually in the parent's subtask list
|
||||
if (!parentSubTaskIds.includes(id)) {
|
||||
Log.err(`Subtask ${id} not found in parent ${parentId} subtasks`);
|
||||
TaskLog.err(`Subtask ${id} not found in parent ${parentId} subtasks`);
|
||||
return state;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import { calcTotalTimeSpent } from '../util/calc-total-time-spent';
|
|||
import { taskAdapter } from './task.adapter';
|
||||
import { filterOutId } from '../../../util/filter-out-id';
|
||||
import { Update } from '@ngrx/entity';
|
||||
import { Log } from '../../../core/log';
|
||||
import { TaskLog } from '../../../core/log';
|
||||
|
||||
export const getTaskById = (taskId: string, state: TaskState): Task => {
|
||||
if (!state.entities[taskId]) {
|
||||
|
|
@ -38,7 +38,9 @@ export const reCalcTimeSpentForParentIfParent = (
|
|||
if (parentId) {
|
||||
const parentTask = state.entities[parentId];
|
||||
if (!parentTask) {
|
||||
Log.err(`Parent task ${parentId} not found in reCalcTimeSpentForParentIfParent`);
|
||||
TaskLog.err(
|
||||
`Parent task ${parentId} not found in reCalcTimeSpentForParentIfParent`,
|
||||
);
|
||||
return state;
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +84,9 @@ export const reCalcTimeEstimateForParentIfParent = (
|
|||
): TaskState => {
|
||||
const parentTask = state.entities[parentId];
|
||||
if (!parentTask) {
|
||||
Log.err(`Parent task ${parentId} not found in reCalcTimeEstimateForParentIfParent`);
|
||||
TaskLog.err(
|
||||
`Parent task ${parentId} not found in reCalcTimeEstimateForParentIfParent`,
|
||||
);
|
||||
return state;
|
||||
}
|
||||
|
||||
|
|
@ -94,9 +98,9 @@ export const reCalcTimeEstimateForParentIfParent = (
|
|||
return upd && upd.id === id ? { ...task, ...upd.changes } : task;
|
||||
})
|
||||
.filter((task): task is Task => !!task);
|
||||
// Log.log(
|
||||
// TaskLog.log(
|
||||
// subTasks.reduce((acc: number, st: Task) => {
|
||||
// Log.log(
|
||||
// TaskLog.log(
|
||||
// (st.isDone ? 0 : Math.max(0, st.timeEstimate - st.timeSpent)) / 60 / 1000,
|
||||
// );
|
||||
//
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import {
|
|||
} from './task-attachment.actions';
|
||||
import { TaskState } from '../task.model';
|
||||
import { createFromDrop } from 'src/app/core/drop-paste-input/drop-paste-input';
|
||||
import { Log } from '../../../core/log';
|
||||
import { TaskLog } from '../../../core/log';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
|
|
@ -23,7 +23,7 @@ export class TaskAttachmentService {
|
|||
|
||||
addAttachment(taskId: string, taskAttachment: TaskAttachment): void {
|
||||
if (!taskAttachment) {
|
||||
Log.err('No valid attachment passed');
|
||||
TaskLog.err('No valid attachment passed');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ import { TaskSharedActions } from '../../../../root-store/meta/task-shared.actio
|
|||
import { selectTodayTagTaskIds } from '../../../tag/store/tag.reducer';
|
||||
import { isToday } from '../../../../util/is-today.util';
|
||||
import { MenuTouchFixDirective } from '../menu-touch-fix.directive';
|
||||
import { Log } from '../../../../core/log';
|
||||
import { TaskLog } from '../../../../core/log';
|
||||
|
||||
@Component({
|
||||
selector: 'task-context-menu-inner',
|
||||
|
|
@ -404,7 +404,7 @@ export class TaskContextMenuInnerComponent implements AfterViewInit {
|
|||
archiveInstances,
|
||||
targetProject,
|
||||
]) => {
|
||||
Log.log({
|
||||
TaskLog.log({
|
||||
reminderCfg,
|
||||
nonArchiveInstancesWithSubTasks,
|
||||
archiveInstances,
|
||||
|
|
@ -537,7 +537,7 @@ export class TaskContextMenuInnerComponent implements AfterViewInit {
|
|||
|
||||
private async _schedule(selectedDate: Date, isRemoveFromToday = false): Promise<void> {
|
||||
if (!selectedDate) {
|
||||
Log.err('no selected date');
|
||||
TaskLog.err('no selected date');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -308,9 +308,9 @@ export class TaskDetailPanelComponent implements OnInit, AfterViewInit, OnDestro
|
|||
}
|
||||
});
|
||||
}
|
||||
// this.issueIdAndType$.subscribe((v) => Log.log('issueIdAndType$', v));
|
||||
// this.issueDataTrigger$.subscribe((v) => Log.log('issueDataTrigger$', v));
|
||||
// this.issueData$.subscribe((v) => Log.log('issueData$', v));
|
||||
// this.issueIdAndType$.subscribe((v) => TaskLog.log('issueIdAndType$', v));
|
||||
// this.issueDataTrigger$.subscribe((v) => TaskLog.log('issueDataTrigger$', v));
|
||||
// this.issueData$.subscribe((v) => TaskLog.log('issueData$', v));
|
||||
|
||||
// NOTE: check work-view component for more info
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import { MatIcon } from '@angular/material/icon';
|
|||
import { TaskComponent } from '../task/task.component';
|
||||
import { AsyncPipe } from '@angular/common';
|
||||
import { TaskViewCustomizerService } from '../../task-view-customizer/task-view-customizer.service';
|
||||
import { Log } from '../../../core/log';
|
||||
import { TaskLog } from '../../../core/log';
|
||||
|
||||
export type TaskListId = 'PARENT' | 'SUB';
|
||||
export type ListModelId = DropListModelSource | string;
|
||||
|
|
@ -132,7 +132,7 @@ export class TaskListComponent implements OnDestroy, AfterViewInit {
|
|||
// const targetModelId = drag.dropContainer.data.listModelId;
|
||||
const targetModelId = drop.data.listModelId;
|
||||
const isSubtask = !!task.parentId;
|
||||
// Log.log(drag.data.id, { isSubtask, targetModelId, drag, drop });
|
||||
// TaskLog.log(drag.data.id, { isSubtask, targetModelId, drag, drop });
|
||||
// return true;
|
||||
if (targetModelId === 'OVERDUE' || targetModelId === 'LATER_TODAY') {
|
||||
return false;
|
||||
|
|
@ -159,7 +159,7 @@ export class TaskListComponent implements OnDestroy, AfterViewInit {
|
|||
const srcListData = ev.previousContainer.data;
|
||||
const targetListData = ev.container.data;
|
||||
const draggedTask = ev.item.data;
|
||||
Log.log({
|
||||
TaskLog.log({
|
||||
ev,
|
||||
srcListData,
|
||||
targetListData,
|
||||
|
|
@ -221,7 +221,7 @@ export class TaskListComponent implements OnDestroy, AfterViewInit {
|
|||
...targetListData.filteredTasks.filter((t) => t.id !== draggedTask.id),
|
||||
draggedTask,
|
||||
];
|
||||
Log.log(srcListData.listModelId, '=>', targetListData.listModelId, {
|
||||
TaskLog.log(srcListData.listModelId, '=>', targetListData.listModelId, {
|
||||
targetTask,
|
||||
draggedTask,
|
||||
newIds,
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ import { TaskSharedActions } from '../../root-store/meta/task-shared.actions';
|
|||
import { getWorklogStr } from '../../util/get-work-log-str';
|
||||
import { INBOX_PROJECT } from '../project/project.const';
|
||||
import { GlobalConfigService } from '../config/global-config.service';
|
||||
import { Log } from '../../core/log';
|
||||
import { TaskLog } from '../../core/log';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
|
|
@ -285,7 +285,7 @@ export class TaskService {
|
|||
workContextId,
|
||||
});
|
||||
|
||||
Log.log(task, additional);
|
||||
TaskLog.log(task, additional);
|
||||
|
||||
this._store.dispatch(
|
||||
TaskSharedActions.addTask({
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ import { TaskSharedActions } from '../../../root-store/meta/task-shared.actions'
|
|||
import { environment } from '../../../../environments/environment';
|
||||
import { TODAY_TAG } from '../../tag/tag.const';
|
||||
import { GlobalTrackingIntervalService } from '../../../core/global-tracking-interval/global-tracking-interval.service';
|
||||
import { Log } from '../../../core/log';
|
||||
import { TaskLog } from '../../../core/log';
|
||||
|
||||
@Component({
|
||||
selector: 'task',
|
||||
|
|
@ -597,7 +597,7 @@ export class TaskComponent implements OnDestroy, AfterViewInit {
|
|||
focusTitleForEdit(): void {
|
||||
const taskTitleEditEl = this.taskTitleEditEl();
|
||||
if (!taskTitleEditEl || !taskTitleEditEl.textarea().nativeElement) {
|
||||
Log.log(taskTitleEditEl);
|
||||
TaskLog.log(taskTitleEditEl);
|
||||
throw new Error('No el');
|
||||
}
|
||||
taskTitleEditEl.textarea().nativeElement.focus();
|
||||
|
|
@ -711,7 +711,7 @@ export class TaskComponent implements OnDestroy, AfterViewInit {
|
|||
archiveInstances,
|
||||
targetProject,
|
||||
]) => {
|
||||
Log.log({
|
||||
TaskLog.log({
|
||||
reminderCfg,
|
||||
nonArchiveInstancesWithSubTasks,
|
||||
archiveInstances,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { SoundConfig } from '../../config/global-config.model';
|
||||
import { Log } from '../../../core/log';
|
||||
import { TaskLog } from '../../../core/log';
|
||||
|
||||
export const playDoneSound = (soundCfg: SoundConfig, nrOfDoneTasks: number = 0): void => {
|
||||
const speed = 1;
|
||||
|
|
@ -8,13 +8,13 @@ export const playDoneSound = (soundCfg: SoundConfig, nrOfDoneTasks: number = 0):
|
|||
const file = `${BASE}/${soundCfg.doneSound}`;
|
||||
// const speed = 0.5;
|
||||
// const a = new Audio('/assets/snd/done4.mp3');
|
||||
// Log.log(a);
|
||||
// TaskLog.log(a);
|
||||
// a.volume = .4;
|
||||
// a.playbackRate = 1.5;
|
||||
// (a as any).mozPreservesPitch = false;
|
||||
// (a as any).webkitPreservesPitch = false;
|
||||
// a.play();
|
||||
Log.log(file);
|
||||
TaskLog.log(file);
|
||||
|
||||
const pitchFactor = soundCfg.isIncreaseDoneSoundPitch
|
||||
? // prettier-ignore
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { TaskReminderOptionId } from '../task.model';
|
||||
import { devError } from '../../../util/dev-error';
|
||||
import { Log } from '../../../core/log';
|
||||
import { TaskLog } from '../../../core/log';
|
||||
|
||||
export const remindOptionToMilliseconds = (
|
||||
due: number,
|
||||
|
|
@ -55,7 +55,7 @@ export const millisecondsDiffToRemindOption = (
|
|||
} else if (diff <= 0) {
|
||||
return TaskReminderOptionId.AtStart;
|
||||
} else {
|
||||
Log.log(due, remindAt);
|
||||
TaskLog.log(due, remindAt);
|
||||
devError('Cannot determine remind option. Invalid params');
|
||||
return TaskReminderOptionId.DoNotRemind;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue