Skip to content

Commit 69b1e24

Browse files
author
Pietro Passarelli - News Labs
committed
reabsed with master
2 parents e9b3245 + 61affa7 commit 69b1e24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3980
-1031
lines changed

.babelrc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"presets": [
3-
"@babel/preset-react"
3+
"@babel/preset-react",
4+
"@babel/preset-env",
5+
["minify", {
6+
"builtIns": false,
7+
"evaluate": false,
8+
"mangle": false,
9+
}]
410
],
511
"plugins": [
612
"@babel/plugin-proposal-object-rest-spread",

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"newline-before-return": "error",
4444
"space-before-blocks": "error",
4545
"no-unused-vars": "error",
46+
"no-multi-spaces": "warn",
4647
"comma-spacing": ["error", { "before": false, "after": true }],
4748
"prefer-destructuring": ["error", {
4849
"VariableDeclarator": {

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
name: Bug report
33
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: pietrop
47

58
---
69

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4+
title: ''
5+
labels: Enhancement
6+
assignees: pietrop
47

58
---
69

.github/ISSUE_TEMPLATE/question.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
name: Question
33
about: Ask a question about this project
4+
title: ''
5+
labels: bug
6+
assignees: pietrop
47

58
---
69

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
language: node_js
22
node_js:
3-
- "node"
43
- "10"
54

65
install:

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ By submitting code as an individual or as an entity you agree that your code is
1818
5. If you've added code that should be tested, add tests, if you need help with automated testing, feel free to raise an [issue](https://github.com/bbc/react-transcript-editor/issues/new?template=feature_request.md).
1919
6. Ensure the test suite passes.
2020
7. Make sure your code lints.
21-
8. If you've changed APIs, consider [updating the documentation](https://github.com/bbc/react-transcript-editor#documentation).
21+
8. If you've changed APIs, consider [updating the documentation](https://github.com/bbc/react-transcript-editor#documentation) and QA Testing docs.
2222
9. Once the work is complete push the branch up on to GitHub for review. Make sure your branch is up to date with `master` before making a pull request. eg use [`git merge origin/master`](https://git-scm.com/docs/git-merge) or [rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing)
2323
10. Once a branch has been merged into `master`, delete it.
2424

@@ -41,7 +41,7 @@ See [this blog post for more on this](https://medium.com/mindorks/how-to-write-c
4141
- [ ] Ensure test suite passes (`npm run test`)
4242
- [ ] Make sure your code lints. (`npm run lint`)
4343
- [ ] consider re-factoring for code quality and readability
44-
- [ ] Update documentation where appropriate [updating the documentation](https://github.com/bbc/react-transcript-editor#documentation)
44+
- [ ] Update documentation and QA docs where appropriate - [see updating the documentation](https://github.com/bbc/react-transcript-editor#documentation)
4545
- [ ] Setup your PR for review
4646

4747
<!--

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,14 @@ import { TranscriptEditor } from '@bbc/react-transcript-editor';
6565
transcriptData=// Transcript json
6666
mediaUrl=// string url to media file - audio or video
6767
isEditable={true}// se to true if you want to be able to edit the text
68-
sttJsonType={ 'bbcKaldi' }// the type of STT Json transcript supported.
68+
sttJsonType={ 'bbckaldi' }// the type of STT Json transcript supported.
69+
fileName={ this.state.fileName }// optional*
6970
/>
7071
```
7172

73+
_Note: `fileName` it is optional but it's needed if working with user uploaded local media in the browser, to be able to save and retrieve from local storage. For instance if you are passing a blob url to `mediaUrl` using `createObjectURL` this url is randomly re-generated on every page refresh so you wouldn't be able to restore a session, as `mediaUrl` is used as the local storage key. See demo app for more detail example of this[`./src/index.js`](./src/index.js)_
74+
75+
7276
## System Architecture
7377

7478
<!-- _High level overview of system architecture_ -->
@@ -93,6 +97,7 @@ There's a [docs](./docs) folder in this repository.
9397
9498
We are using [this template for ADR](https://gist.github.com/iaincollins/92923cc2c309c2751aea6f1b34b31d95)
9599

100+
[There also QA testing docs](./docs/qa/README.md) to manual test the component before a major release, (QA testing does not require any technical knowledge).
96101

97102
## Build
98103

dist/index.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Frequency of local storage save
2+
3+
* Status: **accepted** <!-- optional -->
4+
* Deciders: Pietro <!-- optional -->
5+
* Date: 2019-01-24 <!-- optional -->
6+
7+
<!-- Technical Story: [description | ticket/issue URL] -->
8+
9+
## Context and Problem Statement
10+
11+
<!-- [Describe the context and problem statement, e.g., in free form using two to three sentences. You may want to articulate the problem in form of a question.] -->
12+
13+
The issue is how often to save to local storage when a user types, previous implementation saved every 5 characters. But that caused issues [#86](https://github.com/bbc/react-transcript-editor/issues/86)
14+
15+
16+
17+
## Decision Drivers <!-- optional -->
18+
19+
<!-- * [driver 1, e.g., a force, facing concern, …] -->
20+
* A simple and straight forward way to save to local storage
21+
* saving on a good frequency
22+
* without introducing performance issues especially on less performant devices
23+
* if possible without introducing third party dependencies
24+
25+
## Considered Options
26+
27+
* [loadash debounce](https://lodash.com/docs/4.17.11#debounce)
28+
* using a js timer
29+
30+
## Notes on debounce option
31+
32+
What is a debounce function?
33+
34+
> debounce function does, it limits the rate at which a function can fire.
35+
> [...] You'll pass the debounce function the function to execute and the fire rate limit in milliseconds
36+
37+
from https://john-dugan.com/javascript-debounce/
38+
39+
In more detail
40+
41+
https://davidwalsh.name/javascript-debounce-function
42+
43+
with examples
44+
45+
https://css-tricks.com/debouncing-throttling-explained-examples/
46+
47+
48+
https://lodash.com/docs/4.17.11#debounce
49+
50+
## Decision Outcome
51+
52+
Chosen option: **using a js timer**.
53+
54+
It uses a timer that can be consolidated into one final one rather then having a lot of saves being delayed, we just have one final save once after user has stopped typing for more then 5 seconds.
55+
56+
The timer is cleared before being called so that there is only the final one left. Leaving only one final save at the end. As a performance optimization.
57+
58+
```js
59+
if (this.saveTimer!== undefined) {
60+
clearTimeout(this.saveTimer);
61+
}
62+
this.saveTimer = setTimeout(() => {
63+
this.localSave(this.props.mediaUrl);
64+
}, 5000);
65+
```
66+
67+
68+
<!-- because [justification. e.g., only option, which meets k.o. criterion decision driver | which resolves force force | … | comes out best (see below)]. -->
69+
70+
71+
<!--
72+
### Positive Consequences
73+
74+
* [e.g., improvement of quality attribute satisfaction, follow-up decisions required, …]
75+
* …
76+
77+
### Negative consequences
78+
79+
* [e.g., compromising quality attribute, follow-up decisions required, …]
80+
* …
81+
82+
## Pros and Cons of the Options
83+
84+
### [option 1]
85+
86+
[example | description | pointer to more information | …]
87+
88+
* Good, because [argument a]
89+
* Good, because [argument b]
90+
* Bad, because [argument c]
91+
92+
### [option 2]
93+
94+
[example | description | pointer to more information | …]
95+
96+
* Good, because [argument a]
97+
* Good, because [argument b]
98+
* Bad, because [argument c]
99+
100+
101+
### [option 3]
102+
103+
[example | description | pointer to more information | …]
104+
105+
* Good, because [argument a]
106+
* Good, because [argument b]
107+
* Bad, because [argument c]
108+
109+
110+
## Links
111+
112+
* [Link type] [Link to ADR] -->

0 commit comments

Comments
 (0)