Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusramberg/258610cbf254caee425bf0ae1f6e9bb9 to your computer and use it in GitHub Desktop.
Save marcusramberg/258610cbf254caee425bf0ae1f6e9bb9 to your computer and use it in GitHub Desktop.
diff --git a/assets/components/SidebarChat.svelte b/assets/components/SidebarChat.svelte
index 1b1a6bcf..70be23ec 100644
--- a/assets/components/SidebarChat.svelte
+++ b/assets/components/SidebarChat.svelte
@@ -10,31 +10,30 @@ let unread = 0;
const api = getContext('api');
const byName = (a, b) => a.name.localeCompare(b.name);
-function loadConversations() {
- api.execute('getUser', {
+async function loadConversations() {
+ let res = await api.execute('getUser', {
connections: true,
dialogs: true,
notifications: false,
- }).then(res => {
- email = res.email;
- unread = res.unread;
+ });
+ email = res.email;
+ unread = res.unread;
- const map = {};
- res.connections.forEach(conn => {
- map[conn.connection_id] = {...conn, channels: [], private: []};
- });
+ const map = {};
+ res.connections.forEach(conn => {
+ map[conn.connection_id] = {...conn, channels: [], private: []};
+ });
- res.dialogs.forEach(dialog => {
- const conn = map[dialog.connection_id] || {};
- dialog.path = encodeURIComponent(dialog.dialog_id);
- conn[dialog.is_private ? 'private' : 'channels'].push(dialog);
- });
+ res.dialogs.forEach(dialog => {
+ const conn = map[dialog.connection_id] || {};
+ dialog.path = encodeURIComponent(dialog.dialog_id);
+ conn[dialog.is_private ? 'private' : 'channels'].push(dialog);
+ });
- connections = Object.keys(map).sort().map(id => {
- map[id].channels.sort(byName);
- map[id].private.sort(byName);
- return map[id];
- });
+ connections = Object.keys(map).sort().map(id => {
+ map[id].channels.sort(byName);
+ map[id].private.sort(byName);
+ return map[id];
});
}
@@ -92,4 +91,4 @@ onMount(() => {
<Link href="/logout" className="sidebar__nav__logout">{l('Log out')}</Link>
</nav>
</div>
-</div>
\ No newline at end of file
+</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment