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
d3315bda
Commit
d3315bda
authored
3 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
wip: migrate paging components to composition api
parent
586c1125
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
packages/client/src/components/timeline.vue
+131
-172
131 additions, 172 deletions
packages/client/src/components/timeline.vue
packages/client/src/components/ui/pagination.vue
+5
-1
5 additions, 1 deletion
packages/client/src/components/ui/pagination.vue
with
136 additions
and
173 deletions
packages/client/src/components/timeline.vue
+
131
−
172
View file @
d3315bda
<
template
>
<XNotes
ref=
"tl"
:no-gap=
"!$store.state.showGapBetweenNotesInTimeline"
:pagination=
"pagination"
@
before=
"$emit('before')"
@
after=
"e => $emit('after', e)"
@
queue=
"
$
emit('queue', $event)"
/>
<XNotes
ref=
"tl
Component
"
:no-gap=
"!$store.state.showGapBetweenNotesInTimeline"
:pagination=
"pagination"
@
queue=
"emit('queue', $event)"
/>
</
template
>
<
script
lang=
"ts"
>
import
{
d
ef
ineComponent
,
markRaw
}
from
'
vue
'
;
<
script
lang=
"ts"
setup
>
import
{
r
ef
,
computed
,
provide
,
onUnmounted
}
from
'
vue
'
;
import
XNotes
from
'
./notes.vue
'
;
import
*
as
os
from
'
@/os
'
;
import
{
stream
}
from
'
@/stream
'
;
import
*
as
sound
from
'
@/scripts/sound
'
;
import
{
$i
}
from
'
@/account
'
;
export
default
defineComponent
({
components
:
{
XNotes
},
provide
()
{
return
{
inChannel
:
this
.
src
===
'
channel
'
};
},
props
:
{
src
:
{
type
:
String
,
required
:
true
},
list
:
{
type
:
String
,
required
:
false
},
antenna
:
{
type
:
String
,
required
:
false
},
channel
:
{
type
:
String
,
required
:
false
},
sound
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
}
},
emits
:
[
'
note
'
,
'
queue
'
,
'
before
'
,
'
after
'
],
data
()
{
return
{
connection
:
null
,
connection2
:
null
,
pagination
:
null
,
baseQuery
:
{
includeMyRenotes
:
this
.
$store
.
state
.
showMyRenotes
,
includeRenotedMyNotes
:
this
.
$store
.
state
.
showRenotedMyNotes
,
includeLocalRenotes
:
this
.
$store
.
state
.
showLocalRenotes
},
query
:
{},
date
:
null
};
},
created
()
{
const
prepend
=
note
=>
{
(
this
.
$refs
.
tl
as
any
).
prepend
(
note
);
this
.
$emit
(
'
note
'
);
if
(
this
.
sound
)
{
sound
.
play
(
note
.
userId
===
this
.
$i
.
id
?
'
noteMy
'
:
'
note
'
);
}
};
const
onUserAdded
=
()
=>
{
(
this
.
$refs
.
tl
as
any
).
reload
();
};
const
onUserRemoved
=
()
=>
{
(
this
.
$refs
.
tl
as
any
).
reload
();
};
const
onChangeFollowing
=
()
=>
{
if
(
!
this
.
$refs
.
tl
.
backed
)
{
this
.
$refs
.
tl
.
reload
();
}
};
let
endpoint
;
if
(
this
.
src
==
'
antenna
'
)
{
endpoint
=
'
antennas/notes
'
;
this
.
query
=
{
antennaId
:
this
.
antenna
};
this
.
connection
=
markRaw
(
stream
.
useChannel
(
'
antenna
'
,
{
antennaId
:
this
.
antenna
}));
this
.
connection
.
on
(
'
note
'
,
prepend
);
}
else
if
(
this
.
src
==
'
home
'
)
{
endpoint
=
'
notes/timeline
'
;
this
.
connection
=
markRaw
(
stream
.
useChannel
(
'
homeTimeline
'
));
this
.
connection
.
on
(
'
note
'
,
prepend
);
this
.
connection2
=
markRaw
(
stream
.
useChannel
(
'
main
'
));
this
.
connection2
.
on
(
'
follow
'
,
onChangeFollowing
);
this
.
connection2
.
on
(
'
unfollow
'
,
onChangeFollowing
);
}
else
if
(
this
.
src
==
'
local
'
)
{
endpoint
=
'
notes/local-timeline
'
;
this
.
connection
=
markRaw
(
stream
.
useChannel
(
'
localTimeline
'
));
this
.
connection
.
on
(
'
note
'
,
prepend
);
}
else
if
(
this
.
src
==
'
social
'
)
{
endpoint
=
'
notes/hybrid-timeline
'
;
this
.
connection
=
markRaw
(
stream
.
useChannel
(
'
hybridTimeline
'
));
this
.
connection
.
on
(
'
note
'
,
prepend
);
}
else
if
(
this
.
src
==
'
global
'
)
{
endpoint
=
'
notes/global-timeline
'
;
this
.
connection
=
markRaw
(
stream
.
useChannel
(
'
globalTimeline
'
));
this
.
connection
.
on
(
'
note
'
,
prepend
);
}
else
if
(
this
.
src
==
'
mentions
'
)
{
endpoint
=
'
notes/mentions
'
;
this
.
connection
=
markRaw
(
stream
.
useChannel
(
'
main
'
));
this
.
connection
.
on
(
'
mention
'
,
prepend
);
}
else
if
(
this
.
src
==
'
directs
'
)
{
endpoint
=
'
notes/mentions
'
;
this
.
query
=
{
visibility
:
'
specified
'
};
const
onNote
=
note
=>
{
if
(
note
.
visibility
==
'
specified
'
)
{
prepend
(
note
);
}
};
this
.
connection
=
markRaw
(
stream
.
useChannel
(
'
main
'
));
this
.
connection
.
on
(
'
mention
'
,
onNote
);
}
else
if
(
this
.
src
==
'
list
'
)
{
endpoint
=
'
notes/user-list-timeline
'
;
this
.
query
=
{
listId
:
this
.
list
};
this
.
connection
=
markRaw
(
stream
.
useChannel
(
'
userList
'
,
{
listId
:
this
.
list
}));
this
.
connection
.
on
(
'
note
'
,
prepend
);
this
.
connection
.
on
(
'
userAdded
'
,
onUserAdded
);
this
.
connection
.
on
(
'
userRemoved
'
,
onUserRemoved
);
}
else
if
(
this
.
src
==
'
channel
'
)
{
endpoint
=
'
channels/timeline
'
;
this
.
query
=
{
channelId
:
this
.
channel
};
this
.
connection
=
markRaw
(
stream
.
useChannel
(
'
channel
'
,
{
channelId
:
this
.
channel
}));
this
.
connection
.
on
(
'
note
'
,
prepend
);
}
const
props
=
defineProps
<
{
src
:
string
;
list
?:
string
;
antenna
?:
string
;
channel
?:
string
;
sound
?:
boolean
;
}
>
();
this
.
pagination
=
{
endpoint
:
endpoint
,
limit
:
10
,
params
:
init
=>
({
untilDate
:
this
.
date
?.
getTime
(),
...
this
.
baseQuery
,
...
this
.
query
})
};
},
beforeUnmount
()
{
this
.
connection
.
dispose
();
if
(
this
.
connection2
)
this
.
connection2
.
dispose
();
},
methods
:
{
focus
()
{
this
.
$refs
.
tl
.
focus
();
},
timetravel
(
date
?:
Date
)
{
this
.
date
=
date
;
this
.
$refs
.
tl
.
reload
();
}
const
emit
=
defineEmits
<
{
(
e
:
'
note
'
):
void
;
(
e
:
'
queue
'
,
count
:
number
):
void
;
}
>
();
provide
(
'
inChannel
'
,
computed
(()
=>
props
.
src
===
'
channel
'
));
const
tlComponent
=
ref
<
InstanceType
<
typeof
XNotes
>>
();
const
prepend
=
note
=>
{
tlComponent
.
value
.
prepend
(
note
);
emit
(
'
note
'
);
if
(
props
.
sound
)
{
sound
.
play
(
$i
&&
(
note
.
userId
===
$i
.
id
)
?
'
noteMy
'
:
'
note
'
);
}
};
const
onUserAdded
=
()
=>
{
tlComponent
.
value
.
reload
();
};
const
onUserRemoved
=
()
=>
{
tlComponent
.
value
.
reload
();
};
const
onChangeFollowing
=
()
=>
{
if
(
!
tlComponent
.
value
.
backed
)
{
tlComponent
.
value
.
reload
();
}
};
let
endpoint
;
let
query
;
let
connection
;
let
connection2
;
if
(
props
.
src
===
'
antenna
'
)
{
endpoint
=
'
antennas/notes
'
;
query
=
{
antennaId
:
props
.
antenna
};
connection
=
stream
.
useChannel
(
'
antenna
'
,
{
antennaId
:
props
.
antenna
});
connection
.
on
(
'
note
'
,
prepend
);
}
else
if
(
props
.
src
===
'
home
'
)
{
endpoint
=
'
notes/timeline
'
;
connection
=
stream
.
useChannel
(
'
homeTimeline
'
);
connection
.
on
(
'
note
'
,
prepend
);
connection2
=
stream
.
useChannel
(
'
main
'
);
connection2
.
on
(
'
follow
'
,
onChangeFollowing
);
connection2
.
on
(
'
unfollow
'
,
onChangeFollowing
);
}
else
if
(
props
.
src
===
'
local
'
)
{
endpoint
=
'
notes/local-timeline
'
;
connection
=
stream
.
useChannel
(
'
localTimeline
'
);
connection
.
on
(
'
note
'
,
prepend
);
}
else
if
(
props
.
src
===
'
social
'
)
{
endpoint
=
'
notes/hybrid-timeline
'
;
connection
=
stream
.
useChannel
(
'
hybridTimeline
'
);
connection
.
on
(
'
note
'
,
prepend
);
}
else
if
(
props
.
src
===
'
global
'
)
{
endpoint
=
'
notes/global-timeline
'
;
connection
=
stream
.
useChannel
(
'
globalTimeline
'
);
connection
.
on
(
'
note
'
,
prepend
);
}
else
if
(
props
.
src
===
'
mentions
'
)
{
endpoint
=
'
notes/mentions
'
;
connection
=
stream
.
useChannel
(
'
main
'
);
connection
.
on
(
'
mention
'
,
prepend
);
}
else
if
(
props
.
src
===
'
directs
'
)
{
endpoint
=
'
notes/mentions
'
;
query
=
{
visibility
:
'
specified
'
};
const
onNote
=
note
=>
{
if
(
note
.
visibility
==
'
specified
'
)
{
prepend
(
note
);
}
};
connection
=
stream
.
useChannel
(
'
main
'
);
connection
.
on
(
'
mention
'
,
onNote
);
}
else
if
(
props
.
src
===
'
list
'
)
{
endpoint
=
'
notes/user-list-timeline
'
;
query
=
{
listId
:
props
.
list
};
connection
=
stream
.
useChannel
(
'
userList
'
,
{
listId
:
props
.
list
});
connection
.
on
(
'
note
'
,
prepend
);
connection
.
on
(
'
userAdded
'
,
onUserAdded
);
connection
.
on
(
'
userRemoved
'
,
onUserRemoved
);
}
else
if
(
props
.
src
===
'
channel
'
)
{
endpoint
=
'
channels/timeline
'
;
query
=
{
channelId
:
props
.
channel
};
connection
=
stream
.
useChannel
(
'
channel
'
,
{
channelId
:
props
.
channel
});
connection
.
on
(
'
note
'
,
prepend
);
}
const
pagination
=
{
endpoint
:
endpoint
,
limit
:
10
,
params
:
query
,
};
onUnmounted
(()
=>
{
connection
.
dispose
();
if
(
connection2
)
connection2
.
dispose
();
});
/* TODO
const timetravel = (date?: Date) => {
this.date = date;
this.$refs.tl.reload();
};
*/
</
script
>
This diff is collapsed.
Click to expand it.
packages/client/src/components/ui/pagination.vue
+
5
−
1
View file @
d3315bda
...
...
@@ -59,6 +59,10 @@ const props = withDefaults(defineProps<{
displayLimit
:
30
,
});
const
emit
=
defineEmits
<
{
(
e
:
'
queue
'
,
count
:
number
):
void
;
}
>
();
const
rootEl
=
ref
<
HTMLElement
>
();
const
items
=
ref
([]);
const
queue
=
ref
([]);
...
...
@@ -235,7 +239,7 @@ const append = (item) => {
watch
(
props
.
pagination
.
params
,
init
,
{
deep
:
true
});
watch
(
queue
,
(
a
,
b
)
=>
{
if
(
a
.
length
===
0
&&
b
.
length
===
0
)
return
;
this
.
$
emit
(
'
queue
'
,
queue
.
value
.
length
);
emit
(
'
queue
'
,
queue
.
value
.
length
);
},
{
deep
:
true
});
init
();
...
...
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