diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-08-03 18:06:49 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-08-06 15:08:58 +0200 |
commit | 4504f09f6e85f09b0489debb547a17209d7176ea (patch) | |
tree | 1e2fdcdd3a0982f6e873205f69bdf90de7f4a883 /client/src/app/helpers | |
parent | 71ab65d02f359000f9ca6a00f163d66d56a33955 (diff) | |
download | PeerTube-4504f09f6e85f09b0489debb547a17209d7176ea.tar.gz PeerTube-4504f09f6e85f09b0489debb547a17209d7176ea.tar.zst PeerTube-4504f09f6e85f09b0489debb547a17209d7176ea.zip |
deal with refresh token in embed
Diffstat (limited to 'client/src/app/helpers')
-rw-r--r-- | client/src/app/helpers/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/helpers/peertube-web-storage.ts | 81 | ||||
-rw-r--r-- | client/src/app/helpers/utils.ts | 10 |
3 files changed, 0 insertions, 92 deletions
diff --git a/client/src/app/helpers/index.ts b/client/src/app/helpers/index.ts index 06806402e..cc61255ba 100644 --- a/client/src/app/helpers/index.ts +++ b/client/src/app/helpers/index.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | export * from './locales' | 1 | export * from './locales' |
2 | export * from './constants' | 2 | export * from './constants' |
3 | export * from './i18n-utils' | 3 | export * from './i18n-utils' |
4 | export * from './peertube-web-storage' | ||
5 | export * from './utils' | 4 | export * from './utils' |
6 | export * from './zone' | 5 | export * from './zone' |
diff --git a/client/src/app/helpers/peertube-web-storage.ts b/client/src/app/helpers/peertube-web-storage.ts deleted file mode 100644 index 0db1301bd..000000000 --- a/client/src/app/helpers/peertube-web-storage.ts +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | // Thanks: https://github.com/capaj/localstorage-polyfill | ||
2 | |||
3 | const valuesMap = new Map() | ||
4 | |||
5 | function proxify (instance: MemoryStorage) { | ||
6 | return new Proxy(instance, { | ||
7 | set: function (obj, prop: string | number, value) { | ||
8 | if (MemoryStorage.prototype.hasOwnProperty(prop)) { | ||
9 | instance[prop] = value | ||
10 | } else { | ||
11 | instance.setItem(prop, value) | ||
12 | } | ||
13 | return true | ||
14 | }, | ||
15 | get: function (target, name: string | number) { | ||
16 | if (MemoryStorage.prototype.hasOwnProperty(name)) { | ||
17 | return instance[name] | ||
18 | } | ||
19 | if (valuesMap.has(name)) { | ||
20 | return instance.getItem(name) | ||
21 | } | ||
22 | } | ||
23 | }) | ||
24 | } | ||
25 | |||
26 | class MemoryStorage { | ||
27 | [key: string]: any | ||
28 | [index: number]: string | ||
29 | |||
30 | getItem (key: any) { | ||
31 | const stringKey = String(key) | ||
32 | if (valuesMap.has(key)) { | ||
33 | return String(valuesMap.get(stringKey)) | ||
34 | } | ||
35 | |||
36 | return null | ||
37 | } | ||
38 | |||
39 | setItem (key: any, val: any) { | ||
40 | valuesMap.set(String(key), String(val)) | ||
41 | } | ||
42 | |||
43 | removeItem (key: any) { | ||
44 | valuesMap.delete(key) | ||
45 | } | ||
46 | |||
47 | clear () { | ||
48 | valuesMap.clear() | ||
49 | } | ||
50 | |||
51 | key (i: any) { | ||
52 | if (arguments.length === 0) { | ||
53 | throw new TypeError('Failed to execute "key" on "Storage": 1 argument required, but only 0 present.') | ||
54 | } | ||
55 | |||
56 | const arr = Array.from(valuesMap.keys()) | ||
57 | return arr[i] | ||
58 | } | ||
59 | |||
60 | get length () { | ||
61 | return valuesMap.size | ||
62 | } | ||
63 | } | ||
64 | |||
65 | let peertubeLocalStorage: Storage | ||
66 | let peertubeSessionStorage: Storage | ||
67 | try { | ||
68 | peertubeLocalStorage = localStorage | ||
69 | peertubeSessionStorage = sessionStorage | ||
70 | } catch (err) { | ||
71 | const instanceLocalStorage = new MemoryStorage() | ||
72 | const instanceSessionStorage = new MemoryStorage() | ||
73 | |||
74 | peertubeLocalStorage = proxify(instanceLocalStorage) | ||
75 | peertubeSessionStorage = proxify(instanceSessionStorage) | ||
76 | } | ||
77 | |||
78 | export { | ||
79 | peertubeLocalStorage, | ||
80 | peertubeSessionStorage | ||
81 | } | ||
diff --git a/client/src/app/helpers/utils.ts b/client/src/app/helpers/utils.ts index 8e9f72adb..825b6ca96 100644 --- a/client/src/app/helpers/utils.ts +++ b/client/src/app/helpers/utils.ts | |||
@@ -81,15 +81,6 @@ function immutableAssign <A, B> (target: A, source: B) { | |||
81 | return Object.assign({}, target, source) | 81 | return Object.assign({}, target, source) |
82 | } | 82 | } |
83 | 83 | ||
84 | function objectToUrlEncoded (obj: any) { | ||
85 | const str: string[] = [] | ||
86 | for (const key of Object.keys(obj)) { | ||
87 | str.push(encodeURIComponent(key) + '=' + encodeURIComponent(obj[key])) | ||
88 | } | ||
89 | |||
90 | return str.join('&') | ||
91 | } | ||
92 | |||
93 | // Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34 | 84 | // Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34 |
94 | function objectToFormData (obj: any, form?: FormData, namespace?: string) { | 85 | function objectToFormData (obj: any, form?: FormData, namespace?: string) { |
95 | const fd = form || new FormData() | 86 | const fd = form || new FormData() |
@@ -207,7 +198,6 @@ export { | |||
207 | sortBy, | 198 | sortBy, |
208 | durationToString, | 199 | durationToString, |
209 | lineFeedToHtml, | 200 | lineFeedToHtml, |
210 | objectToUrlEncoded, | ||
211 | getParameterByName, | 201 | getParameterByName, |
212 | populateAsyncUserVideoChannels, | 202 | populateAsyncUserVideoChannels, |
213 | getAbsoluteAPIUrl, | 203 | getAbsoluteAPIUrl, |