Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(desktop & web): modify default value of auto scroll interval #1147

Merged
merged 1 commit into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/database/database.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { topicDisabled1640846307653 } from './migration/1640846307653-topicDisab
import { reconnectPeriod1642321826532 } from './migration/1642321826532-reconnectPeriod'
import { multiTopics1659668384878 } from './migration/1659668384878-multiTopics'
import { autoScrollInterval1668415942736 } from './migration/1668415942736-autoScrollInterval'
import { modifyDefaultValueOfAutoScrollInterval1668672504891 } from './migration/1668672504891-modifyDefaultValueOfAutoScrollInterval'

const STORE_PATH = getAppDataPath('MQTTX')
try {
Expand Down Expand Up @@ -71,6 +72,7 @@ const ORMConfig = {
reconnectPeriod1642321826532,
multiTopics1659668384878,
autoScrollInterval1668415942736,
modifyDefaultValueOfAutoScrollInterval1668672504891,
],
migrationsTableName: 'temp_migration_table',
entities: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import { MigrationInterface, QueryRunner } from 'typeorm'

export class modifyDefaultValueOfAutoScrollInterval1668672504891 implements MigrationInterface {
name = 'modifyDefaultValueOfAutoScrollInterval1668672504891'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
CREATE TABLE "temporary_SettingEntity" (
"id" varchar PRIMARY KEY NOT NULL,
"width" integer NOT NULL DEFAULT (1025),
"height" integer NOT NULL DEFAULT (749),
"autoCheck" boolean NOT NULL DEFAULT (1),
"currentLang" varchar CHECK(currentLang IN ('zh', 'en', 'ja', 'tr', 'hu')) NOT NULL DEFAULT ('en'),
"currentTheme" varchar CHECK(currentTheme IN ('light', 'dark', 'night')) NOT NULL DEFAULT ('light'),
"maxReconnectTimes" integer NOT NULL DEFAULT (10),
"autoResub" boolean NOT NULL DEFAULT (1),
"autoScroll" boolean NOT NULL DEFAULT (1),
"syncOsTheme" boolean NOT NULL DEFAULT (0),
"multiTopics" boolean NOT NULL DEFAULT (1),
"autoScrollInterval" integer NOT NULL DEFAULT (0)
)
`)
await queryRunner.query(`
INSERT INTO "temporary_SettingEntity"(
"id",
"width",
"height",
"autoCheck",
"currentLang",
"currentTheme",
"maxReconnectTimes",
"autoResub",
"autoScroll",
"syncOsTheme",
"multiTopics",
"autoScrollInterval"
)
SELECT "id",
"width",
"height",
"autoCheck",
"currentLang",
"currentTheme",
"maxReconnectTimes",
"autoResub",
"autoScroll",
"syncOsTheme",
"multiTopics",
"autoScrollInterval"
FROM "SettingEntity"
`)
await queryRunner.query(`
DROP TABLE "SettingEntity"
`)
await queryRunner.query(`
ALTER TABLE "temporary_SettingEntity"
RENAME TO "SettingEntity"
`)
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE "SettingEntity"
RENAME TO "temporary_SettingEntity"
`)
await queryRunner.query(`
CREATE TABLE "SettingEntity" (
"id" varchar PRIMARY KEY NOT NULL,
"width" integer NOT NULL DEFAULT (1025),
"height" integer NOT NULL DEFAULT (749),
"autoCheck" boolean NOT NULL DEFAULT (1),
"currentLang" varchar CHECK(currentLang IN ('zh', 'en', 'ja', 'tr', 'hu')) NOT NULL DEFAULT ('en'),
"currentTheme" varchar CHECK(currentTheme IN ('light', 'dark', 'night')) NOT NULL DEFAULT ('light'),
"maxReconnectTimes" integer NOT NULL DEFAULT (10),
"autoResub" boolean NOT NULL DEFAULT (1),
"autoScroll" boolean NOT NULL DEFAULT (1),
"syncOsTheme" boolean NOT NULL DEFAULT (0),
"multiTopics" boolean NOT NULL DEFAULT (1),
"autoScrollInterval" integer NOT NULL DEFAULT (1)
)
`)
await queryRunner.query(`
INSERT INTO "SettingEntity"(
"id",
"width",
"height",
"autoCheck",
"currentLang",
"currentTheme",
"maxReconnectTimes",
"autoResub",
"autoScroll",
"syncOsTheme",
"multiTopics",
"autoScrollInterval"
)
SELECT "id",
"width",
"height",
"autoCheck",
"currentLang",
"currentTheme",
"maxReconnectTimes",
"autoResub",
"autoScroll",
"syncOsTheme",
"multiTopics",
"autoScrollInterval"
FROM "temporary_SettingEntity"
`)
await queryRunner.query(`
DROP TABLE "temporary_SettingEntity"
`)
}
}
2 changes: 1 addition & 1 deletion src/database/models/SettingEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class SettingEntity {
@Column({ type: 'boolean', default: true })
autoScroll!: boolean

@Column({ type: 'integer', default: 1 })
@Column({ type: 'integer', default: 0 })
autoScrollInterval!: number

@Column({ type: 'boolean', default: false })
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const app = {
autoCheck: settingData.autoCheck,
autoResub: settingData.autoResub,
autoScroll: settingData.autoScroll,
autoScrollInterval: settingData.autoScrollInterval || 1,
autoScrollInterval: settingData.autoScrollInterval || 0,
syncOsTheme: settingData.syncOsTheme,
multiTopics: settingData.multiTopics,
maxReconnectTimes: settingData.maxReconnectTimes || 10,
Expand Down
2 changes: 1 addition & 1 deletion src/views/settings/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<label>{{ $t('settings.autoScrollInterval') }}</label>
</el-col>
<el-col :span="4">
<el-input-number size="mini" :value="autoScrollInterval" :min="1" @change="handleAutoScrollIntervalChange">
<el-input-number size="mini" :value="autoScrollInterval" :min="0" @change="handleAutoScrollIntervalChange">
</el-input-number>
</el-col>
</el-row>
Expand Down
2 changes: 1 addition & 1 deletion web/src/database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DB {
}
// Set auto scroll interval to 1 second by default
if (!this.db.has('settings.autoScrollInterval').value()) {
this.db.set('settings.autoScrollInterval', 1).write()
this.db.set('settings.autoScrollInterval', 0).write()
}
// Set max reconnection times
if (!this.db.get('settings.maxReconnectTimes').value()) {
Expand Down
27 changes: 8 additions & 19 deletions web/src/views/settings/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<el-col :span="4">
<el-select
class="settings-options"
v-model="currentLang"
:value="currentLang"
size="mini"
@change="handleSelectChange('lang', $event)"
>
Expand Down Expand Up @@ -85,7 +85,7 @@
<label>{{ $t('settings.autoScrollInterval') }}</label>
</el-col>
<el-col :span="4">
<el-input-number size="mini" v-model="autoScrollInterval" :min="1" @change="handleAutoScrollIntervalChange">
<el-input-number size="mini" :value="autoScrollInterval" :min="0" @change="handleAutoScrollIntervalChange">
</el-input-number>
</el-col>
</el-row>
Expand Down Expand Up @@ -125,7 +125,7 @@
<label>{{ $t('settings.maxReconnectTimes') }}</label>
</el-col>
<el-col :span="4">
<el-input-number size="mini" v-model="maxReconnectTimes" :min="1" @change="handleInputChage">
<el-input-number size="mini" :value="maxReconnectTimes" :min="1" @change="handleInputChage">
</el-input-number>
</el-col>
</el-row>
Expand All @@ -145,7 +145,7 @@
<el-col :span="4">
<el-select
class="settings-options"
v-model="currentTheme"
:value="currentTheme"
size="mini"
@change="handleSelectChange('theme', $event)"
>
Expand Down Expand Up @@ -175,18 +175,14 @@ export default class Settings extends Vue {
autoScrollInterval: number
}) => void
@Action('TOGGLE_MULTI_TOPICS') private actionToggleMultiTopics!: (payload: { multiTopics: boolean }) => void
@Getter('currentTheme') private getterTheme!: 'light' | 'dark' | 'night'
@Getter('currentLang') private getterLang!: Language
@Getter('maxReconnectTimes') private getterMaxReconnectTimes!: number
@Getter('currentTheme') private currentTheme!: 'light' | 'dark' | 'night'
@Getter('currentLang') private currentLang!: Language
@Getter('maxReconnectTimes') private maxReconnectTimes!: number
@Getter('autoResub') private autoResub!: boolean
@Getter('autoScroll') private autoScroll!: boolean
@Getter('autoScrollInterval') private getterAutoScrollInterval!: number
@Getter('autoScrollInterval') private autoScrollInterval!: number
@Getter('multiTopics') private multiTopics!: boolean

private currentTheme: 'light' | 'dark' | 'night' = 'light'
private currentLang: Language = 'en'
private autoScrollInterval = 1
private maxReconnectTimes = 10
private langOptions: Options[] = [
{ label: '简体中文', value: 'zh' },
{ label: 'English', value: 'en' },
Expand Down Expand Up @@ -228,13 +224,6 @@ export default class Settings extends Vue {
private handleAutoScrollIntervalChange(value: number) {
this.actionAutoScrollInterval({ autoScrollInterval: value })
}

private created() {
this.currentTheme = this.getterTheme
this.currentLang = this.getterLang
this.autoScrollInterval = this.getterAutoScrollInterval
this.maxReconnectTimes = this.getterMaxReconnectTimes
}
}
</script>

Expand Down