updated protocols
This commit is contained in:
parent
7283e3f6f9
commit
531a32a5a5
37 changed files with 682 additions and 650 deletions
26
src/render/shared/account.ts
Normal file
26
src/render/shared/account.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// shared
|
||||
import { ref } from "vue";
|
||||
|
||||
export const ready = ref(false);
|
||||
export const account = ref();
|
||||
|
||||
export const setAccount: IpcListenerCallback<string | null> = (payload) => {
|
||||
payload ? account.value = payload : clearAccount();
|
||||
showRender();
|
||||
};
|
||||
|
||||
export const clearAccount = () => {
|
||||
console.log("Clearing account");
|
||||
account.value = null;
|
||||
}
|
||||
|
||||
const showRender = () => {
|
||||
ready.value = true;
|
||||
}
|
||||
|
||||
export default {
|
||||
ready,
|
||||
account,
|
||||
setAccount,
|
||||
clearAccount
|
||||
};
|
||||
|
|
@ -1,12 +1,65 @@
|
|||
// shared
|
||||
import { ref } from "vue";
|
||||
import anime from "animejs";
|
||||
|
||||
export const status = ref("");
|
||||
|
||||
export let hiddenState = true;
|
||||
|
||||
let animateLogo: anime.AnimeInstance;
|
||||
let animateConnect: anime.AnimeInstance;
|
||||
|
||||
export function useAnim() {
|
||||
|
||||
animateLogo = anime({
|
||||
targets: '#logo',
|
||||
translateX: [0, 15],
|
||||
duration: 500,
|
||||
autoplay: false,
|
||||
easing: 'easeInOutBack'
|
||||
});
|
||||
|
||||
animateConnect = anime({
|
||||
targets: '#connect',
|
||||
translateX: [0, -15],
|
||||
opacity: [0, 1],
|
||||
duration: 500,
|
||||
autoplay: false,
|
||||
easing: 'easeInOutBack'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
export function show() {
|
||||
if (animateLogo && animateConnect) {
|
||||
animateLogo.direction = "normal";
|
||||
animateConnect.direction = "normal";
|
||||
animateLogo.play();
|
||||
animateConnect.play();
|
||||
hiddenState = false;
|
||||
}
|
||||
}
|
||||
|
||||
export function hide() {
|
||||
if (animateLogo && animateConnect) {
|
||||
animateLogo.direction = "reverse";
|
||||
animateConnect.direction = "reverse";
|
||||
animateLogo.play();
|
||||
animateConnect.play();
|
||||
hiddenState = true;
|
||||
}
|
||||
}
|
||||
|
||||
export const setConnectionStatus: IpcListenerCallback<string> = (payload) => {
|
||||
status.value = payload;
|
||||
};
|
||||
|
||||
export default {
|
||||
status
|
||||
hiddenState,
|
||||
useAnim,
|
||||
status,
|
||||
show,
|
||||
hide
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +1,14 @@
|
|||
// shared
|
||||
import { ref, Ref } from "vue";
|
||||
import useScroll from "@/render/composables/useScroll";
|
||||
|
||||
const { isScrolledToBottom, adjustScroll } = useScroll("messenger");
|
||||
|
||||
export const messages: Ref<Array<Message>> = ref([]);
|
||||
|
||||
export const setMessages: IpcListenerCallback<Array<Message>> = (payload) => {
|
||||
messages.value = payload as Array<Message>;
|
||||
setTimeout(() => {
|
||||
adjustScroll();
|
||||
}, 1000);
|
||||
messages.value = payload;
|
||||
}
|
||||
|
||||
export const addMessage: IpcListenerCallback<Message> = (payload) => {
|
||||
const bottom = isScrolledToBottom();
|
||||
messages.value.push(payload as Message);
|
||||
if (bottom) {
|
||||
setTimeout(() => {
|
||||
adjustScroll();
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
export const updateMessage: IpcListenerCallback<Annotation> = (payload) => {
|
||||
|
|
@ -31,11 +19,15 @@ export const updateMessage: IpcListenerCallback<Annotation> = (payload) => {
|
|||
if (messages.value[i].uid == annotation.uid) {
|
||||
|
||||
if (annotation.name == "content") {
|
||||
messages.value[i].content = annotation.data as string[];
|
||||
messages.value[i].content = annotation.data as Content[];
|
||||
}
|
||||
|
||||
if (annotation.name == "context") {
|
||||
messages.value[i].context = annotation.data as string;
|
||||
messages.value[i].context = annotation.data as Context;
|
||||
}
|
||||
|
||||
if (annotation.name == "seen") {
|
||||
messages.value[i].seen = annotation.data as boolean;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -56,6 +48,10 @@ export const deleteMessage: IpcListenerCallback<string> = (payload) => {
|
|||
|
||||
}
|
||||
|
||||
export const resetMessages = () => {
|
||||
messages.value = [];
|
||||
}
|
||||
|
||||
export default {
|
||||
messages,
|
||||
setMessages,
|
||||
|
|
|
|||
|
|
@ -1,27 +1,19 @@
|
|||
// shared
|
||||
import { ref } from "vue";
|
||||
|
||||
export const profile = ref();
|
||||
class Profile implements Profile{
|
||||
crimata_id = "";
|
||||
name = "";
|
||||
photo = "";
|
||||
}
|
||||
|
||||
export const authComplete = ref(false);
|
||||
export const profile = ref(new Profile());
|
||||
|
||||
export const setProfile: IpcListenerCallback<Profile | null> = (payload) => {
|
||||
payload ? profile.value = payload : clearProfile();
|
||||
showRender();
|
||||
};
|
||||
|
||||
export const clearProfile = () => {
|
||||
profile.value = null;
|
||||
};
|
||||
|
||||
export const showRender = () => {
|
||||
authComplete.value = true;
|
||||
export const setProfile: IpcListenerCallback<Profile> = (payload) => {
|
||||
profile.value = payload;
|
||||
};
|
||||
|
||||
export default {
|
||||
setProfile,
|
||||
clearProfile,
|
||||
profile,
|
||||
showRender,
|
||||
authComplete,
|
||||
};
|
||||
setProfile
|
||||
};
|
||||
12
src/render/shared/version.ts
Normal file
12
src/render/shared/version.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// shared
|
||||
import { ref } from "vue";
|
||||
|
||||
export const version = ref();
|
||||
|
||||
export const setVersion: IpcListenerCallback<Profile | null> = (payload) => {
|
||||
version.value = payload;
|
||||
};
|
||||
|
||||
export default {
|
||||
setVersion
|
||||
}
|
||||
Loading…
Reference in a new issue