瀏覽代碼

Move ConnectionFeedback model to its own file

JC Brand 2 年之前
父節點
當前提交
6df80507f3
共有 3 個文件被更改,包括 18 次插入15 次删除
  1. 0 13
      src/headless/core.js
  2. 3 2
      src/headless/shared/api/public.js
  3. 15 0
      src/headless/shared/connection/feedback.js

+ 0 - 13
src/headless/core.js

@@ -8,8 +8,6 @@ import advancedFormat from 'dayjs/plugin/advancedFormat';
 import connection_api from './shared/connection/api.js';
 import dayjs from 'dayjs';
 import i18n from './shared/i18n';
-import { Model } from '@converse/skeletor/src/model.js';
-import { Strophe } from 'strophe.js/src/strophe';
 import { settings_api } from './shared/settings/api.js';
 import send_api from './shared/api/send.js';
 import user_api from './shared/api/user.js';
@@ -50,14 +48,3 @@ _converse.shouldClearCache = () => (
     api.settings.get('clear_cache_on_logout') ||
     _converse.isTestEnv()
 );
-
-
-_converse.ConnectionFeedback = Model.extend({
-    defaults: {
-        'connection_status': Strophe.Status.DISCONNECTED,
-        'message': ''
-    },
-    initialize () {
-        this.on('change', () => api.trigger('connfeedback', _converse.connfeedback));
-    }
-});

+ 3 - 2
src/headless/shared/api/public.js

@@ -1,7 +1,8 @@
+import ConnectionFeedback from './../connection/feedback.js';
 import URI from 'urijs';
-import i18n from '../i18n';
 import _converse from '../_converse.js';
 import dayjs from 'dayjs';
+import i18n from '../i18n';
 import invoke from 'lodash-es/invoke';
 import log from '../../log.js';
 import sizzle from 'sizzle';
@@ -81,7 +82,7 @@ export const converse = Object.assign(window.converse || {}, {
             /^converse\?loglevel=(debug|info|warn|error|fatal)$/, 'loglevel',
             l => log.setLogLevel(l)
         );
-        _converse.connfeedback = new _converse.ConnectionFeedback();
+        _converse.connfeedback = new ConnectionFeedback();
 
         /* When reloading the page:
          * For new sessions, we need to send out a presence stanza to notify

+ 15 - 0
src/headless/shared/connection/feedback.js

@@ -0,0 +1,15 @@
+import _converse from '../_converse';
+import { Model } from '@converse/skeletor/src/model.js';
+import { Strophe } from 'strophe.js/src/strophe';
+
+export default Model.extend({
+    defaults: {
+        'connection_status': Strophe.Status.DISCONNECTED,
+        'message': ''
+    },
+
+    initialize () {
+        const { api } = _converse;
+        this.on('change', () => api.trigger('connfeedback', _converse.connfeedback));
+    }
+});