wip
This commit is contained in:
parent
5efb52b9f5
commit
f87ec61e96
|
@ -484,6 +484,9 @@ const endpoints: Endpoint[] = [
|
||||||
minInterval: ms('10seconds')
|
minInterval: ms('10seconds')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'channels/show'
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default endpoints;
|
export default endpoints;
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
* Module dependencies
|
||||||
|
*/
|
||||||
|
import $ from 'cafy';
|
||||||
|
import { default as Channel, IChannel } from '../../models/channel';
|
||||||
|
import serialize from '../../serializers/channel';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a channel
|
||||||
|
*
|
||||||
|
* @param {any} params
|
||||||
|
* @param {any} user
|
||||||
|
* @return {Promise<any>}
|
||||||
|
*/
|
||||||
|
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
// Get 'channel_id' parameter
|
||||||
|
const [channelId, channelIdErr] = $(params.channel_id).id().$;
|
||||||
|
if (channelIdErr) return rej('invalid channel_id param');
|
||||||
|
|
||||||
|
// Fetch channel
|
||||||
|
const channel: IChannel = await Channel.findOne({
|
||||||
|
_id: channelId
|
||||||
|
});
|
||||||
|
|
||||||
|
if (channel === null) {
|
||||||
|
return rej('channel not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Serialize
|
||||||
|
res(await serialize(channel, user));
|
||||||
|
});
|
|
@ -7,15 +7,16 @@ const route = require('page');
|
||||||
let page = null;
|
let page = null;
|
||||||
|
|
||||||
export default me => {
|
export default me => {
|
||||||
route('/', index);
|
route('/', index);
|
||||||
route('/i>mentions', mentions);
|
route('/i>mentions', mentions);
|
||||||
route('/channel', channels);
|
route('/channel', channels);
|
||||||
route('/post::post', post);
|
route('/channel/:channel', channel);
|
||||||
route('/search::query', search);
|
route('/post::post', post);
|
||||||
route('/:user', user.bind(null, 'home'));
|
route('/search::query', search);
|
||||||
route('/:user/graphs', user.bind(null, 'graphs'));
|
route('/:user', user.bind(null, 'home'));
|
||||||
route('/:user/:post', post);
|
route('/:user/graphs', user.bind(null, 'graphs'));
|
||||||
route('*', notFound);
|
route('/:user/:post', post);
|
||||||
|
route('*', notFound);
|
||||||
|
|
||||||
function index() {
|
function index() {
|
||||||
me ? home() : entrance();
|
me ? home() : entrance();
|
||||||
|
@ -55,6 +56,12 @@ export default me => {
|
||||||
mount(el);
|
mount(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function channel(ctx) {
|
||||||
|
const el = document.createElement('mk-channel-page');
|
||||||
|
el.setAttribute('id', ctx.params.channel);
|
||||||
|
mount(el);
|
||||||
|
}
|
||||||
|
|
||||||
function channels() {
|
function channels() {
|
||||||
mount(document.createElement('mk-channels-page'));
|
mount(document.createElement('mk-channels-page'));
|
||||||
}
|
}
|
||||||
|
@ -72,6 +79,7 @@ export default me => {
|
||||||
};
|
};
|
||||||
|
|
||||||
function mount(content) {
|
function mount(content) {
|
||||||
|
document.documentElement.style.background = '#313a42';
|
||||||
document.documentElement.removeAttribute('data-page');
|
document.documentElement.removeAttribute('data-page');
|
||||||
if (page) page.unmount();
|
if (page) page.unmount();
|
||||||
const body = document.getElementById('app');
|
const body = document.getElementById('app');
|
||||||
|
|
|
@ -61,6 +61,7 @@ require('./pages/user.tag');
|
||||||
require('./pages/post.tag');
|
require('./pages/post.tag');
|
||||||
require('./pages/search.tag');
|
require('./pages/search.tag');
|
||||||
require('./pages/not-found.tag');
|
require('./pages/not-found.tag');
|
||||||
|
require('./pages/channel.tag');
|
||||||
require('./pages/channels.tag');
|
require('./pages/channels.tag');
|
||||||
require('./autocomplete-suggestion.tag');
|
require('./autocomplete-suggestion.tag');
|
||||||
require('./progress-dialog.tag');
|
require('./progress-dialog.tag');
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
<mk-channel-page>
|
||||||
|
<mk-ui ref="ui">
|
||||||
|
<main if={ !parent.fetching }>
|
||||||
|
<h1>{ parent.channel.title }</h1>
|
||||||
|
</main>
|
||||||
|
</mk-ui>
|
||||||
|
<style>
|
||||||
|
:scope
|
||||||
|
display block
|
||||||
|
|
||||||
|
main
|
||||||
|
> h1
|
||||||
|
color #f00
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
import Progress from '../../../common/scripts/loading';
|
||||||
|
|
||||||
|
this.mixin('api');
|
||||||
|
|
||||||
|
this.id = this.opts.id;
|
||||||
|
this.fetching = true;
|
||||||
|
this.channel = null;
|
||||||
|
|
||||||
|
this.on('mount', () => {
|
||||||
|
document.documentElement.style.background = '#efefef';
|
||||||
|
|
||||||
|
Progress.start();
|
||||||
|
|
||||||
|
this.api('channels/show', {
|
||||||
|
channel_id: this.id
|
||||||
|
}).then(channel => {
|
||||||
|
Progress.done();
|
||||||
|
|
||||||
|
this.update({
|
||||||
|
fetching: false,
|
||||||
|
channel: channel
|
||||||
|
});
|
||||||
|
|
||||||
|
document.title = channel.title + ' | Misskey'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</mk-channel-page>
|
|
@ -18,7 +18,7 @@
|
||||||
this.new = () => {
|
this.new = () => {
|
||||||
const title = window.prompt('%i18n:desktop.tags.mk-channels-page.channel-title%');
|
const title = window.prompt('%i18n:desktop.tags.mk-channels-page.channel-title%');
|
||||||
|
|
||||||
this.api('bbs/channels/create', {
|
this.api('channels/create', {
|
||||||
title: title
|
title: title
|
||||||
}).then(channel => {
|
}).then(channel => {
|
||||||
location.href = '/channel/' + channel.id;
|
location.href = '/channel/' + channel.id;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
this.refs.ui.refs.user.on('user-fetched', user => {
|
this.refs.ui.refs.user.on('user-fetched', user => {
|
||||||
Progress.set(0.5);
|
Progress.set(0.5);
|
||||||
document.title = user.name + ' | Misskey'
|
document.title = user.name + ' | Misskey';
|
||||||
});
|
});
|
||||||
|
|
||||||
this.refs.ui.refs.user.on('loaded', () => {
|
this.refs.ui.refs.user.on('loaded', () => {
|
||||||
|
|
Loading…
Reference in New Issue