Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dima Krasner
Sharkey
Commits
7c30b94c
Commit
7c30b94c
authored
7 years ago
by
こぴなたみぽ
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
697cbc3a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/web/app/desktop/-tags/user-timeline.tag
+0
-150
0 additions, 150 deletions
src/web/app/desktop/-tags/user-timeline.tag
src/web/app/desktop/views/components/user-timeline.vue
+133
-0
133 additions, 0 deletions
src/web/app/desktop/views/components/user-timeline.vue
with
133 additions
and
150 deletions
src/web/app/desktop/-tags/user-timeline.tag
deleted
100644 → 0
+
0
−
150
View file @
697cbc3a
<mk-user-timeline>
<header>
<span data-is-active={ mode == 'default' } @click="setMode.bind(this, 'default')">投稿</span><span data-is-active={ mode == 'with-replies' } @click="setMode.bind(this, 'with-replies')">投稿と返信</span>
</header>
<div class="loading" v-if="isLoading">
<mk-ellipsis-icon/>
</div>
<p class="empty" v-if="isEmpty">%fa:R comments%このユーザーはまだ何も投稿していないようです。</p>
<mk-timeline ref="timeline">
<yield to="footer">
<template v-if="!parent.moreLoading">%fa:moon%</template>
<template v-if="parent.moreLoading">%fa:spinner .pulse .fw%</template>
</yield/>
</mk-timeline>
<style lang="stylus" scoped>
:scope
display block
background #fff
> header
padding 8px 16px
border-bottom solid 1px #eee
> span
margin-right 16px
line-height 27px
font-size 18px
color #555
&:not([data-is-active])
color $theme-color
cursor pointer
&:hover
text-decoration underline
> .loading
padding 64px 0
> .empty
display block
margin 0 auto
padding 32px
max-width 400px
text-align center
color #999
> [data-fa]
display block
margin-bottom 16px
font-size 3em
color #ccc
</style>
<script lang="typescript">
import isPromise from '../../common/scripts/is-promise';
this.mixin('api');
this.user = null;
this.userPromise = isPromise(this.opts.user)
? this.opts.user
: Promise.resolve(this.opts.user);
this.isLoading = true;
this.isEmpty = false;
this.moreLoading = false;
this.unreadCount = 0;
this.mode = 'default';
this.on('mount', () => {
document.addEventListener('keydown', this.onDocumentKeydown);
window.addEventListener('scroll', this.onScroll);
this.userPromise.then(user => {
this.update({
user: user
});
this.fetch(() => this.$emit('loaded'));
});
});
this.on('unmount', () => {
document.removeEventListener('keydown', this.onDocumentKeydown);
window.removeEventListener('scroll', this.onScroll);
});
this.onDocumentKeydown = e => {
if (e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA') {
if (e.which == 84) { // [t]
this.$refs.timeline.focus();
}
}
};
this.fetch = cb => {
this.$root.$data.os.api('users/posts', {
user_id: this.user.id,
until_date: this.date ? this.date.getTime() : undefined,
with_replies: this.mode == 'with-replies'
}).then(posts => {
this.update({
isLoading: false,
isEmpty: posts.length == 0
});
this.$refs.timeline.setPosts(posts);
if (cb) cb();
});
};
this.more = () => {
if (this.moreLoading || this.isLoading || this.$refs.timeline.posts.length == 0) return;
this.update({
moreLoading: true
});
this.$root.$data.os.api('users/posts', {
user_id: this.user.id,
with_replies: this.mode == 'with-replies',
until_id: this.$refs.timeline.tail().id
}).then(posts => {
this.update({
moreLoading: false
});
this.$refs.timeline.prependPosts(posts);
});
};
this.onScroll = () => {
const current = window.scrollY + window.innerHeight;
if (current > document.body.offsetHeight - 16/*遊び*/) {
this.more();
}
};
this.setMode = mode => {
this.update({
mode: mode
});
this.fetch();
};
this.warp = date => {
this.update({
date: date
});
this.fetch();
};
</script>
</mk-user-timeline>
This diff is collapsed.
Click to expand it.
src/web/app/desktop/views/components/user-timeline.vue
0 → 100644
+
133
−
0
View file @
7c30b94c
<
template
>
<div
class=
"mk-user-timeline"
>
<header>
<span
:data-is-active=
"mode == 'default'"
@
click=
"mode = 'default'"
>
投稿
</span>
<span
:data-is-active=
"mode == 'with-replies'"
@
click=
"mode = 'with-replies'"
>
投稿と返信
</span>
</header>
<div
class=
"loading"
v-if=
"fetching"
>
<mk-ellipsis-icon/>
</div>
<p
class=
"empty"
v-if=
"empty"
>
%fa:R comments%このユーザーはまだ何も投稿していないようです。
</p>
<mk-posts
ref=
"timeline"
:posts=
"posts"
>
<div
slot=
"footer"
>
<template
v-if=
"!moreFetching"
>
%fa:moon%
</
template
>
<
template
v-if=
"moreFetching"
>
%fa:spinner .pulse .fw%
</
template
>
</div>
</mk-posts>
</div>
</template>
<
script
lang=
"ts"
>
import
Vue
from
'
vue
'
;
export
default
Vue
.
extend
({
props
:
[
'
user
'
],
data
()
{
return
{
fetching
:
true
,
moreFetching
:
false
,
mode
:
'
default
'
,
unreadCount
:
0
,
posts
:
[],
date
:
null
};
},
watch
:
{
mode
()
{
this
.
fetch
();
}
},
computed
:
{
empty
():
boolean
{
return
this
.
posts
.
length
==
0
;
}
},
mounted
()
{
document
.
addEventListener
(
'
keydown
'
,
this
.
onDocumentKeydown
);
window
.
addEventListener
(
'
scroll
'
,
this
.
onScroll
);
this
.
fetch
(()
=>
this
.
$emit
(
'
loaded
'
));
},
beforeDestroy
()
{
document
.
removeEventListener
(
'
keydown
'
,
this
.
onDocumentKeydown
);
window
.
removeEventListener
(
'
scroll
'
,
this
.
onScroll
);
},
methods
:
{
onDocumentKeydown
(
e
)
{
if
(
e
.
target
.
tagName
!==
'
INPUT
'
&&
e
.
target
.
tagName
!==
'
TEXTAREA
'
)
{
if
(
e
.
which
==
84
)
{
// [t]
(
this
.
$refs
.
timeline
as
any
).
focus
();
}
}
},
fetch
(
cb
?)
{
this
.
$root
.
$data
.
os
.
api
(
'
users/posts
'
,
{
user_id
:
this
.
user
.
id
,
until_date
:
this
.
date
?
this
.
date
.
getTime
()
:
undefined
,
with_replies
:
this
.
mode
==
'
with-replies
'
}).
then
(
posts
=>
{
this
.
fetching
=
false
;
this
.
posts
=
posts
;
if
(
cb
)
cb
();
});
},
more
()
{
if
(
this
.
moreFetching
||
this
.
fetching
||
this
.
posts
.
length
==
0
)
return
;
this
.
moreFetching
=
true
;
this
.
$root
.
$data
.
os
.
api
(
'
users/posts
'
,
{
user_id
:
this
.
user
.
id
,
with_replies
:
this
.
mode
==
'
with-replies
'
,
until_id
:
this
.
posts
[
this
.
posts
.
length
-
1
].
id
}).
then
(
posts
=>
{
this
.
moreFetching
=
false
;
this
.
posts
=
this
.
posts
.
concat
(
posts
);
});
},
onScroll
()
{
const
current
=
window
.
scrollY
+
window
.
innerHeight
;
if
(
current
>
document
.
body
.
offsetHeight
-
16
/*遊び*/
)
{
this
.
more
();
}
}
}
});
</
script
>
<
style
lang=
"stylus"
scoped
>
.mk-user-timeline
background #fff
> header
padding 8px 16px
border-bottom solid 1px #eee
> span
margin-right 16px
line-height 27px
font-size 18px
color #555
&:not([data-is-active])
color $theme-color
cursor pointer
&:hover
text-decoration underline
> .loading
padding 64px 0
> .empty
display block
margin 0 auto
padding 32px
max-width 400px
text-align center
color #999
> [data-fa]
display block
margin-bottom 16px
font-size 3em
color #ccc
</
style
>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment