[Client] Refactoring

This commit is contained in:
syuilo
2017-03-20 14:49:24 +09:00
parent 431da9e087
commit b6475958d0
19 changed files with 72 additions and 102 deletions

View File

@@ -159,8 +159,6 @@
this.mixin('api');
this.mixin('stream');
const stream = this.stream.event;
this.files = [];
this.folders = [];
this.hierarchyFolders = [];
@@ -176,10 +174,10 @@
this.multiple =this.opts.multiple;
this.on('mount', () => {
stream.on('drive_file_created', this.onStreamDriveFileCreated);
stream.on('drive_file_updated', this.onStreamDriveFileUpdated);
stream.on('drive_folder_created', this.onStreamDriveFolderCreated);
stream.on('drive_folder_updated', this.onStreamDriveFolderUpdated);
this.stream.on('drive_file_created', this.onStreamDriveFileCreated);
this.stream.on('drive_file_updated', this.onStreamDriveFileUpdated);
this.stream.on('drive_folder_created', this.onStreamDriveFolderCreated);
this.stream.on('drive_folder_updated', this.onStreamDriveFolderUpdated);
// Riotのバグでnullを渡しても""になる
// https://github.com/riot/riot/issues/2080
@@ -195,10 +193,10 @@
});
this.on('unmount', () => {
stream.off('drive_file_created', this.onStreamDriveFileCreated);
stream.off('drive_file_updated', this.onStreamDriveFileUpdated);
stream.off('drive_folder_created', this.onStreamDriveFolderCreated);
stream.off('drive_folder_updated', this.onStreamDriveFolderUpdated);
this.stream.off('drive_file_created', this.onStreamDriveFileCreated);
this.stream.off('drive_file_updated', this.onStreamDriveFileUpdated);
this.stream.off('drive_folder_created', this.onStreamDriveFolderCreated);
this.stream.off('drive_folder_updated', this.onStreamDriveFolderUpdated);
});
this.onStreamDriveFileCreated = file => {

View File

@@ -54,8 +54,6 @@
this.mixin('api');
this.mixin('stream');
const stream = this.stream.event;
this.user = null;
this.userPromise = isPromise(this.opts.user)
? this.opts.user
@@ -69,14 +67,14 @@
init: false,
user: user
});
stream.on('follow', this.onStreamFollow);
stream.on('unfollow', this.onStreamUnfollow);
this.stream.on('follow', this.onStreamFollow);
this.stream.on('unfollow', this.onStreamUnfollow);
});
});
this.on('unmount', () => {
stream.off('follow', this.onStreamFollow);
stream.off('unfollow', this.onStreamUnfollow);
this.stream.off('follow', this.onStreamFollow);
this.stream.off('unfollow', this.onStreamUnfollow);
});
this.onStreamFollow = user => {

View File

@@ -9,8 +9,6 @@
this.mixin('api');
this.mixin('stream');
const stream = this.stream.event;
this.init = new Promise((res, rej) => {
this.api('posts/timeline').then(posts => {
res(posts);
@@ -19,15 +17,15 @@
});
this.on('mount', () => {
stream.on('post', this.onStreamPost);
stream.on('follow', this.onStreamFollow);
stream.on('unfollow', this.onStreamUnfollow);
this.stream.on('post', this.onStreamPost);
this.stream.on('follow', this.onStreamFollow);
this.stream.on('unfollow', this.onStreamUnfollow);
});
this.on('unmount', () => {
stream.off('post', this.onStreamPost);
stream.off('follow', this.onStreamFollow);
stream.off('unfollow', this.onStreamUnfollow);
this.stream.off('post', this.onStreamPost);
this.stream.off('follow', this.onStreamFollow);
this.stream.off('unfollow', this.onStreamUnfollow);
});
this.more = () => {

View File

@@ -63,8 +63,6 @@
this.mixin('api');
this.mixin('stream');
const stream = this.stream.event;
this.notifications = [];
this.loading = true;
@@ -78,11 +76,11 @@
this.trigger('fetched');
});
stream.on('notification', this.onNotification);
this.stream.on('notification', this.onNotification);
});
this.on('unmount', () => {
stream.off('notification', this.onNotification);
this.stream.off('notification', this.onNotification);
});
this.onNotification = notification => {

View File

@@ -15,8 +15,6 @@
this.mixin('i');
this.mixin('stream');
const stream = this.stream.event;
this.unreadCount = 0;
this.on('mount', () => {
@@ -29,7 +27,7 @@
Progress.start();
stream.on('post', this.onStreamPost);
this.stream.on('post', this.onStreamPost);
document.addEventListener('visibilitychange', this.onVisibilitychange, false);
this.refs.ui.refs.home.on('loaded', () => {
@@ -38,7 +36,7 @@
});
this.on('unmount', () => {
stream.off('post', this.onStreamPost);
this.stream.off('post', this.onStreamPost);
document.removeEventListener('visibilitychange', this.onVisibilitychange);
});

View File

@@ -345,7 +345,7 @@
type: 'capture',
id: this.p.id
});
this.stream.event.on('post-updated', this.onStreamPostUpdated);
this.stream.on('post-updated', this.onStreamPostUpdated);
};
this.decapture = () => {
@@ -353,7 +353,7 @@
type: 'decapture',
id: this.p.id
});
this.stream.event.off('post-updated', this.onStreamPostUpdated);
this.stream.off('post-updated', this.onStreamPostUpdated);
};
this.on('mount', () => {

View File

@@ -12,19 +12,16 @@
</style>
<script>
this.mixin('i');
this.mixin('stream');
const stream = this.stream.event;
this.isDrawerOpening = false;
this.on('mount', () => {
stream.on('notification', this.onStreamNotification);
this.stream.on('notification', this.onStreamNotification);
});
this.on('unmount', () => {
stream.off('notification', this.onStreamNotification);
this.stream.off('notification', this.onStreamNotification);
});
this.toggleDrawer = () => {