Move Timeline.ready to Application.onReady
Disabled add column button if not input
This commit is contained in:
		@@ -12,7 +12,6 @@ import ContextMenu from 'electron-context-menu'
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import Application from './main/Application'
 | 
					import Application from './main/Application'
 | 
				
			||||||
import ApplicationMenu from './main/ApplicationMenu'
 | 
					import ApplicationMenu from './main/ApplicationMenu'
 | 
				
			||||||
import Timeline from './main/Timeline'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type PackageJson = typeof import('../package.json')
 | 
					export type PackageJson = typeof import('../package.json')
 | 
				
			||||||
import { author, contributors, homepage } from '../package.json'
 | 
					import { author, contributors, homepage } from '../package.json'
 | 
				
			||||||
@@ -46,8 +45,6 @@ if (process.env.NODE_ENV !== 'production') {
 | 
				
			|||||||
protocol.registerStandardSchemes(['app'], { secure: true })
 | 
					protocol.registerStandardSchemes(['app'], { secure: true })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ContextMenu()
 | 
					ContextMenu()
 | 
				
			||||||
//この書き方がいいのかは知りません。(cutls|main/Timeline.ts)
 | 
					 | 
				
			||||||
Timeline.timelineReady()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const TheDeskVueApp: Application = Application.shared
 | 
					const TheDeskVueApp: Application = Application.shared
 | 
				
			||||||
TheDeskVueApp.setApplicationMenu(ApplicationMenu.buildTemplate())
 | 
					TheDeskVueApp.setApplicationMenu(ApplicationMenu.buildTemplate())
 | 
				
			||||||
@@ -5,7 +5,8 @@
 | 
				
			|||||||
      <BaseButton
 | 
					      <BaseButton
 | 
				
			||||||
        @click.native="addTL"
 | 
					        @click.native="addTL"
 | 
				
			||||||
        class="primary fill"
 | 
					        class="primary fill"
 | 
				
			||||||
        style="font-size:.8em;"
 | 
					        style="--font-size:.8em;"
 | 
				
			||||||
 | 
					        :disabled="!hasDomain"
 | 
				
			||||||
      >Add Column</BaseButton>
 | 
					      >Add Column</BaseButton>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <div id="timelines">
 | 
					    <div id="timelines">
 | 
				
			||||||
@@ -14,11 +15,11 @@
 | 
				
			|||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <BaseButton
 | 
					    <BaseButton
 | 
				
			||||||
        v-if="!showInput"
 | 
					      v-if="!showInput"
 | 
				
			||||||
        @click.native="showInput = true"
 | 
					      @click.native="showInput = true"
 | 
				
			||||||
        class="primary fill"
 | 
					      class="primary fill"
 | 
				
			||||||
        style="font-size:.8em;"
 | 
					      style="--font-size:.8em;"
 | 
				
			||||||
      >Show Menu</BaseButton>
 | 
					    >Show Menu</BaseButton>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -26,16 +27,18 @@
 | 
				
			|||||||
import { ipcRenderer } from 'electron'
 | 
					import { ipcRenderer } from 'electron'
 | 
				
			||||||
import { Component, Vue } from 'vue-property-decorator'
 | 
					import { Component, Vue } from 'vue-property-decorator'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Status = 'welcome' | 'login' | 'public_timeline'
 | 
					type Instance = string
 | 
				
			||||||
type Instance = String
 | 
					 | 
				
			||||||
type showInput = boolean
 | 
					type showInput = boolean
 | 
				
			||||||
type Timelines = String[]
 | 
					type Timelines = string[]
 | 
				
			||||||
@Component
 | 
					@Component
 | 
				
			||||||
export default class AddColumn extends Vue {
 | 
					export default class AddColumn extends Vue {
 | 
				
			||||||
  public status: Status = 'welcome'
 | 
					 | 
				
			||||||
  public instance: Instance = ''
 | 
					  public instance: Instance = ''
 | 
				
			||||||
  public showInput : showInput = true
 | 
					  public showInput: showInput = true
 | 
				
			||||||
  public pubTL : Timelines = []
 | 
					  public pubTL: Timelines = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public get hasDomain() {
 | 
				
			||||||
 | 
					    return this.instance != ''
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public addTL() {
 | 
					  public addTL() {
 | 
				
			||||||
    this.showInput = false
 | 
					    this.showInput = false
 | 
				
			||||||
@@ -43,9 +46,9 @@ export default class AddColumn extends Vue {
 | 
				
			|||||||
    this.timeline()
 | 
					    this.timeline()
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public timeline(){
 | 
					  public timeline() {
 | 
				
			||||||
    this.pubTL.forEach(function( value ) {
 | 
					    this.pubTL.forEach(function (value) {
 | 
				
			||||||
     ipcRenderer.send('no-auth-streaming', value);
 | 
					      ipcRenderer.send('no-auth-streaming', value);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,13 +9,14 @@ import {
 | 
				
			|||||||
} from 'vue-cli-plugin-electron-builder/lib'
 | 
					} from 'vue-cli-plugin-electron-builder/lib'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import Window from './Window'
 | 
					import Window from './Window'
 | 
				
			||||||
 | 
					import Timeline from './Timeline'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const isDevelopment = process.env.NODE_ENV !== 'production'
 | 
					const isDevelopment = process.env.NODE_ENV !== 'production'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default class Application {
 | 
					export default class Application {
 | 
				
			||||||
    private static _instance: 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.
 | 
					        // Do you need arguments? Make it a regular static method instead.
 | 
				
			||||||
        return this._instance || (this._instance = new this())
 | 
					        return this._instance || (this._instance = new this())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -46,6 +47,9 @@ export default class Application {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (!process.env.WEBPACK_DEV_SERVER_URL) createProtocol('app')
 | 
					        if (!process.env.WEBPACK_DEV_SERVER_URL) createProtocol('app')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Timeline.ready()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Window.Main()
 | 
					        Window.Main()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,20 +1,20 @@
 | 
				
			|||||||
import {
 | 
					import {
 | 
				
			||||||
  ipcMain
 | 
					    ipcMain
 | 
				
			||||||
} from 'electron'
 | 
					} from 'electron'
 | 
				
			||||||
import Mastodon, { Status, Response } from 'megalodon'
 | 
					import Mastodon, { Status, Response } from 'megalodon'
 | 
				
			||||||
//この書き方がいいのかは知りません。(cutls|background.ts)
 | 
					 | 
				
			||||||
export default class Timeline {
 | 
					 | 
				
			||||||
    static timelineReady() {
 | 
					 | 
				
			||||||
      ipcMain.on('no-auth-streaming', (event: Event, instance :String) => {
 | 
					 | 
				
			||||||
        const client = new Mastodon(
 | 
					 | 
				
			||||||
          "",
 | 
					 | 
				
			||||||
          "https://"+instance + '/api/v1'
 | 
					 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        client.get<[Status]>('/timelines/public?local=true')
 | 
					export default class Timeline {
 | 
				
			||||||
          .then((resp: Response<[Status]>) => {
 | 
					    public static ready() {
 | 
				
			||||||
            console.log(resp.data)
 | 
					        ipcMain.on('no-auth-streaming', (event: Event, instance: string) => {
 | 
				
			||||||
          })
 | 
					            const client = new Mastodon(
 | 
				
			||||||
      })
 | 
					                '',
 | 
				
			||||||
 | 
					                'https://' + instance + '/api/v1'
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            client.get<[Status]>('/timelines/public?local=true')
 | 
				
			||||||
 | 
					                .then((resp: Response<[Status]>) => {
 | 
				
			||||||
 | 
					                    console.log(resp.data)
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user