Move Timeline.ready to Application.onReady

Disabled add column button if not input
This commit is contained in:
kPherox 2019-04-24 03:40:04 +09:00
parent e5b723837d
commit 49acb2c7b7
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D
4 changed files with 37 additions and 33 deletions

View File

@ -12,7 +12,6 @@ import ContextMenu from 'electron-context-menu'
import Application from './main/Application'
import ApplicationMenu from './main/ApplicationMenu'
import Timeline from './main/Timeline'
export type PackageJson = typeof import('../package.json')
import { author, contributors, homepage } from '../package.json'
@ -46,8 +45,6 @@ if (process.env.NODE_ENV !== 'production') {
protocol.registerStandardSchemes(['app'], { secure: true })
ContextMenu()
//この書き方がいいのかは知りません。(cutls|main/Timeline.ts)
Timeline.timelineReady()
const TheDeskVueApp: Application = Application.shared
TheDeskVueApp.setApplicationMenu(ApplicationMenu.buildTemplate())

View File

@ -5,7 +5,8 @@
<BaseButton
@click.native="addTL"
class="primary fill"
style="font-size:.8em;"
style="--font-size:.8em;"
:disabled="!hasDomain"
>Add Column</BaseButton>
</div>
<div id="timelines">
@ -17,7 +18,7 @@
v-if="!showInput"
@click.native="showInput = true"
class="primary fill"
style="font-size:.8em;"
style="--font-size:.8em;"
>Show Menu</BaseButton>
</div>
</template>
@ -26,16 +27,18 @@
import { ipcRenderer } from 'electron'
import { Component, Vue } from 'vue-property-decorator'
type Status = 'welcome' | 'login' | 'public_timeline'
type Instance = String
type Instance = string
type showInput = boolean
type Timelines = String[]
type Timelines = string[]
@Component
export default class AddColumn extends Vue {
public status: Status = 'welcome'
public instance: Instance = ''
public showInput : showInput = true
public pubTL : Timelines = []
public showInput: showInput = true
public pubTL: Timelines = []
public get hasDomain() {
return this.instance != ''
}
public addTL() {
this.showInput = false
@ -43,8 +46,8 @@ export default class AddColumn extends Vue {
this.timeline()
}
public timeline(){
this.pubTL.forEach(function( value ) {
public timeline() {
this.pubTL.forEach(function (value) {
ipcRenderer.send('no-auth-streaming', value);
});
}

View File

@ -9,13 +9,14 @@ import {
} from 'vue-cli-plugin-electron-builder/lib'
import Window from './Window'
import Timeline from './Timeline'
const isDevelopment = process.env.NODE_ENV !== 'production'
export default class Application {
private static _instance: Application
public static get shared() {
public static get shared(): Application {
// Do you need arguments? Make it a regular static method instead.
return this._instance || (this._instance = new this())
}
@ -46,6 +47,9 @@ export default class Application {
}
}
if (!process.env.WEBPACK_DEV_SERVER_URL) createProtocol('app')
Timeline.ready()
Window.Main()
}

View File

@ -2,13 +2,13 @@ import {
ipcMain
} from 'electron'
import Mastodon, { Status, Response } from 'megalodon'
//この書き方がいいのかは知りません。(cutls|background.ts)
export default class Timeline {
static timelineReady() {
ipcMain.on('no-auth-streaming', (event: Event, instance :String) => {
public static ready() {
ipcMain.on('no-auth-streaming', (event: Event, instance: string) => {
const client = new Mastodon(
"",
"https://"+instance + '/api/v1'
'',
'https://' + instance + '/api/v1'
)
client.get<[Status]>('/timelines/public?local=true')