diff --git a/src/main/Application.ts b/src/main/Application.ts index 2723ac9d..44faae11 100644 --- a/src/main/Application.ts +++ b/src/main/Application.ts @@ -30,6 +30,7 @@ export default class Application { private constructor() { this.isDarkMode = systemPreferences.isDarkMode() + const gotTheLock = app.requestSingleInstanceLock() if (!gotTheLock) { app.quit() @@ -77,6 +78,11 @@ export default class Application { ipcMain.on('dark-theme', (e: Event) => e.returnValue = this.isDarkMode) + ipcMain.on('is-startup', (e: Event) => { + // 初回起動かどうかをここで判断させる。timeline.dbかaccount.dbがあれば初回起動じゃない扱いでもいいか? + e.returnValue = true + }) + Window.Main() } diff --git a/src/main/Client.ts b/src/main/Client.ts index 0a463af2..ba5fc3ad 100644 --- a/src/main/Client.ts +++ b/src/main/Client.ts @@ -5,7 +5,7 @@ import { join } from "path" type Protocol = 'http' | 'websocket' -export default class Clients { +export default class Client { // Authorized Accounts. keyには`username@domain`を設定します private static authorizedHTTP: Map = new Map() private static authorizedWebSocket: Map = new Map() @@ -27,7 +27,7 @@ export default class Clients { if (err) { console.log(err) } else { - Clients.setAuthClient(protocol, username, Clients.createAuthClient(protocol, docs.domain, docs.accessToken)) + Client.setAuthClient(protocol, username, Client.createAuthClient(protocol, docs.domain, docs.accessToken)) } }) } @@ -66,7 +66,7 @@ export default class Clients { private static createNoAuthClient(protocol: Protocol, domain: string): Mastodon { let scheme = protocol === 'http' ? 'https://' : 'wss://' return new Mastodon( - '', + '', // pleromaでは空文字ではなくnullを指定しないと毎秒403エラーになるアクセスを繰り返すことになる。TypeScriptではnullを入れられないのでmegalodonの方を修正する必要あり scheme + domain + '/api/v1' ) } diff --git a/src/views/App.vue b/src/views/App.vue index 99a2590d..6913e782 100644 --- a/src/views/App.vue +++ b/src/views/App.vue @@ -19,9 +19,9 @@ import Welcome from '@/components/Welcome.vue' }, }) export default class App extends Vue { - public isDarkMode!: boolean - public isStartup!: boolean - public fontSize!: string + public isDarkMode: boolean = false + public isStartup: boolean = true + public fontSize: string = '16px' public get styles(): { [key: string]: string } { return { @@ -33,15 +33,20 @@ export default class App extends Vue { created() { this.isDarkMode = ipcRenderer.sendSync('dark-theme') - this.isStartup = true // TODO: ipcで初回起動かのboolean値を取得する - this.fontSize = '16px' + this.isStartup = ipcRenderer.sendSync('is-startup') // TODO: ipcで初回起動かのboolean値を取得する } mounted() { ipcRenderer.on('change-color-theme', () => this.isDarkMode = ipcRenderer.sendSync('dark-theme')) // TODO: アカウントか公開TLの追加を確認する。初回起動時のみ if (this.isStartup) { - //ipcRenderer.once('add-timeline', () => this.isStartup = false) + ipcRenderer.once('add-timeline', (_e: Event, _tl: Object, error?: Error) => { + if (error) { + console.error(error) + return + } + this.isStartup = false + }) } }