Skip to content

Commit

Permalink
Merge pull request #41 from berkmancenter/npiano/rebrand
Browse files Browse the repository at this point in the history
Npiano/rebrand
  • Loading branch information
jsdiaz authored May 25, 2023
2 parents 1313b0e + f09fc56 commit fde5d62
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,500;0,700;1,300;1,500;1,700&display=swap"
rel="stylesheet" />
<title>Threads</title>
<title>nymspace</title>
</head>

<body>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Shared/FooterSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
target="_blank"
class="text-xl self-center"
>
Threads GitHub
<img :src="githubLogo" alt="Threads GitHub" class="inline-block w-8" />
nymspace GitHub
<img :src="githubLogo" alt="nymspace GitHub" class="inline-block w-8" />
</a>
</div>
</template>
Expand Down
9 changes: 2 additions & 7 deletions src/components/Shared/HeaderSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
>
<div>
<router-link to="/" class="text-4xl">
<img
src="/images/threads-logo-v1.svg"
alt="Threads"
class="w-12 inline-block"
/>
<p class="inline-block text-red-600">Threads</p>
<p class="inline-block text-red-600">nymspace</p>
</router-link>
<a
v-if="showVersion"
Expand All @@ -36,7 +31,7 @@
href="https://cyber.harvard.edu/projects/nymity"
rel="noopener"
target="_blank"
>About Threads<ExternalLinkIcon class="ml-1 inline-block w-4 h-4" />
>About Nymity<ExternalLinkIcon class="ml-1 inline-block w-4 h-4" />
</a>
</div>
</div>
Expand Down
28 changes: 24 additions & 4 deletions src/views/MessagesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,28 @@ const updatedMsgs = computed((x) => {
/**
* Send message via ws
*/
function parseJwt (token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
var jsonPayload = decodeURIComponent(window.atob(base64).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
return JSON.parse(jsonPayload);
}
async function sendMessage() {
if (message.value.trim().length > 0 && !getActiveThread.value?.locked && !pseudonymMismatch.value) {
const accessToken = VueCookieNext.getCookie("access_token");
const decodedAccessToken = parseJwt(accessToken);
const expiresAt = new Date(decodedAccessToken.exp * 1000);
const oneMinuteFromNow = new Date();
oneMinuteFromNow.setMinutes(oneMinuteFromNow.getMinutes() + 1);
if (expiresAt < oneMinuteFromNow) {
await loadUser();
}
wsInstance.value.sendMessage({
message: {
body: message.value,
Expand Down Expand Up @@ -389,15 +409,15 @@ const reconnectSockets = () =>{
}
onMounted(async () => {
wsInstance.value = new SocketioService();
wsInstance.value.addDisconnectHandler(reconnectSockets);
reconnectSockets();
const user = await loadUser();
goodReputation.value = user.goodReputation;
await fetchMessages(route.params.threadId);
await fetchThreadDetails(route.params.threadId);
messageTextArea.value?.focus();
wsInstance.value = new SocketioService();
wsInstance.value.addDisconnectHandler(reconnectSockets);
reconnectSockets();
});
onUnmounted(() => {
Expand Down
8 changes: 4 additions & 4 deletions src/views/ThreadsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,6 @@ const reconnectSockets = () =>{
}
onMounted(async () => {
wsInstance.value = new SocketioService();
wsInstance.value.addDisconnectHandler(reconnectSockets);
reconnectSockets();
await loadUserThreads();
await loadThreads(route.params.channelId);
Expand All @@ -189,6 +185,10 @@ onMounted(async () => {
channel.value = getChannel(route.params.channelId);
}
wsInstance.value = new SocketioService();
wsInstance.value.addDisconnectHandler(reconnectSockets);
reconnectSockets();
setActiveChannel(channel.value);
});
Expand Down

0 comments on commit fde5d62

Please sign in to comment.