Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mayswind committed Dec 30, 2024
1 parent 2560a70 commit 863e020
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 35 deletions.
5 changes: 1 addition & 4 deletions src/consts/timezone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,7 @@ export const ALL_TIMEZONES: TimezoneInfo[] = [
timezoneName: 'Atlantic/Cape_Verde'
},
// UTC
{
displayName: 'Coordinated Universal Time',
timezoneName: 'Etc/GMT'
},
UTC_TIMEZONE,
// UTC+00:00
{
displayName: 'Dublin, Edinburgh, Lisbon, London',
Expand Down
8 changes: 3 additions & 5 deletions src/lib/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,10 @@ export function allTransactionCategoriesWithVisibleCount(allTransactionCategorie
|| allowCategoryTypes[CategoryType.Expense.toString()]
|| allowCategoryTypes[CategoryType.Transfer.toString()]);

for (let key in CategoryType) {
if (!Object.prototype.hasOwnProperty.call(CategoryType, key)) {
continue;
}
const allCategoryTypes = [ CategoryType.Income, CategoryType.Expense, CategoryType.Transfer ];

const categoryType = CategoryType[key];
for (let i = 0; i < allCategoryTypes.length; i++) {
const categoryType = allCategoryTypes[i];

if (!allTransactionCategories[categoryType]) {
continue;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ function getCurrentLanguageDisplayName(i18nGlobal) {
return currentLanguageInfo.displayName;
}

function getLocalizedDisplayNameAndType(nameAndTypes, translateFn) {
function getLocalizedDisplayNameAndType(typeAndNames, translateFn) {
const ret = [];

for (let i = 0; i < nameAndTypes.length; i++) {
const nameAndType = nameAndTypes[i];
for (let i = 0; i < typeAndNames.length; i++) {
const nameAndType = typeAndNames[i];

ret.push({
type: nameAndType.type,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/session.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import uaParser from 'ua-parser-js';

import { CliUserAgent, type TokenInfoResponse, SessionInfo } from '@/models/token.ts';
import { TOKEN_CLI_USER_AGENT, type TokenInfoResponse, SessionInfo } from '@/models/token.ts';

interface UserAgentInfo {
device: {
Expand Down Expand Up @@ -39,7 +39,7 @@ function parseUserAgent(ua: string): UserAgentInfo {
}

function isSessionUserAgentCreatedByCli(ua: string): boolean {
return ua === CliUserAgent;
return ua === TOKEN_CLI_USER_AGENT;
}

function parseDeviceInfo(uaInfo: UserAgentInfo): string {
Expand Down
2 changes: 1 addition & 1 deletion src/models/token.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const CliUserAgent: string = 'ezbookkeeping Cli';
export const TOKEN_CLI_USER_AGENT: string = 'ezbookkeeping Cli';

export interface TokenInfoResponse {
readonly tokenId: string;
Expand Down
31 changes: 11 additions & 20 deletions src/views/mobile/settings/CategoryFilterSettingsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,24 @@ export default {
'f7router'
],
data: function () {
const self = this;
return {
loading: true,
loadingError: null,
type: null,
allowCategoryTypes: null,
filterCategoryIds: {},
showHidden: false,
collapseStates: self.getCollapseStates(),
collapseStates: {
[CategoryType.Income]: {
opened: true
},
[CategoryType.Expense]: {
opened: true
},
[CategoryType.Transfer]: {
opened: true
}
},
showMoreActionSheet: false
}
},
Expand Down Expand Up @@ -367,23 +375,6 @@ export default {
},
isSubCategoriesHasButNotAllChecked(category, filterCategoryIds) {
return isSubCategoriesHasButNotAllChecked(category, filterCategoryIds);
},
getCollapseStates() {
const collapseStates = {};
for (const categoryTypeField in CategoryType) {
if (!Object.prototype.hasOwnProperty.call(CategoryType, categoryTypeField)) {
continue;
}
const categoryType = CategoryType[categoryTypeField];
collapseStates[categoryType] = {
opened: true
};
}
return collapseStates;
}
}
}
Expand Down

0 comments on commit 863e020

Please sign in to comment.