Skip to content

Commit 4fd4b0d

Browse files
committed
Fixes #3824
Currently there are two different instances of DayJS. One in `@converse/headless`, imported in `src/headless/shared/api/public.js` and another in the UI code, which comes in via the dynamic import of the DayJS locale. The bug was that the locale was being set for the UI-code DayJS, but it should be set for the headless one. The UI-code DayJS is part of the dynamic import of the locale, but is otherwise not used. It would of course be nice to have only one instance, but I'm not sure how this can be achieved while keeping dynamic imports of DayJS translations in the UI-code.
1 parent 8c206ad commit 4fd4b0d

File tree

20 files changed

+67
-69
lines changed

20 files changed

+67
-69
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Next release
44

5+
- #3824: Dates and times are not translated
56
- #3829: Rich text from LibreOffice Calc is sent as screenshots
67
- #3830: The message textarea blocks undo of the pasted text
78
- #3863: Shift `unescapeHTML` helper function (used to set `isOnlyEmoji` on a message) to converse-headless

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@
138138
"@converse/log": "file:src/log",
139139
"bootstrap": "^5.3.3",
140140
"client-compress": "^2.2.2",
141-
"dayjs": "^1.11.8",
142141
"dompurify": "^3.0.8",
143142
"favico.js-slevomat": "^0.3.11",
144143
"gifuct-js": "^2.1.2",

src/headless/index.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
import dayjs from 'dayjs';
2-
import advancedFormat from 'dayjs/plugin/advancedFormat';
3-
import localizedFormat from 'dayjs/plugin/localizedFormat';
4-
51
import log from '@converse/log';
6-
7-
dayjs.extend(advancedFormat);
8-
dayjs.extend(localizedFormat);
9-
102
import { _converse, api, constants as shared_constants, i18n, parsers } from './shared/index.js';
113
import u from './utils/index.js';
124
import converse from './shared/api/public.js';

src/headless/plugins/chat/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export default {
143143
}
144144
if (jids === undefined) {
145145
const chats = await api.chatboxes.get();
146-
return chats.filter(c => (c.get('type') === PRIVATE_CHAT_TYPE));
146+
return chats?.filter(c => (c.get('type') === PRIVATE_CHAT_TYPE)) ?? [];
147147
} else if (typeof jids === 'string') {
148148
return _get(jids);
149149
}

src/headless/plugins/chat/parsers.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import _converse from '../../shared/_converse.js';
55
import api from '../../shared/api/index.js';
66
import converse from '../../shared/api/public.js';
7-
import dayjs from 'dayjs';
87
import log from "@converse/log";
98
import u from '../../utils/index.js';
109
import { rejectMessage } from '../../shared/actions.js';
@@ -29,7 +28,7 @@ import {
2928
throwErrorIfInvalidForward,
3029
} from '../../shared/parsers';
3130

32-
const { Strophe, sizzle } = converse.env;
31+
const { Strophe, dayjs, sizzle } = converse.env;
3332

3433
/**
3534
* Parses a passed in message stanza and returns an object of attributes.

src/headless/plugins/headlines/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default {
4545

4646
if (jids === undefined) {
4747
const chats = await api.chatboxes.get();
48-
return chats.filter(c => (c.get('type') === HEADLINES_TYPE));
48+
return chats?.filter(c => (c.get('type') === HEADLINES_TYPE)) ?? [];
4949
} else if (typeof jids === 'string') {
5050
return _get(jids);
5151
}

src/headless/plugins/mam/api.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
import sizzle from "sizzle";
2+
import { Strophe, Stanza } from 'strophe.js';
3+
import log from "@converse/log";
14
import _converse from '../../shared/_converse.js';
25
import api from '../../shared/api/index.js';
36
import converse from '../../shared/api/public.js';
4-
import dayjs from 'dayjs';
5-
import log from "@converse/log";
6-
import sizzle from "sizzle";
77
import { RSM } from '../../shared/rsm.js';
8-
import { Strophe, Stanza } from 'strophe.js';
98
import { TimeoutError } from '../../shared/errors.js';
109

1110
const { NS } = Strophe;
12-
const { stx, u } = converse.env;
11+
const { dayjs, stx, u } = converse.env;
1312

1413

1514
export default {

src/headless/plugins/muc/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ const rooms = {
161161
}
162162
if (jids === undefined) {
163163
const chats = await chatboxes.get();
164-
return chats.filter((c) => c.get('type') === CHATROOMS_TYPE);
164+
return chats?.filter((c) => c.get('type') === CHATROOMS_TYPE) ?? [];
165165
} else if (typeof jids === 'string') {
166166
return _get(jids);
167167
}

src/headless/plugins/muc/parsers.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* @typedef {import('../muc/muc.js').default} MUC
44
* @typedef {import('./types').MUCMessageAttributes} MUCMessageAttributes
55
*/
6-
import dayjs from 'dayjs';
76
import _converse from '../../shared/_converse.js';
87
import api from '../../shared/api/index.js';
98
import converse from '../../shared/api/public.js';
@@ -29,7 +28,7 @@ import {
2928
} from '../../shared/parsers';
3029
import { STATUS_CODE_STANZAS } from './constants.js';
3130

32-
const { Strophe, sizzle, u } = converse.env;
31+
const { Strophe, dayjs, sizzle, u } = converse.env;
3332
const { NS } = Strophe;
3433

3534
/**

0 commit comments

Comments
 (0)