debian-mirror-gitlab/app/assets/javascripts/notes/components/discussion_navigator.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.2 KiB
Vue
Raw Normal View History

2019-10-12 21:52:04 +05:30
<script>
/* global Mousetrap */
import 'mousetrap';
2022-10-11 01:57:18 +05:30
import { throttle } from 'lodash';
2021-04-29 21:17:54 +05:30
import {
keysFor,
MR_NEXT_UNRESOLVED_DISCUSSION,
MR_PREVIOUS_UNRESOLVED_DISCUSSION,
} from '~/behaviors/shortcuts/keybindings';
2020-10-24 23:57:45 +05:30
import eventHub from '~/notes/event_hub';
2021-03-11 19:13:27 +05:30
import discussionNavigation from '~/notes/mixins/discussion_navigation';
2019-10-12 21:52:04 +05:30
export default {
mixins: [discussionNavigation],
2022-10-11 01:57:18 +05:30
data() {
return {
jumpToNext: throttle(() => this.jumpToNextDiscussion({ behavior: 'auto' }), 200),
jumpToPrevious: throttle(() => this.jumpToPreviousDiscussion({ behavior: 'auto' }), 200),
};
},
2020-10-24 23:57:45 +05:30
created() {
eventHub.$on('jumpToFirstUnresolvedDiscussion', this.jumpToFirstUnresolvedDiscussion);
},
2019-10-12 21:52:04 +05:30
mounted() {
2022-10-11 01:57:18 +05:30
Mousetrap.bind(keysFor(MR_NEXT_UNRESOLVED_DISCUSSION), this.jumpToNext);
Mousetrap.bind(keysFor(MR_PREVIOUS_UNRESOLVED_DISCUSSION), this.jumpToPrevious);
2019-10-12 21:52:04 +05:30
},
beforeDestroy() {
2021-04-29 21:17:54 +05:30
Mousetrap.unbind(keysFor(MR_NEXT_UNRESOLVED_DISCUSSION));
Mousetrap.unbind(keysFor(MR_PREVIOUS_UNRESOLVED_DISCUSSION));
2020-10-24 23:57:45 +05:30
eventHub.$off('jumpToFirstUnresolvedDiscussion', this.jumpToFirstUnresolvedDiscussion);
2019-10-12 21:52:04 +05:30
},
render() {
2022-08-13 15:12:31 +05:30
return this.$scopedSlots.default?.();
2019-10-12 21:52:04 +05:30
},
};
</script>