Skip to content

Commit 0eaaf04

Browse files
committed
Revert "Merge branch 'lazyload'"
This reverts commit d78738e, reversing changes made to 186a60b.
1 parent d38962c commit 0eaaf04

File tree

3 files changed

+9
-23
lines changed

3 files changed

+9
-23
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ A full example of how to use it, is the following:
3434
// fetch tips from somewhere..
3535

3636
// init RandomTips
37-
RandomTips.init("/common/modules/data/Tips.js").then(() => {
37+
RandomTips.init(tips).then(() => {
3838
RandomTips.setContext("options");
3939
RandomTips.showRandomTipIfWanted();
4040
});
4141
```
4242

4343
This does the following steps:
44-
1. Initializes the module with the path to list of all tips (the [tip data](#specifying-tips)). They are loaded automatically.
44+
1. Initializes the module with the list of all tips (the [tip data](#specifying-tips)).
4545
2. When they are loaded, sets a specific [context](#context), which allows you to show some tips only in some "contexts".
4646
3. Shows a tip with a chance of 20%, so on average only in 1 of 5 triggers of this function, a tip is shown.
4747

RandomTips.js

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ const DEFAULT_TIP_CONFIG = Object.freeze({
6666
});
6767

6868
/**
69-
* is a string if not initialized/loaded yet
70-
*
7169
* @private
72-
* @type {TipObject[]|string}
70+
* @type {TipObject[]}
7371
* @see {@link tips}
7472
*/
7573
let tips;
@@ -294,15 +292,6 @@ export function setContext(newContext) {
294292
* @returns {Promise}
295293
*/
296294
export async function showRandomTip() {
297-
// load tips if not already loaded
298-
if (!tips || !Array.isArray(tips)) {
299-
const tipsToShow = import(tips); // ES6 dynamic modules, requires Firefoy >= 67
300-
301-
// use local shallow copy, so we can modify it
302-
// inner objects won't be modified, so we do not need to deep-clone it.
303-
tips = tipsToShow.slice();
304-
}
305-
306295
// only try to select tip, if one is even available
307296
if (tips.length === 0) {
308297
console.info("no tips to show available anymore");
@@ -351,16 +340,13 @@ export function showRandomTipIfWanted() {
351340
* Initialises the module.
352341
*
353342
* @public
354-
* @param {TipObject[]|string} [tipsToShow="/common/modules/data/Tips.js"]
355-
* optionally, the tips object to init
356-
* or the path to lazy-load the data from
343+
* @param {TipObject[]} tipsToShow the tips object to init
357344
* @returns {Promise.<void>}
358345
*/
359-
export function init(tipsToShow = "/common/modules/data/Tips.js") {
360-
if (tipsToShow) {
361-
// use local shallow copy, if it si an array or save path
362-
tips = Array.isArray(tipsToShow) ? tipsToShow.slice() : tipsToShow;
363-
}
346+
export function init(tipsToShow) {
347+
// use local shallow copy, so we can modify it
348+
// inner objects won't be modified, so we do not need to deep-clone it.
349+
tips = tipsToShow.slice();
364350

365351
// load function
366352
// We need to assign it here to make it testable.

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//ID required, because of storage permission
2121
2222
// minimum version, because of module system
23-
"strict_min_version": "67.0a1"
23+
"strict_min_version": "60.0a1"
2424
}
2525
}
2626
}

0 commit comments

Comments
 (0)