Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Chatterbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
element-hq
Chatterbox
Commits
a0b98cbb
Commit
a0b98cbb
authored
3 years ago
by
Midhun Suresh
Browse files
Options
Downloads
Patches
Plain Diff
Implement interface and refactor code
parent
f1981902
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Hydrogen.ts
+9
-9
9 additions, 9 deletions
src/Hydrogen.ts
src/types/IMatrixClient.ts
+6
-0
6 additions, 0 deletions
src/types/IMatrixClient.ts
with
15 additions
and
9 deletions
src/Hydrogen.ts
+
9
−
9
View file @
a0b98cbb
import
{
Platform
,
Client
,
LoadStatus
,
createNavigation
,
createRouter
,
RoomViewModel
,
TimelineView
,
}
from
"
hydrogen-view-sdk
"
;
import
assetPaths
from
"
hydrogen-view-sdk/paths/vite
"
;
import
"
hydrogen-view-sdk/style.css
"
;
import
{
IMatrixClient
}
from
"
./types/IMatrixClient
"
;
export
class
Hydrogen
{
export
class
Hydrogen
implements
IMatrixClient
{
private
readonly
_homeserver
:
string
;
private
_platform
:
Record
<
string
,
any
>
;
private
_client
:
Record
<
string
,
any
>
;
private
_urlRouter
:
Re
cord
<
string
,
any
>
;
private
_navigation
:
Re
cord
<
string
,
any
>
;
private
_platform
:
Platform
;
private
_client
:
Client
;
private
_urlRouter
:
Re
turnType
<
createRouter
>
;
private
_navigation
:
Re
turnType
<
createNavigation
>
;
private
_container
:
HTMLDivElement
;
constructor
(
homeserver
:
string
,
container
:
HTMLDivElement
)
{
...
...
@@ -21,15 +22,14 @@ export class Hydrogen {
this
.
_client
=
new
Client
(
this
.
_platform
);
}
async
register
(
username
:
string
,
password
:
string
,
initialDeviceDisplayName
:
string
)
{
async
register
(
username
:
string
,
password
:
string
,
initialDeviceDisplayName
:
string
)
:
Promise
<
void
>
{
let
stage
=
await
this
.
_client
.
startRegistration
(
this
.
_homeserver
,
username
,
password
,
initialDeviceDisplayName
);
while
(
stage
!==
true
)
{
stage
=
await
stage
.
complete
();
}
return
stage
;
}
async
login
(
username
:
string
,
password
:
string
)
{
async
login
(
username
:
string
,
password
:
string
)
:
Promise
<
void
>
{
const
loginOptions
=
await
this
.
_client
.
queryLogin
(
this
.
_homeserver
).
result
;
this
.
_client
.
startWithLogin
(
loginOptions
.
password
(
username
,
password
));
...
...
@@ -46,7 +46,7 @@ export class Hydrogen {
}
}
async
showRoom
(
roomId
:
string
)
{
async
showRoom
(
roomId
:
string
)
:
Promise
<
void
>
{
const
room
=
this
.
_session
.
rooms
.
get
(
roomId
)
??
await
this
.
_joinRoom
(
roomId
);
const
vm
=
new
RoomViewModel
({
room
,
...
...
This diff is collapsed.
Click to expand it.
src/types/IMatrixClient.ts
0 → 100644
+
6
−
0
View file @
a0b98cbb
export
interface
IMatrixClient
{
register
(
username
:
string
,
password
:
string
,
initialDeviceDisplayName
:
string
):
Promise
<
void
>
;
login
(
username
:
string
,
password
:
string
):
Promise
<
void
>
;
showRoom
(
roomId
:
string
):
Promise
<
void
>
;
attemptStartWithExistingSession
():
Promise
<
boolean
>
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment