From 9b1ebaae912b7ce950f14cd96348a2e1dd4f7c3b Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 5 Jul 2017 14:18:26 -0400 Subject: [PATCH] Remove long deprecated code --- .../extend-for-solved-button.js.es6 | 59 +------------------ 1 file changed, 3 insertions(+), 56 deletions(-) diff --git a/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 b/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 index 52b5a7d..cb24154 100644 --- a/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 +++ b/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 @@ -4,7 +4,7 @@ import TopicStatus from 'discourse/raw-views/topic-status'; import { popupAjaxError } from 'discourse/lib/ajax-error'; import { withPluginApi } from 'discourse/lib/plugin-api'; import { ajax } from 'discourse/lib/ajax'; -import PostCooked from 'discourse/widgets/post-cooked' +import PostCooked from 'discourse/widgets/post-cooked'; function clearAccepted(topic) { const posts = topic.get('postStream.posts'); @@ -57,59 +57,6 @@ function acceptPost(post) { }).catch(popupAjaxError); } -// Code for older discourse installs for backwards compatibility -function oldPluginCode() { - const PostView = require('discourse/views/post').default; - PostView.reopen({ - classNameBindings: ['post.accepted_answer:accepted-answer'] - }); - - const module = require( 'discourse/components/post-menu'); - const PostMenuComponent = module.default; - const Button = module.Button; - PostMenuComponent.registerButton(function(visibleButtons){ - var position = 0; - - var canAccept = this.get('post.can_accept_answer'); - var canUnaccept = this.get('post.can_unaccept_answer'); - var accepted = this.get('post.accepted_answer'); - var isOp = Discourse.User.currentProp("id") === this.get('post.topic.user_id'); - - if (!accepted && canAccept && !isOp) { - // first hidden position - if (this.get('collapsed')) { return; } - position = visibleButtons.length - 2; - } - if (canAccept) { - visibleButtons.splice(position,0,new Button('acceptAnswer', 'solved.accept_answer', 'check-square-o', {className: 'unaccepted'})); - } - if (canUnaccept || accepted) { - var locale = canUnaccept ? 'solved.unaccept_answer' : 'solved.accepted_answer'; - visibleButtons.splice(position,0,new Button( - 'unacceptAnswer', - locale, - 'check-square', - {className: 'accepted fade-out', prefixHTML: '' + I18n.t('solved.solution') + ''}) - ); - } - - }); - - PostMenuComponent.reopen({ - acceptedChanged: function() { - this.rerender(); - }.observes('post.accepted_answer'), - - clickUnacceptAnswer() { - unacceptPost(this.get('post')); - }, - - clickAcceptAnswer() { - acceptPost(this.get('post')); - } - }); -} - function initializeWithApi(api) { const currentUser = api.getCurrentUser(); @@ -164,7 +111,7 @@ function initializeWithApi(api) {
${topic.get('accepted_answer').excerpt}
- ` + `; var cooked = new PostCooked({cooked:rawhtml}); @@ -256,6 +203,6 @@ export default { }.property() }); - withPluginApi('0.1', initializeWithApi, { noApi: oldPluginCode }); + withPluginApi('0.1', initializeWithApi); } };