diff --git a/.eslintrc.json b/.eslintrc.json index 380533a79a..fa5f394975 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -281,7 +281,6 @@ "timerender": false, "todo_widget": false, "top_left_corner": false, - "topic_generator": false, "topic_list": false, "topic_zoom": false, "transmit": false, diff --git a/static/js/bundles/app.js b/static/js/bundles/app.js index c970c8284d..d5c3d20315 100644 --- a/static/js/bundles/app.js +++ b/static/js/bundles/app.js @@ -39,7 +39,6 @@ import "../topic_list"; import "../pm_list_dom"; import "../pm_list"; import "../recent_senders"; -import "../topic_generator"; import "../top_left_corner"; import "../stream_list"; import "../topic_zoom"; diff --git a/static/js/global.d.ts b/static/js/global.d.ts index 92eea642ff..40801b8739 100644 --- a/static/js/global.d.ts +++ b/static/js/global.d.ts @@ -146,7 +146,6 @@ declare let templates: any; declare let timerender: any; declare let todo_widget: any; declare let stream_topic_history: any; -declare let topic_generator: any; declare let topic_list: any; declare let topic_zoom: any; declare let top_left_corner: any; diff --git a/static/js/narrow.js b/static/js/narrow.js index 59b9e5867e..99e30ffca6 100644 --- a/static/js/narrow.js +++ b/static/js/narrow.js @@ -1,6 +1,7 @@ "use strict"; const people = require("./people"); +const topic_generator = require("./topic_generator"); const util = require("./util"); let unnarrow_times; diff --git a/static/js/topic_generator.js b/static/js/topic_generator.js index b34c2d850e..a2f06daa16 100644 --- a/static/js/topic_generator.js +++ b/static/js/topic_generator.js @@ -1,9 +1,7 @@ -"use strict"; +import * as pm_conversations from "./pm_conversations"; +import * as stream_sort from "./stream_sort"; -const pm_conversations = require("./pm_conversations"); -const stream_sort = require("./stream_sort"); - -exports.next_topic = function (streams, get_topics, has_unread_messages, curr_stream, curr_topic) { +export function next_topic(streams, get_topics, has_unread_messages, curr_stream, curr_topic) { const curr_stream_index = streams.indexOf(curr_stream); // -1 if not found if (curr_stream_index >= 0) { @@ -45,9 +43,9 @@ exports.next_topic = function (streams, get_topics, has_unread_messages, curr_st } return undefined; -}; +} -exports.get_next_topic = function (curr_stream, curr_topic) { +export function get_next_topic(curr_stream, curr_topic) { let my_streams = stream_sort.get_streams(); my_streams = my_streams.filter((stream_name) => { @@ -74,16 +72,10 @@ exports.get_next_topic = function (curr_stream, curr_topic) { return unread.topic_has_any_unread(stream_id, topic); } - return exports.next_topic( - my_streams, - get_unmuted_topics, - has_unread_messages, - curr_stream, - curr_topic, - ); -}; + return next_topic(my_streams, get_unmuted_topics, has_unread_messages, curr_stream, curr_topic); +} -exports.get_next_unread_pm_string = function (curr_pm) { +export function get_next_unread_pm_string(curr_pm) { const my_pm_strings = pm_conversations.recent.get_strings(); const curr_pm_index = my_pm_strings.indexOf(curr_pm); // -1 if not found @@ -100,9 +92,9 @@ exports.get_next_unread_pm_string = function (curr_pm) { } return undefined; -}; +} -exports.get_next_stream = function (curr_stream) { +export function get_next_stream(curr_stream) { const my_streams = stream_sort.get_streams(); const curr_stream_index = my_streams.indexOf(curr_stream); return my_streams[ @@ -110,12 +102,10 @@ exports.get_next_stream = function (curr_stream) { ? 0 : curr_stream_index + 1 ]; -}; +} -exports.get_prev_stream = function (curr_stream) { +export function get_prev_stream(curr_stream) { const my_streams = stream_sort.get_streams(); const curr_stream_index = my_streams.indexOf(curr_stream); return my_streams[curr_stream_index <= 0 ? my_streams.length - 1 : curr_stream_index - 1]; -}; - -window.topic_generator = exports; +}