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 @Component
export default class UserTimeline extends Vue { export default class UserTimeline extends Vue {
@Prop() public username!: string
public timelineType: string = 'home' public timelineType: string = 'home'
public userTimelineTypes: { public userTimelineTypes: {
[key: string]: string [key: string]: string

View File

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

View File

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

View File

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