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
fac9e449
Commit
fac9e449
authored
3 years ago
by
RMidhunSuresh
Browse files
Options
Downloads
Patches
Plain Diff
Setup and get hydrogen sdk working
parent
2862adfc
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
index.html
+1
-1
1 addition, 1 deletion
index.html
src/main.ts
+54
-6
54 additions, 6 deletions
src/main.ts
with
55 additions
and
7 deletions
index.html
+
1
−
1
View file @
fac9e449
...
...
@@ -7,7 +7,7 @@
<title>
Vite App
</title>
</head>
<body>
<div
id=
"app"
></div>
<div
id=
"app"
class=
"hydrogen"
></div>
<script
type=
"module"
src=
"/src/main.ts"
></script>
</body>
</html>
This diff is collapsed.
Click to expand it.
src/main.ts
+
54
−
6
View file @
fac9e449
import
'
./style.css
'
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
"
;
const
app
=
document
.
querySelector
<
HTMLDivElement
>
(
'
#app
'
)
!
async
function
main
()
{
const
app
=
document
.
querySelector
<
HTMLDivElement
>
(
'
#app
'
)
!
const
config
=
{};
const
platform
=
new
Platform
(
app
,
assetPaths
,
config
,
{
development
:
import
.
meta
.
env
.
DEV
});
const
navigation
=
createNavigation
();
platform
.
setNavigation
(
navigation
);
const
urlRouter
=
createRouter
({
navigation
:
navigation
,
history
:
platform
.
history
});
urlRouter
.
attach
();
const
client
=
new
Client
(
platform
);
app
.
innerHTML
=
`
<h1>Hello Vite!</h1>
<a href="https://vitejs.dev/guide/features.html" target="_blank">Documentation</a>
`
const
loginOptions
=
await
client
.
queryLogin
(
"
matrix.org
"
).
result
;
client
.
startWithLogin
(
loginOptions
.
password
(
"
foobaraccount
"
,
"
UzmiRif6UnHqp6s
"
));
await
client
.
loadStatus
.
waitFor
((
status
:
string
)
=>
{
return
status
===
LoadStatus
.
Ready
||
status
===
LoadStatus
.
Error
||
status
===
LoadStatus
.
LoginFailed
;
}).
promise
;
if
(
client
.
loginFailure
)
{
alert
(
"
login failed:
"
+
client
.
loginFailure
);
}
else
if
(
client
.
loadError
)
{
alert
(
"
load failed:
"
+
client
.
loadError
.
message
);
}
else
{
const
{
session
}
=
client
;
// looks for room corresponding to #element-dev:matrix.org, assuming it is already joined
const
room
=
session
.
rooms
.
get
(
"
!nXJtsUatHBGyIYfyYw:matrix.org
"
);
const
vm
=
new
RoomViewModel
({
room
,
ownUserId
:
session
.
userId
,
platform
,
urlCreator
:
urlRouter
,
navigation
,
});
await
vm
.
load
();
const
view
=
new
TimelineView
(
vm
.
timelineViewModel
);
app
.
appendChild
(
view
.
mount
());
}
}
main
();
\ No newline at end of file
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