mirror of https://github.com/vector-im/riot-web
move urlSearchParamsToObject and global.d.ts to react-sdk
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/13138/head
parent
c044e1a00c
commit
6764c7e779
|
@ -97,7 +97,6 @@
|
||||||
"@babel/register": "^7.7.4",
|
"@babel/register": "^7.7.4",
|
||||||
"@babel/runtime": "^7.7.6",
|
"@babel/runtime": "^7.7.6",
|
||||||
"@types/jest": "^25.2.1",
|
"@types/jest": "^25.2.1",
|
||||||
"@types/modernizr": "^3.5.3",
|
|
||||||
"@types/react": "16.9",
|
"@types/react": "16.9",
|
||||||
"@types/react-dom": "^16.9.4",
|
"@types/react-dom": "^16.9.4",
|
||||||
"autoprefixer": "^9.7.3",
|
"autoprefixer": "^9.7.3",
|
||||||
|
|
|
@ -14,25 +14,15 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import "modernizr";
|
import "matrix-react-sdk/src/@types/global";
|
||||||
import {Renderer} from "react-dom";
|
import {Renderer} from "react-dom";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
Modernizr: ModernizrAPI & FeatureDetects;
|
|
||||||
Olm: {
|
|
||||||
init: () => Promise<void>;
|
|
||||||
};
|
|
||||||
|
|
||||||
mxSendRageshake: (text: string, withLogs?: boolean) => void;
|
mxSendRageshake: (text: string, withLogs?: boolean) => void;
|
||||||
matrixChat: ReturnType<Renderer>;
|
matrixChat: ReturnType<Renderer>;
|
||||||
|
|
||||||
// electron-only
|
// electron-only
|
||||||
ipcRenderer: any;
|
ipcRenderer: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
// workaround for https://github.com/microsoft/TypeScript/issues/30933
|
|
||||||
interface ObjectConstructor {
|
|
||||||
fromEntries?(xs: [string|number|symbol, any][]): object
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,12 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {urlSearchParamsToObject} from "matrix-react-sdk/src/utils/UrlUtils";
|
||||||
|
|
||||||
interface IParamsObject {
|
interface IParamsObject {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchParamsToObject(params: URLSearchParams) {
|
|
||||||
return <IParamsObject>Object.fromEntries([...params.entries()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We want to support some name / value pairs in the fragment
|
// We want to support some name / value pairs in the fragment
|
||||||
// so we're re-using query string like format
|
// so we're re-using query string like format
|
||||||
//
|
//
|
||||||
|
@ -42,11 +40,11 @@ export function parseQsFromFragment(location: Location) {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (hashparts.length > 1) {
|
if (hashparts.length > 1) {
|
||||||
result.params = searchParamsToObject(new URLSearchParams(hashparts[1]));
|
result.params = urlSearchParamsToObject<IParamsObject>(new URLSearchParams(hashparts[1]));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseQs(location: Location) {
|
export function parseQs(location: Location) {
|
||||||
return searchParamsToObject(new URLSearchParams(location.search));
|
return urlSearchParamsToObject<IParamsObject>(new URLSearchParams(location.search));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue