remember what view was used for chat objects
This commit is contained in:
Vendored
+11
-4
@@ -389,6 +389,9 @@
|
|||||||
|
|
||||||
// src/utility.tsx
|
// src/utility.tsx
|
||||||
var storageKeys = {
|
var storageKeys = {
|
||||||
|
viewType(id) {
|
||||||
|
return id + "view-type";
|
||||||
|
},
|
||||||
hasUnread(id) {
|
hasUnread(id) {
|
||||||
return id + "has-unread-messages";
|
return id + "has-unread-messages";
|
||||||
},
|
},
|
||||||
@@ -686,6 +689,7 @@
|
|||||||
// src/Model/chatModel.ts
|
// src/Model/chatModel.ts
|
||||||
var Chat = class {
|
var Chat = class {
|
||||||
id;
|
id;
|
||||||
|
viewType;
|
||||||
isSubscribed = new State(false);
|
isSubscribed = new State(false);
|
||||||
primaryChannel = new State("");
|
primaryChannel = new State("");
|
||||||
hasUnreadMessages;
|
hasUnreadMessages;
|
||||||
@@ -709,6 +713,10 @@
|
|||||||
// init
|
// init
|
||||||
constructor(id = UUID()) {
|
constructor(id = UUID()) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
this.viewType = restoreState(
|
||||||
|
storageKeys.viewType(id),
|
||||||
|
"all"
|
||||||
|
);
|
||||||
this.primaryChannel = restoreState(
|
this.primaryChannel = restoreState(
|
||||||
storageKeys.primaryChannel(id),
|
storageKeys.primaryChannel(id),
|
||||||
""
|
""
|
||||||
@@ -1716,10 +1724,9 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const selectedViewType = new State("all");
|
const mainView = createProxyState([chat.viewType], () => {
|
||||||
const mainView = createProxyState([selectedViewType], () => {
|
|
||||||
function getViewFunction() {
|
function getViewFunction() {
|
||||||
switch (selectedViewType.value) {
|
switch (chat.viewType.value) {
|
||||||
case "notes":
|
case "notes":
|
||||||
return NoteObjectsView;
|
return NoteObjectsView;
|
||||||
case "kanban":
|
case "kanban":
|
||||||
@@ -1745,7 +1752,7 @@
|
|||||||
},
|
},
|
||||||
/* @__PURE__ */ createElement("span", { class: "icon" }, "add")
|
/* @__PURE__ */ createElement("span", { class: "icon" }, "add")
|
||||||
), /* @__PURE__ */ createElement("div", { class: "padding-sm flex flex-row gap justify-center scroll-h width-100" }, ...Object.keys(viewTypes).map(
|
), /* @__PURE__ */ createElement("div", { class: "padding-sm flex flex-row gap justify-center scroll-h width-100" }, ...Object.keys(viewTypes).map(
|
||||||
(key) => ViewTypeToggle(key, selectedViewType)
|
(key) => ViewTypeToggle(key, chat.viewType)
|
||||||
)), /* @__PURE__ */ createElement("button", { class: "height-100", disabled: true }, /* @__PURE__ */ createElement("span", { class: "icon" }, "visibility"))), /* @__PURE__ */ createElement("div", { class: "width-100 height-100 flex scroll-no", "children:set": mainView }), /* @__PURE__ */ createElement("div", { "children:set": objectModal }));
|
)), /* @__PURE__ */ createElement("button", { class: "height-100", disabled: true }, /* @__PURE__ */ createElement("span", { class: "icon" }, "visibility"))), /* @__PURE__ */ createElement("div", { class: "width-100 height-100 flex scroll-no", "children:set": mainView }), /* @__PURE__ */ createElement("div", { "children:set": objectModal }));
|
||||||
}
|
}
|
||||||
function ViewTypeToggle(key, selection) {
|
function ViewTypeToggle(key, selection) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { decryptString, encryptString } from "../cryptUtility";
|
|||||||
import { Message } from "udn-frontend";
|
import { Message } from "udn-frontend";
|
||||||
import { storageKeys } from "../utility";
|
import { storageKeys } from "../utility";
|
||||||
import { translation } from "../translations";
|
import { translation } from "../translations";
|
||||||
|
import { viewTypes } from "../Views/Objects/objectPane";
|
||||||
|
|
||||||
// TYPES
|
// TYPES
|
||||||
// message
|
// message
|
||||||
@@ -50,6 +51,8 @@ export interface MessageObjectContent {
|
|||||||
export class Chat {
|
export class Chat {
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
|
viewType: React.State<keyof typeof viewTypes>;
|
||||||
|
|
||||||
isSubscribed = new React.State(false);
|
isSubscribed = new React.State(false);
|
||||||
primaryChannel = new React.State("");
|
primaryChannel = new React.State("");
|
||||||
hasUnreadMessages: React.State<boolean>;
|
hasUnreadMessages: React.State<boolean>;
|
||||||
@@ -78,6 +81,11 @@ export class Chat {
|
|||||||
constructor(id: string = React.UUID()) {
|
constructor(id: string = React.UUID()) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
|
this.viewType = React.restoreState<keyof typeof viewTypes>(
|
||||||
|
storageKeys.viewType(id),
|
||||||
|
"all"
|
||||||
|
);
|
||||||
|
|
||||||
// channels
|
// channels
|
||||||
this.primaryChannel = React.restoreState(
|
this.primaryChannel = React.restoreState(
|
||||||
storageKeys.primaryChannel(id),
|
storageKeys.primaryChannel(id),
|
||||||
|
|||||||
@@ -33,10 +33,9 @@ export function ObjectPane(chat: Chat) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// view type
|
// view type
|
||||||
const selectedViewType = new React.State<keyof typeof viewTypes>("all");
|
const mainView = React.createProxyState([chat.viewType], () => {
|
||||||
const mainView = React.createProxyState([selectedViewType], () => {
|
|
||||||
function getViewFunction() {
|
function getViewFunction() {
|
||||||
switch (selectedViewType.value) {
|
switch (chat.viewType.value) {
|
||||||
case "notes":
|
case "notes":
|
||||||
return NoteObjectsView;
|
return NoteObjectsView;
|
||||||
case "kanban":
|
case "kanban":
|
||||||
@@ -70,7 +69,7 @@ export function ObjectPane(chat: Chat) {
|
|||||||
|
|
||||||
<div class="padding-sm flex flex-row gap justify-center scroll-h width-100">
|
<div class="padding-sm flex flex-row gap justify-center scroll-h width-100">
|
||||||
{...Object.keys(viewTypes).map((key: any) =>
|
{...Object.keys(viewTypes).map((key: any) =>
|
||||||
ViewTypeToggle(key, selectedViewType)
|
ViewTypeToggle(key, chat.viewType)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import * as React from "bloatless-react";
|
import * as React from "bloatless-react";
|
||||||
|
|
||||||
export const storageKeys = {
|
export const storageKeys = {
|
||||||
|
viewType(id: string): string {
|
||||||
|
return id + "view-type";
|
||||||
|
},
|
||||||
|
|
||||||
hasUnread(id: string): string {
|
hasUnread(id: string): string {
|
||||||
return id + "has-unread-messages";
|
return id + "has-unread-messages";
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user