Add username props to user timeline component

This commit is contained in:
kPherox 2019-04-27 06:45:45 +09:00
parent 212cea2b59
commit d3f5313bd8
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D
4 changed files with 30 additions and 9 deletions

View File

@ -23,6 +23,8 @@ import { Component, Prop, Vue } from "vue-property-decorator"
@Component
export default class UserTimeline extends Vue {
@Prop() public username!: string
public timelineType: string = 'home'
public userTimelineTypes: {
[key: string]: string

View File

@ -22,7 +22,16 @@
<script lang="ts">
import { ipcRenderer } from "electron"
import { Component, Vue } from "vue-property-decorator"
type Instance = string
interface Account {
domain: string
acct: string
avatar: string
avatarStatic: string
accessToken?: string
}
@Component
export default class AccountAuth extends Vue {
public instance: Instance = ""
@ -44,8 +53,8 @@ export default class AccountAuth extends Vue {
this.instance = ''
ipcRenderer.once(
`login-complete`,
(e: Event) => {
this.$emit('login-complete')
(e: Event, account: Account) => {
this.$emit('login-complete', account)
}
)
}

View File

@ -18,7 +18,7 @@
>
<Login v-if="status === 'login'" @login-complete="loggedIn"/>
<PublicTimeline v-else-if="status === 'public_timeline'"/>
<Timeline v-else-if="status === 'select_timeline'"/>
<UserTimeline v-else-if="status === 'select_timeline'" :username="username"/>
</BaseOverlay>
</div>
</template>
@ -27,25 +27,35 @@
import { Component, Vue } from 'vue-property-decorator'
import Login from './Preferences/AccountAuth.vue'
import Timeline from './AddColumn/UserTimeline.vue'
import UserTimeline from './AddColumn/UserTimeline.vue'
import PublicTimeline from './AddColumn/PublicTimeline.vue'
type Status = 'welcome' | 'login' | 'public_timeline' | 'select_timeline'
interface Account {
domain: string
acct: string
avatar: string
avatarStatic: string
accessToken?: string
}
@Component({
components: {
Login,
Timeline,
UserTimeline,
PublicTimeline,
}
})
export default class Welcome extends Vue {
public status: Status = 'welcome'
public loginButton: string = 'Login'
public publicTLButton: string = 'Streaming Public Timeline'
public selectTimeline: string = 'Select Timeline'
public loggedIn() {
public username: string = ''
public status: Status = 'welcome'
public loggedIn(account: Account) {
this.username = `@${account.acct}@${account.domain}`
this.status = 'select_timeline'
}
}

View File

@ -68,7 +68,7 @@ export default class Auth {
autoload: true
})
let docs = {
domain: url,
domain: instance,
acct: you.acct,
avatar: you.avatar,
avatarStatic: you.avatar_static,
@ -82,7 +82,7 @@ export default class Auth {
message: "You cannot login already logined account."
})
} else {
event.sender.send(`login-complete`)
event.sender.send(`login-complete`, newDocs)
}
})
})