Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(local-storage): store cvaa settings #45

Merged
merged 14 commits into from
Oct 23, 2017
Merged

feat(local-storage): store cvaa settings #45

merged 14 commits into from
Oct 23, 2017

Conversation

yairans
Copy link
Contributor

@yairans yairans commented Oct 19, 2017

Description of the Changes

  • storing the cvaa settings in the local storage.
  • applying the cvaa setting from the local storage.

CheckLists

  • changes have been done against master branch, and PR does not conflict
  • new unit / functional tests have been added (whenever applicable)
  • test are passing in local environment
  • Travis tests are passing (or test results are not worse than on master branch :))
  • Docs have been updated

@yairans yairans changed the title Store cvaa feat(local-storage): store cvaa settings Oct 19, 2017
Copy link
Contributor

@OrenMe OrenMe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to recreate the TextStyle object from the serialized object on player init

* @returns {void}
*/
static setPlayerTextStyle(player: Player): void {
const textStyle = StorageManager.getStorage().textStyle;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why get all the storage again? time consuming
call
StorageWrapper.getItem('textStyle')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't know this API, 10x.

static setPlayerTextStyle(player: Player): void {
const textStyle = StorageManager.getStorage().textStyle;
if (textStyle) {
player.textStyle = Utils.Object.mergeDeep(new TextStyle(), textStyle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to split to declaration and assignment
let textStyle = Utils.Object.mergeDeep(new TextStyle(), textStyle);
player.textStyle = textStyle;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and on line 61 maybe change the name to textStyleObj
because this is not really the textStyle but the parsed object from the storage.

Copy link
Contributor Author

@yairans yairans Oct 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regarding split:
let textStyle = Utils.Object.mergeDeep(new TextStyle(), textStyle);
is also declaration and assignment in one line...

regarding name: done.

* @public
* @returns {void}
*/
static setPlayerTextStyle(player: Player): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why it gets the player reference again?
this is not already on the StorageManager ?
StorageManager._player

Copy link
Contributor Author

@yairans yairans Oct 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can't rely on the statics method invoking order. if i'm changing the order in setup.js:
setStorageTextStyle();
applyStorageSupport(kalturaPlayer);
it won't work.

i've remove the player ref.
applyStorageSupport gets it as param, why to storing it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds legit, I was convinced

StorageWrapper.setItem('muted', StorageManager._player.muted);
StorageWrapper.setItem('volume', StorageManager._player.volume);
player.addEventListener(player.Event.VOLUME_CHANGE, () => {
StorageWrapper.setItem('muted', player.muted);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yairans
If u already touch this class, move please the muted to his own event (MUTE_CHANGE).
It's done this way in the past cause we didn't had mute event.
10x

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@OrenMe OrenMe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not getting the separation of methods to apply config.
Maybe if the name config was changed to cachedSettings it made more clear sense what we are trying to do.
This feature is from kaltura player perspective so mute and textStyle are the same thing.
The difference is how they are applied to the playkit lib.

I would change the of setStorageConfig to setStorageSetting or maybe setSettingsFromStorage and in it do all storage based actions

@@ -1,16 +1,17 @@
// @flow
import StorageWrapper from './storage-wrapper'
import LoggerFactory from '../utils/logger'
import {Utils, TextStyle} from 'playkit-js'

export default class StorageManager {
static StorageKeys = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better move these to const keys as we are referring the strings in too many places already

OrenMe
OrenMe previously approved these changes Oct 23, 2017
const VOLUME = 'volume';
const AUDIO_LANG = 'audioLanguage';
const TEXT_LANG = 'textLanguage';
const TEXT_STYLE = 'textStyle';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like it like that
if we will have 20 keys, so we will create 20 consts?
(@yairans it was not said in anger :) )

I think we need to change StorageKeys to a key-value object:
static StorageKeys = {
KEY : "VALUE"
}

and when we will need to iterate the values we will simply do Object(StorageManager.StorageKeys).keys().forEach((storageKey...

@yairans yairans merged commit f3546f5 into master Oct 23, 2017
@yairans yairans deleted the store-cvaa branch October 23, 2017 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants