Skip to content

Commit

Permalink
Fixes #3243
Browse files Browse the repository at this point in the history
Use relative imports and import the `api` before `_converse`.
  • Loading branch information
jcbrand committed Aug 7, 2023
1 parent e001a10 commit 8404cb4
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/headless/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './shared/constants.js';
import _converse from './shared/_converse';
import advancedFormat from 'dayjs/plugin/advancedFormat';
import api from './shared/api/index.js';
import _converse from './shared/_converse';
import dayjs from 'dayjs';
import i18n from './shared/i18n';
import { converse } from './shared/api/public.js';
Expand Down
2 changes: 1 addition & 1 deletion src/headless/plugins/chat/model-with-contact.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import api from "../../shared/api/index.js";
import { Model } from '@converse/skeletor/src/model.js';
import { api } from "../../index.js";
import { getOpenPromise } from '@converse/openpromise';

const ModelWithContact = Model.extend({
Expand Down
3 changes: 2 additions & 1 deletion src/headless/plugins/headlines/feed.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ChatBox from '@converse/headless/plugins/chat/model.js';
import { _converse, api } from '../../index.js';
import api from "../../shared/api/index.js";
import { _converse } from '../../index.js';


export default class HeadlinesFeed extends ChatBox {
Expand Down
8 changes: 4 additions & 4 deletions src/headless/shared/api/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import connection_api from '../connection/api.js';
import events_api from '../api/events.js';
import promise_api from '../api/promise.js';
import send_api from '../api/send.js';
import user_api from '../api/user.js';
import events_api from './events.js';
import promise_api from './promise.js';
import send_api from './send.js';
import user_api from './user.js';
import { settings_api } from '../settings/api.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/headless/shared/api/promise.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _converse from '@converse/headless/shared/_converse.js';
import _converse from '../_converse.js';
import { getOpenPromise } from '@converse/openpromise';
import { waitUntil, isFunction } from '../../utils/core.js';

Expand Down
2 changes: 1 addition & 1 deletion src/headless/shared/api/send.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _converse from '../../shared/_converse.js';
import _converse from '../_converse.js';
import log from '../../log.js';
import { Strophe } from 'strophe.js';
import { TimeoutError } from '../errors.js';
Expand Down
2 changes: 1 addition & 1 deletion src/headless/shared/connection/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _converse from '@converse/headless/shared/_converse.js';
import _converse from '../_converse.js';
import { Strophe } from 'strophe.js';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/headless/shared/settings/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import log from '@converse/headless/log.js';
import log from '../../log.js';
import {
clearUserSettings,
extendAppSettings,
Expand All @@ -8,7 +8,7 @@ import {
unregisterListener,
updateAppSettings,
updateUserSettings,
} from '@converse/headless/shared/settings/utils.js';
} from './utils.js';

/**
* This grouping allows access to the
Expand Down
4 changes: 2 additions & 2 deletions src/headless/shared/settings/utils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { _converse } from '@converse/headless';
import _converse from '../_converse.js';
import isEqual from "lodash-es/isEqual.js";
import log from '@converse/headless/log';
import pick from 'lodash-es/pick';
import u from '@converse/headless/utils/core';
import { DEFAULT_SETTINGS } from './constants.js';
import { Events } from '@converse/skeletor/src/events.js';
import { Model } from '@converse/skeletor/src/model.js';
import { initStorage } from '@converse/headless/utils/storage.js';
import { initStorage } from '../../utils/storage.js';

let app_settings;
let init_settings = {}; // Container for settings passed in via converse.initialize
Expand Down
7 changes: 4 additions & 3 deletions src/headless/utils/storage.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import Storage from '@converse/skeletor/src/storage.js';
import { _converse, api } from '@converse/headless';
import _converse from '../shared/_converse.js';
import { settings_api } from '../shared/settings/api.js';

export function getDefaultStore () {
if (_converse.config.get('trusted')) {
const is_non_persistent = api.settings.get('persistent_store') === 'sessionStorage';
const is_non_persistent = settings_api.get('persistent_store') === 'sessionStorage';
return is_non_persistent ? 'session': 'persistent';
} else {
return 'session';
}
}

function storeUsesIndexedDB (store) {
return store === 'persistent' && api.settings.get('persistent_store') === 'IndexedDB';
return store === 'persistent' && settings_api.get('persistent_store') === 'IndexedDB';
}

export function createStore (id, store) {
Expand Down
6 changes: 4 additions & 2 deletions src/shared/registry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import api from "@converse/headless/shared/api/index.js";
import { api } from "@converse/headless";

const registry = {};

Expand All @@ -8,7 +8,7 @@ const registry = {};
* @namespace api.elements
* @memberOf api
*/
api.elements = {
const elements = {
registry,

/**
Expand Down Expand Up @@ -41,3 +41,5 @@ api.elements = {
});
}
}

Object.assign(api, { elements });

0 comments on commit 8404cb4

Please sign in to comment.