remember favourite chat tab
This commit is contained in:
parent
998756be28
commit
ce62c49ceb
|
@ -16,7 +16,7 @@ userId: @jsUserId,
|
|||
tour: @jsOrNull(tour.flatMap(_.top).map(lila.tournament.JsonView.top(_, lightUser))),
|
||||
chat: @jsOrNull(chatOption.map(_.either).map {
|
||||
case Left(c) => {
|
||||
chat.ChatJsData.restricted(c, name = trans.chatRoom.txt(), timeout = false, withNote = true, public = false)
|
||||
chat.ChatJsData.restricted(c, name = trans.chatRoom.txt(), timeout = false, withNote = ctx.isAuth, public = false)
|
||||
}
|
||||
case Right(c) => {
|
||||
chat.ChatJsData.json(c.chat, name = trans.chatRoom.txt(), timeout = c.timeout, public = true)
|
||||
|
|
|
@ -11,10 +11,17 @@ export default function(opts: ChatOpts, redraw: Redraw): Ctrl {
|
|||
|
||||
const pubsub = li.pubsub;
|
||||
|
||||
const allTabs: Tab[] = ['discussion'];
|
||||
if (opts.noteId) allTabs.push('note');
|
||||
if (opts.plugin) allTabs.push(opts.plugin.tab.key);
|
||||
|
||||
const tabStorage = li.storage.make('chat.tab'),
|
||||
storedTab = tabStorage.get();
|
||||
|
||||
let moderation: ModerationCtrl | undefined;
|
||||
|
||||
const vm: ViewModel = {
|
||||
tab: 'discussion',
|
||||
tab: allTabs.indexOf(storedTab) > -1 ? storedTab : allTabs[0],
|
||||
enabled: opts.alwaysEnabled || !li.storage.get('nochat'),
|
||||
placeholderKey: 'talkInChat',
|
||||
loading: false,
|
||||
|
@ -71,7 +78,7 @@ export default function(opts: ChatOpts, redraw: Redraw): Ctrl {
|
|||
}
|
||||
instanciateModeration();
|
||||
|
||||
const note = data.userId && opts.noteId ? noteCtrl({
|
||||
const note = opts.noteId ? noteCtrl({
|
||||
id: opts.noteId,
|
||||
trans,
|
||||
redraw
|
||||
|
@ -104,8 +111,10 @@ export default function(opts: ChatOpts, redraw: Redraw): Ctrl {
|
|||
data,
|
||||
opts,
|
||||
vm,
|
||||
allTabs,
|
||||
setTab(t: Tab) {
|
||||
vm.tab = t;
|
||||
tabStorage.set(t);
|
||||
redraw()
|
||||
},
|
||||
moderation: () => moderation,
|
||||
|
|
|
@ -55,6 +55,7 @@ export interface Ctrl {
|
|||
data: ChatData
|
||||
opts: ChatOpts
|
||||
vm: ViewModel
|
||||
allTabs: Tab[]
|
||||
preset: PresetCtrl
|
||||
note?: NoteCtrl
|
||||
moderation(): ModerationCtrl | undefined
|
||||
|
|
|
@ -19,11 +19,8 @@ export default function(ctrl: Ctrl): VNode {
|
|||
|
||||
function normalView(ctrl: Ctrl) {
|
||||
const active = ctrl.vm.tab;
|
||||
const tabs: Array<Tab> = ['discussion'];
|
||||
if (ctrl.note) tabs.push('note');
|
||||
if (ctrl.plugin) tabs.push(ctrl.plugin.tab.key);
|
||||
return [
|
||||
h('div.chat_tabs.nb_' + tabs.length, tabs.map(t => renderTab(ctrl, t, active))),
|
||||
h('div.chat_tabs.nb_' + ctrl.allTabs.length, ctrl.allTabs.map(t => renderTab(ctrl, t, active))),
|
||||
h('div.content.' + active,
|
||||
(active === 'note' && ctrl.note) ? [noteView(ctrl.note)] : (
|
||||
ctrl.plugin && active === ctrl.plugin.tab.key ? [ctrl.plugin.view()] : discussionView(ctrl)
|
||||
|
|
Loading…
Reference in a new issue