Change to send timeline result

This commit is contained in:
kPherox 2019-04-24 05:30:16 +09:00
parent 088599f88c
commit e0fc3df242
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D
4 changed files with 20 additions and 17 deletions

View File

@ -42,13 +42,15 @@ export default class AddColumn extends Vue {
public addTL() { public addTL() {
this.showInput = false this.showInput = false
this.pubTL.push(this.instance) let instance = this.instance
this.pubTL.push(instance)
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-timeline', value);
}); });
} }
} }

View File

@ -43,7 +43,7 @@ button {
--btn-bg-color: var(--bg-color) !important; --btn-bg-color: var(--bg-color) !important;
} }
font-size: 1em; font-size: var(--font-size);
margin: 0 0.5em; margin: 0 0.5em;
padding: 0.8em 2em; padding: 0.8em 2em;

View File

@ -12,8 +12,8 @@ export default class Streaming {
} }
public static ready() { public static ready() {
ipcMain.on('open-streaming', (_: Event, domain: string, type: string) => { ipcMain.on('open-streaming', (_: Event, name: string, type: string) => {
return this.shared.openStreaming(domain, type) return this.shared.openStreaming(name, type)
}) })
} }
@ -23,20 +23,20 @@ export default class Streaming {
this.sockets = new Map() this.sockets = new Map()
} }
private openStreaming(clientName: string, type: string) { private openStreaming(name: string, type: string) {
let client: Mastodon let client: Mastodon
let stream: string let stream: string
switch (type) { switch (type) {
case 'no-auth': case 'no-auth':
client = Client.getNoAuthClient(clientName) client = Client.getNoAuthClient(name)
stream = 'public:local' stream = 'public:local'
break break
default: default:
return return
} }
let socketName = clientName + ':' + type let socketName = name + ':' + type
if (this.sockets.has(socketName)) { if (this.sockets.has(socketName)) {
return return
} }
@ -49,7 +49,7 @@ export default class Streaming {
socket.on('update', (status: Status) => { socket.on('update', (status: Status) => {
if (Window.windowMap.has('main')) { if (Window.windowMap.has('main')) {
Window.windowMap.get('main')!.webContents.send(`update-${clientName}-${type}`, status) Window.windowMap.get('main')!.webContents.send(`update-${name}-${type}`, status)
} }
}) })
@ -59,7 +59,7 @@ export default class Streaming {
socket.on('delete', (id: number) => { socket.on('delete', (id: number) => {
if (Window.windowMap.has('main')) { if (Window.windowMap.has('main')) {
Window.windowMap.get('main')!.webContents.send(`delete-${clientName}-${type}`, id) Window.windowMap.get('main')!.webContents.send(`delete-${name}-${type}`, id)
} }
}) })

View File

@ -1,19 +1,20 @@
import { import {
ipcMain ipcMain
} from 'electron' } from 'electron'
import Mastodon, { Status, Response } from 'megalodon' import { Status, Response } from 'megalodon'
import Client from './Client' import Client from './Client'
import Window from './Window'
export default class Timeline { export default class Timeline {
public static ready() { public static ready() {
ipcMain.on('no-auth-streaming', (event: Event, instance: string) => { ipcMain.on('no-auth-timeline', async (event: Event, name: string) => {
const client = Client.getNoAuthClient(instance) const client = Client.getNoAuthClient(name)
let res: Response<[Status]> = await client.get<[Status]>('/timelines/public?local=true')
client.get<[Status]>('/timelines/public?local=true') if (Window.windowMap.has('main')) {
.then((resp: Response<[Status]>) => { Window.windowMap.get('main')!.webContents.send(`timeline-${name}-no-auth`, res.data)
console.log(resp.data) }
})
}) })
} }
} }