Format time, fix sort (#230)

This commit is contained in:
Pranav Raj S 2019-11-21 12:02:10 +05:30 committed by GitHub
parent ba10045a0f
commit c914d94b18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 11 deletions

View file

@ -14,7 +14,7 @@ class WidgetsController < ActionController::Base
source_id: cookie_params[:source_id]
)
@contact = contact_inbox.contact
@contact = contact_inbox ? contact_inbox.contact : nil
end
def set_token

View file

@ -150,10 +150,9 @@ export default {
} else {
copyList = this.allChatList.slice();
}
const sorted = copyList.sort((a, b) =>
this.wootTime(this.lastMessage(a).created_at).isBefore(
this.wootTime(this.lastMessage(b).created_at)
)
const sorted = copyList.sort(
(a, b) =>
this.lastMessage(b).created_at - this.lastMessage(a).created_at
);
return sorted;

View file

@ -15,12 +15,7 @@ export default {
},
dynamicTime(time) {
const createdAt = moment(time * 1000);
return createdAt.calendar(null, {
sameDay: 'h:mm A',
lastDay: '[Yesterday]',
lastWeek: 'ddd',
sameElse: 'D MMM',
});
return createdAt.fromNow();
},
},
};